// MakePointType
// Nathaniel Vaughn KELSO
// 2007.July.8 
// at Hyattsville, MD
// Version 0.3
// DESC: Takes a area type box and extracts the text and turns into point type
// TODO: Fix baseline offset issue (where the text frame moves up from where the point text was)
// TODO: Extend to work with text on a line (PATHTEXT)

// Version 0.2
// (c) vd [vd(kot)online.com.ua]

if(documents.length > 0) {
	doc = activeDocument;
	mySelection = activeDocument.selection;

	// If there are enough to process
	if (mySelection instanceof Array)

	// For each of the selected items
	for(i=0; i<mySelection.length; i++)
	// That are textFrames
	if (mySelection[i].typename == "TextFrame" && mySelection[i].kind == TextType.AREATEXT) {
		obj = mySelection[i];
		objTop = obj.top;
		objLeft = obj.left;

		// Make the new point type object and locate it
		copy1 = obj.parent.textFrames.add();
		copy1.left = objLeft;
		copy1.top = objTop;

		// Run thru the paragraphs
		for(j=0;j<obj.paragraphs.length;j++) {
			frame = obj.paragraphs[j];
			// If there is more than one paragraph add a char return
			// TODO: Does this mess with formating to be Paragraph?
			if(j>0) copy1.paragraphs.add("");
			frame.duplicate(copy1);
		}

		// Now assign depth of the point text to the area text box
		rect = obj.parent.pathItems.rectangle(copy1.top, copy1.left, copy1.width, copy1.height);
		copy2 = obj.parent.textFrames.areaText(rect);
		copy2.selected = true;
		rect.selected = true;
//		obj.resize( 200, 100);

		obj.textRange.duplicate(copy2);	
		copy1.remove();	
		obj.remove();
	}
}