//Written by Paul Stothard, University of Alberta, Canada
//Modified by George Waldon

function restSummary (theDocument) {	

	var newDna = "";
	var title = "";
	var maxInput = 100000;

	var restrictionSites = getRestrictionSiteString(theDocument.forms[0].elements[4].options[theDocument.forms[0].elements[4].selectedIndex].value);

	if ((checkFormElement (theDocument.forms[0].elements[0]) == false) || (checkSequenceLength(theDocument.forms[0].elements[0].value, maxInput) == false))	{
		return false;
	}

	itemsToCheck = restrictionSites.split(/,/);
    // not valid anymore
	//if (checkRestPatterns(itemsToCheck) == false)	{
	//	return false;
	//}

	openWindow("Restriction Summary");
	outputWindow.document.write(RestrictionSiteTypetoString(theDocument.forms[0].elements[4].options[theDocument.forms[0].elements[4].selectedIndex].value));
	outputWindow.document.write("<br /><br />\n");
    var arrayOfFasta = getArrayOfFasta (theDocument.forms[0].elements[0].value);

	for (var i = 0; i < arrayOfFasta.length; i++)	{
		newDna = getSequenceFromFasta (arrayOfFasta[i]);
		title = getTitleFromFasta(arrayOfFasta[i]);

		newDna = removeNonDna(newDna);
		outputWindow.document.write(getInfoFromTitleAndSequenceAndTopology(title, newDna, theDocument.forms[0].elements[5].options[theDocument.forms[0].elements[5].selectedIndex].value));
        outputWindow.document.write("<br />\n");
		writeRestrictionSites (newDna, itemsToCheck, theDocument.forms[0].elements[5].options[theDocument.forms[0].elements[5].selectedIndex].value);
		outputWindow.document.write ('<br />\n<br />\n');
	}

	//closePre();
	closeWindow();
	return true;	

}

