alert("Text Stirfry\n\nBy Blaine Christian\nblaine@npoly.com");
    if(app.documents.length<1){
	app.documents.add(500, 500, 72.0);
  }
  AD = app.activeDocument;
   var defaultRulerUnits = app.preferences.rulerUnits;
  app.preferences.rulerUnits = Units.PIXELS;

 	bgGrey = new SolidColor();

	var fontType =prompt("Enter a font name.\nThis is hard. You need to use the exact name as far as your OS is concerned.\ntype CURRENT to use the font on an active layer.\nPhotoshop will use Myriad if you enter a bad font name.")	
	if (fontType =="CURRENT"){
		if(AD.activeLayer.kind == LayerKind.TEXT){
				if(AD.activeLayer.textItem.font!= undefined){ 
					alert("As far as your computer is concerned...\n your current fonts name is\n"+AD.activeLayer.textItem.font+"\nCopy this exactly to skip this step next time.");
					fontType=AD.activeLayer.textItem.font
				}
				}

	else{
			alert("If you want to use the CURRENT command, you need to first create a type layer, choose a font\n and leave that as the active layer (highlighted in the layer panel) before starting this script.\n For now you get the default text.");
			fontType="Arial"
			}
	}
  var textArray =prompt("Enter a word(s) or a phrase.");
	 if(textArray == "undefined") {
	 	textArray = "Text Stir Fry";
 	}
  var recursion = prompt("How many times? \n the default is 100 - the larger the number the longer it will take.")
  if(recursion/1 != recursion || recursion<1){
  	recursion = 100;
  	}


	for (i=0;i<recursion;i++){
	
	bgGrey.rgb.red = Math.round(Math.random()*255);
	bgGrey.rgb.green = Math.round(Math.random()*255);
	bgGrey.rgb.blue =  Math.round(Math.random()*255);

	backgroundColor = bgGrey;

  
		var TextLayer = AD.artLayers.add();
		TextLayer.kind = LayerKind.TEXT;
		TextLayer.opacity = 30;
		var txtRef = TextLayer.textItem;
		txtRef.color = backgroundColor;
		txtRef.font = fontType;
		txtRef.contents = textArray
		txtRef.size = AD.width/32 + Math.round(Math.random()*100);
		TextLayer.rotate(i);
		var textPosition = [Math.abs(Math.round(Math.random()*AD.width)-Math.round(Math.random()*AD.width)), Math.abs(Math.round(Math.random()*AD.height)-Math.round(Math.random()*AD.height))];
		txtRef.position = textPosition;
		}




  	
