// declaring searchURL variable, which will be the complete URL for submitting the search to the appropriate application
var searchURL = "";

// Local configuration
	var atomzid = "sp1001e64c";
	// 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-w-control=1&sp-w=&sp-f=iso-8859-1&sp-date-range=7";

// Main function
function submitsearch() {
	// assigns form values into JavaScript variables
	var affildomain = document.zeform.affil.value;
	var affilprintname = document.zeform.affilprint.value;
	var archiveproduct = document.zeform.p_product.value;
	var searchwords = document.zeform.keyword.value;

	if (searchwords=="")
		{
			alert ("Please enter a search word(s)");
		} //end if
	else {
 		if (document.zeform.searchtype[0].checked)
		{
			searchURL = beginURL + searchwords + "&sp-a=" + atomzid + endURL;
			document.location=searchURL;
		} //end if
		if (document.zeform.searchtype[1].checked)
		{
			// 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=_rank_%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


