/* Function that goes to the URL. */
function goBackTwice()
{
   history.back( -1 )
   history.back( -1 )
}

function goBackTrice()
{
   history.back( -1 )
   history.back( -1 )
   history.back( -1 )
}

function MM_goToURL() { //v3.0
  	var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  		for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
/* Function that sends email form. */
function emailSubmit(){
	document.emailForm.submit();
}

/* Function that opens a new browser window. */
function MM_openBrWindow(theURL,winName,features) { //v2.0
  	window.open(theURL,winName,features);
}

/* Function that sets the maximum number that can be checked to 5. */
    var maxChecked5 = 5;  
    var totalChecked5 = 0;

function CountChecked5(field) {
		if (field.checked)
            totalChecked5 += 1;
        else
            totalChecked5 -= 1;
        if (totalChecked5 > maxChecked5) {
        	alert ("Sorry! You can't select more than five items!");
				document.form1.box.value=""
            	field.checked = true;
	}
}
	
/* Function that sets the maximum number that can be checked to 10. */
    var maxChecked = 10;  
    var totalChecked = 0;

function CountChecked(field) {
    	if (field.checked)
            totalChecked += 1;
        else
            totalChecked -= 1;
        if (totalChecked > maxChecked) {
            alert ("Sorry! You can't select more than ten chemicals!");
				document.form1.box.value=""
            	field.checked = true;
	}
}
	
function MM_findObj(n, d) { //v3.0
  	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  		if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function writeBox(checkvalue){
	var quote=document.form1.box.value
		document.form1.box.value = quote + ' ' + checkvalue + "\n"
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  		if (restore) selObj.selectedIndex=0;
}

function gotopagechem_sr(choice)
{ 
alert(choice);
location=choice;
location=location.search
alert(location.search);
}

function gotopage(choice)
{
		if(choice=='chemical')
		{
			if (document.choosechem.chemname.options[document.choosechem.chemname.selectedIndex].value != "")
			{
			
		location = document.choosechem.chemname.options[document.choosechem.chemname.selectedIndex].value;
			
			}
			
		}
		else if(choice=='chemical1')
		{
			if (document.choosechem1.chemname.options[document.choosechem1.chemname.selectedIndex].value != "")
			{
		location = document.choosechem1.chemname.options[document.choosechem1.chemname.selectedIndex].value;
			}
			
		}
		
		
		else if(choice=='category')
		{
			if (document.ChemCategory.categoryOption.options[document.ChemCategory.categoryOption.selectedIndex].value != "")
			{
		location = document.ChemCategory.categoryOption.options[document.ChemCategory.categoryOption.selectedIndex].value;
			}
		}
		
}

/* Function that clears radio button and text box. */  
function convertField(buttonName)
{
	var cutNumber = buttonName.substring(6,9);
	var cutLetter = buttonName.substring(9,10);
	var actualNumber = parseInt(cutNumber,10);		
	var startFor = 0;
	var endFor = 0;	
			
	if (actualNumber != 1)
	{					
		for (i = 0; i <= 2; i++)
		{
			var textboxNum = 'document.form1.textbox' + actualNumber + '[' + i + '].value = ""';
			eval(textboxNum);
						
			for (j = 0; j <= 2; j++)
			{
				var radioButtonGroup = 'document.form1.conversion' + actualNumber + cutLetter + '[' + i + '].checked';
				var radioButtonUncheck = 'document.form1.conversion' + actualNumber + cutLetter + '[' + i + '].checked = false';
				if (eval(radioButtonGroup))
				{
					eval(radioButtonUncheck);
				}
			}			
		}
	}
	else
	{	
		startFor = actualNumber - 1;
		endFor = startFor + 2;
		
		for (i = startFor; i <= endFor; i++)
		{
			var textboxNum = 'document.form1.textbox' + actualNumber + '[' + i + '].value = ""';
			eval(textboxNum);
						
			for (j = 0; j <= 2; j++)
			{
				var radioButtonGroup = 'document.form1.conversion' + actualNumber + cutLetter + '[' + i + '].checked';
				var radioButtonUncheck = 'document.form1.conversion' + actualNumber + cutLetter + '[' + i + '].checked = false';
				if (eval(radioButtonGroup))
				{
					eval(radioButtonUncheck);
				}
			}			
		}
	}		
}