
//function handles whether it is a ChemACX, ChemFinder or Standard Search
//if ChemACX or ChemFinder is chosen the action is set to submit to the appropriate site
//if any of the other drop down choices are selected it is submitted to atomz.com

function submission(whereto)
{  	
	var whereto = document.searchform["sp-k"].options[document.searchform["sp-k"].selectedIndex].value;
	
	if (whereto == "ChemFinder")
	{	
		var submitto = "http://www.chemfinder.com/result.asp";
		document.searchform.method = "post";
		
		//takes the sp-q filed and changes it to the filed required by ChemFinder
		document.searchform.polyQuery.value = document.searchform["sp-q"].value;
		document.searchform.action = submitto;
		return(true);
	}
	else if (whereto == "ChemACX")
	{
		var submitto = "http://www.chemacx.com/chemacx/testTextQuery.asp";
		document.searchform.method = "get";
		document.searchform.querystring.value = document.searchform["sp-q"].value;
		document.searchform.action = submitto;
		return(true);
	} 
	else if (whereto == "ChemStore")
	{
		var submitto = "http://scistore.cambridgesoft.com/search.cfm";
		document.searchform.method = "post";
		document.searchform.searchterm.value = document.searchform["sp-q"].value;
		document.searchform.step.value = 2;
		document.searchform.action = submitto;
		return(true);
	} 
	else 
	{
		document.searchform.method = "get"
		document.searchform.action = "http://search.atomz.com/search/";
		return(true);
	}
}

//defaultselect is the drop down which you want selected when writing the form (case sensitive)
//fieldsize is the size of the search box field
//firstbreak is true/false for a break after the search box
//secondbreak is a true/false for a break after the drop down box
//endform is a true/false for whether you want to end the form with this script or in your html (put in due to spacing issues)
//	document.write("<option value=\"ChemACX\"> ChemACX.Com </option>");
function writesearchform(defaultselect, fieldsize, firstbreak, secondbreak, endform)
{
	document.write("<form name=\"searchform\" onsubmit=\"submission()\">");

	document.write("<select name=\"sp-k\">");
	document.write("<option value=\"CambridgeSoft\"> CambridgeSoft </option>");
	document.write("<option value=\"Support\"> Tech Support </option>");
	document.write("<option value=\"ChemStore\"> SciStore.Com </option>");
	document.write("<option value=\"ChemFinder\"> ChemFinder.Com </option>");
	document.write("<option value=\"ChemNews\"> ChemBioNews.Com </option>");
	document.write("<option value=\"ChemClub\"> ChemClub.Com </option>");
	document.write("</select>&nbsp;");
	
	if (firstbreak)
	{
		document.write("<BR>");
	}
	
	var inputbox = "<input size=" + fieldsize + " name=\"sp-q\">";
	document.write(inputbox);
	
	if (secondbreak)
	{
		document.write("<BR>");
	}
	
	document.write("<input type=hidden name=\"polyQuery\">");
	document.write("<input type=hidden name=\"querystring\">");
	document.write("<input type=hidden name=\"sp-a\" value=\"000337ea-sp00000000\">");
	document.write("<input type=hidden name=\"searchterm\">");
	document.write("<input type=hidden name=\"step\">");
	
	if (typeof imgbutton == 'string'){
	document.write("&nbsp;<input type=\"image\" border=0 value=\"Search\" src=\"" + imgbutton + "\" align=absmiddle class=nobrd>")
	}
	else{
	document.write("<input type=\"submit\" value=\"Search\">")
	}
	//loops through the list to select the default drop down
	if (endform != false )
	{
		document.write("</form>");
	}
	for (var i = 0; i < document.searchform["sp-k"].options.length; i++) 
	 {  
	 	if (document.searchform["sp-k"].options[i].value == defaultselect)
		{
		 	document.searchform["sp-k"].options[i].selected = true;
			break;
		 }     
	 }
	 
	document.write("</form>");
}


