﻿
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function validate_form()
{
	
	if (document.FINDPLANT.loc.value=='st')	// state/region
		if (document.FINDPLANT.srg.selectedIndex==0)
		{
			alert('Please select a state or region for your search.');
			return false;		
		}
	
	if (document.FINDPLANT.loc.value=='zip') // zip code
		if ((document.FINDPLANT.tbZip.value.length<5)||(document.FINDPLANT.tbZip.value=='Zip Code'))
		{
			alert('Please enter a valid zip/postal code for your search.');
			return false;			
		}
	
	if (document.FINDPLANT.chkShip.checked)
	{
	    document.FINDPLANT.loc.value='ship';
	}
	
	return true;
}


function processCookie()
{
    if (document.FINDPLANT.chkShip.checked)
    {        
    	document.cookie += con_code + ':LOC=ship';
	    document.cookie += con_code + ':STATE='+ document.FINDPLANT.srg.options[document.FINDPLANT.srg.selectedIndex].value;
	}
	if (document.FINDPLANT.loc(0).checked)	// state/region
	{
		document.cookie += con_code + ':LOC=st';
	    document.cookie += con_code + ':STATE='+ document.FINDPLANT.srg.options[document.FINDPLANT.srg.selectedIndex].value;
	}			
	
	if (document.FINDPLANT.loc(2).checked) // zip code
	{
	    document.cookie += con_code + ':LOC=zip';
		document.cookie += con_code + ':ZIP='+ document.FINDPLANT.tbZip.value;
	}
	

}

function submit_form()
{			
	document.FINDPLANT.action = buildPlantLink();	
	setTimeout('document.FINDPLANT.submit',50);
}


function show(objName)
{
    var objShow = document.getElementById(objName);
        
    if (objShow.style.visibility=='hidden')
    {
        objShow.style.visibility='visible';
        objShow.style.display='block';        
    }
    else
    {
        objShow.style.visibility='hidden';
        objShow.style.display='none';        
    }

}

function validate_ecard()
{
    var rxEmail = new RegExp(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.\w{2,3}$/);
    var arrE = document.send_ecard.to.value.split(',');
    var sEmail = '';
    
    for (i=0;i<arrE.length;i++)
    {
        sEmail = arrE[i];
        sEmail = sEmail.replace(/ /g,'');
        if (!rxEmail.exec(sEmail))
        {
            alert('Please make sure all email addresses are valid.');
            return false;
            break;
        }
    }
    
    if (document.send_ecard.msg.value.length<3)
    {
        alert('Please enter a valid message.');
        return false;
    }
    return true;


}

