// JavaScript Document

function doSearch()
{
	
	var theval = document.forms["searchform"].searchvalue.value.replace(/^\s*|\s*$/g,'');
	
	var addaster = '*';
	if (theval.substring(0,1) == '='){var addaster = ''; };
	
	var thesearchfield = document.forms["searchform"].searchfield.value;
	
	//var thesearchview = document.forms["searchform"].searchview[1].checked;
	var theaction = "";
	var addaction = "";

	//alert(thesearchview);

	//if (theval == '')
//		{
//			alert('Please enter a search term.')
//		}
//	else
//	{
		if (document.forms["searchform"].searchview[0].checked == true)
		{
			theaction = "/search/default.asp?dbname=gelest&dataaction=search&metadata_directive=blind_gui&formgroup=basenp_form_group";
		}
		else
		{
			theaction = "/search/default.asp?dbname=gelest&dataaction=search&metadata_directive=blind_gui&formgroup=msds_form_group&homepage=true";
		}



		if (thesearchfield == 'pc')
			{
				addaction = "&MAIN.Catnum=";
			}
		else if (thesearchfield == 'cas')
			{
				addaction = "&MAIN.CAS=";
			}
		else if (thesearchfield == 'chemname')
			{
				addaction = "&MAIN.Name=";
			}

		theval = addaster + theval + addaster;			
		var reg = /(&laquo;|&raquo;|[\xAB\xBB\x22])/g;
		theval = theval.replace(reg,"*");	
		theval = theval.replace("**","*");
		theval = theval.replace("**","*");
		theaction = theaction + addaction + theval;
		
		
		document.forms["searchform"].action = theaction;
		document.forms["searchform"].submit();
	//}

}
