// declaring searchURL variable, which will be the complete URL for submitting the search to the appropriate application
var searchURL = "";

// Local configuration
	var atomzid = "sp1001e473";
	// beginURL is the first part of the website-search URL. The final URL is assembled like this: beginURL + keyword + endURL
	var beginURL = "http://search.atomz.com/search/?sp-q=";
	// endURL consists of any fields that follow the searchwords in the search URL
	var endURL = "&sp-p=all&sp-f=ISO-8859-1";

// Main function
function submitsearch () {
	// assigns form values into JavaScript variables
	var affildomain = document.searchform.affil.value;
	var affilprintname = document.searchform.affilprint.value;
	var archiveproduct = document.searchform.p_product.value;
	var searchwords = document.searchform.keyword.value;
	var option = document.searchform.searchopt.options[document.searchform.searchopt.selectedIndex].value; 

		//if (option == 0)
		//{
		//searchURL = "http://www.thejournalnews.com/headlines/index.htm";
		//document.location=searchURL;
		//} //end if
		
		if (searchwords=="")
		{
		alert ("Please enter a search word(s)," + menu);
		} //end if
	else {

 		if (option == "Photos")
		{
			var section= "Photo Gallery";
			searchURL = beginURL + searchwords + "&sp-k=" + section + "&sp-a=" + atomzid + endURL;
			document.location=searchURL;
		} //end if
		if (option == "Search")
		{
			searchURL = beginURL + searchwords + "&sp-a=" + atomzid + endURL;
			document.location=searchURL;
		} //end if
		if (option == "Archive")
		{
			// NewsBank search needs several fields specific to the paper, which are declared above, including the domain name, print name, and archive product code
			searchURL = "http://nl.newsbank.com/nl-search/we/Archives?s_site=" + affildomain + "&f_site=" + affildomain + "&f_sitename=" + affilprintname + "&p_theme=gannett&p_action=search&p_field_base-0=&p_text_base-0=" + searchwords + "&Search=Search&p_perpage=10&p_maxdocs=200&p_queryname=700&s_search_type=keyword&p_product=" + archiveproduct + "&p_sort=YMD_date%3AD&p_field_date-0=YMD_date&p_params_date-0=date%3AB%2CE&p_text_date-0=-";
			document.location=searchURL;
		} // end if
	   } // end else
} // end function submitform

// function that enables user to hit "Enter" to submit form instead of clicking "Go" button
function submitenter(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13)
   	{
   		submitsearch();
   		return false;
   	} //end if
	else return true;
} // end submitenter function

