function trim(str){
   return str.replace(/^\s*|\s*$/g,"");
}

function hoverimg(hoverimg,imgid){
    document.getElementById(imgid).src=hoverimg;
}
function normalimg(hoverimg,imgid){
    document.getElementById(imgid).src=hoverimg;
}


function echeck(str) {
		
		if(str.reg_name.value=='')
		{
			alert('Please Enter Your Name')
			str.reg_name.focus();
			return false;
		}
		if(str.reg_user.value=='')
		{
			alert('Please Enter Your Username')
			str.reg_user.focus();
			return false;
		}
		
		if(str.reg_pass1.value=='')
		{
			alert('Please Enter Password')
			str.reg_pass1.focus();
			return false;
		}
		if(str.reg_pass1.value !=str.reg_pass2.value)
		{
			alert('Passworde match Incorrect')
			str.reg_pass2.focus();
			return false;
		}
		if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str.reg_email.value)))
		{
			alert('Please Enter Valid Email Address');
			str.reg_email.focus();
			return false;
		}
		if(str.reg_location.value=='0')
		{
			alert('Please Select Location')
			str.reg_location.focus();
			return false;
		}
		if(str.reg_location.value=='2')
		{
			if(str.reg_state.value=='')
			{
				alert('Please Select State')
				str.reg_state.focus();
				return false;
			}
		}
 		 return true;
	}
function show_hide_states(){
	s=document.getElementById('clist');
  	t=document.getElementById('sltext');
  	slist=document.getElementById('slist');
  	if(s.options[s.selectedIndex].value==2){
    	slist.style.display='';
    	t.style.display='';
  	}else{
    	slist.style.display='none';
    	t.style.display='none';
  	}
}
function whichButton(event){
	if (event.button==2)//RIGHT CLICK
  	{
  		//alert("Not Allow Right Click!");
		return false;
  	}

}
function noCTRL(e){
	var code = (document.all) ? event.keyCode:e.which;
	var msg = "Sorry, this functionality is disabled.";
	if (parseInt(code)==17) //CTRL
	{
		//alert(msg);
		window.event.returnValue = false;
	}
} 


function checksubmit(str){
	
    b=true;
	err = "";
	var j=-1;
	var country
    document.getElementById("stat").value=str.state[str.state.selectedIndex].text;
	//alert(document.getElementById("stat").value);
	while (++j<str.country.length)
	{
		if (str.country[j].checked && str.country[j].value=="USA") {country = true;break;}
		else country = false
	}
    if(str.from_name.value=="") {b=false;err += " - First Name\n";}
    //if(cform.from_surname.value=="") b=false;
    if(str.company.value=="") {b=false;err += " - Company name\n";}
    if(str.from_emailaddress.value=="") {b=false;err += " - E-mail address\n";}
	//alert(country);
	if (country){
	if(str.state[str.state.selectedIndex].value=="") {b=false;err += " - State\n";}
	}
	else  str.state[str.state.selectedIndex].value="";
    if(!b){
		alert("Please Enter:\n\n"+err) ;
		return false;
	}else{
        var emailFilter=/^.+@.+\..{2,3}$/;
        if (!(emailFilter.test(str.from_emailaddress.value))) { 
          alert("Please enter a valid email address.");
		  return false;
        }
        else str.from_emailaddress.focus();
      }
	  return true;
}

function checkreset(){
document.forms[0].reset();
} 

function setoptions(eleid){
		if(eleid=="USA"){
			document.getElementById('slist').disabled="";
			document.getElementById('slist_n').disabled="disabled";
			document.getElementById('slist_c').disabled="disabled";			
		}
		if(eleid=="Non-USA"){
			document.getElementById('slist').disabled="disabled";
			document.getElementById('slist_n').disabled="";
			document.getElementById('slist_c').disabled="disabled";			
		}
		if(eleid=="Canada"){
			document.getElementById('slist').disabled="disabled";
			document.getElementById('slist_n').disabled="disabled";
			document.getElementById('slist_c').disabled="";			
		}
}

function chkforgetfrm(x){
	if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(x.viaemail.value))){
		alert('Please Enter Valid Email Address');
		x.viaemail.focus();
		return false;
	}	
}
function go_to(a){
	  	var f = document.lang;
	  	f.action = "special-offers-S"+a+".html";
	    f.submit();
	  	return true;
}
function checksubmit(cform){
	b=true;
	err = "";
	var j=-1;
	if(cform.from_name.value=="") {b=false;err += " - First Name\n";}
	if(cform.company.value=="") {b=false;err += " - Company name\n";}
	if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(cform.from_emailaddress.value))) {b=false;err += " - Valid E-mail address\n";}
	if(err != "" && b== false){
		alert("Please Enter:\n\n"+err);
		return false;
	}
	return true;
     
}
