function isCorrectEmail(email)
	{
		  var result = false
		  var theStr = new String(email)
		  var index = theStr.indexOf("@");
		  if (index > 0)
		  {
			    var pindex = theStr.indexOf(".",index);
			    if ((pindex > index+1) && (theStr.length > pindex+1))
				result = true;
		  }
  			return result;
  }

 function validateDownload(frm)
  {
	var str,s,i
    formElements=["txtema_down_sFirstName","txtema_down_sLastName","txtema_down_sAddress1","txtema_down_sAddress2","txtema_down_sCity","txtema_down_sState","txtema_down_sPinCode","txtema_down_sEmail","txtema_down_sTelephone"];
	for(i=0;i<9;i++)
    	{
      		if(frm.elements[formElements[i]].value.length !=0)
      		{ 
         		str=frm.elements[formElements[i]].value
     		    s = str.replace(/^(\s)*/, '');
		        s = s.replace(/(\s)*$/, '');
        		frm.elements[formElements[i]].value=s
      		}  
    	}
	
	if (frm.txtema_down_sFirstName.value.length==0)
	{
		alert("Please enter your first name!");
		frm.txtema_down_sFirstName.focus();
		return false;
	}
	
	if (frm.txtema_down_sLastName.value.length==0)
	{
		alert("Please enter your last name!");
		frm.txtema_down_sLastName.focus();
		return false;
	}
	
	if (frm.txtema_down_sEmail.value.length==0)
	{
		alert("Please enter email!");
		frm.txtema_down_sEmail.focus();
		return false;
	}
	
	if (frm.txtema_down_sEmail.value.length != 0)
     {
		 if (!isCorrectEmail(frm.txtema_down_sEmail.value))
		  {
			alert("Please enter valid email address!");
			frm.txtema_down_sEmail.focus();
			return (false);
		  }
      }
	
    	if (frm.txtema_down_sAddress1.value.length==0)
		 {
			alert("Please enter address!");
			frm.txtema_down_sAddress1.focus();
			return false;
	 	}

	 	if (frm.txtema_down_sCity.value.length==0)
		 {
			alert("Please enter city!");
			frm.txtema_down_sCity.focus();
			return false;
	 	 }
		 
		if (frm.txtema_down_sState.value.length==0)
		 {
			alert("Please enter state!");
			frm.txtema_down_sState.focus();
			return false;
	 	 } 

		if (frm.txtema_down_sPinCode.value.length==0)
		 {
			alert("Please enter pincode!");
			frm.txtema_down_sPinCode.focus();
			return false;
	 	 } 

		if (frm.cboema_down_sCountry.value=="Select country")
		 {
			alert("Please select country!");
			frm.cboema_down_sCountry.focus();
			return false;
	 	 } 
		 
		 if (frm.txtema_down_sTelephone.value.length==0)
		 {
			alert("Please enter telephone!");
			frm.txtema_down_sTelephone.focus();
			return false;
	 	 } 
		 
	
		return true;
	 
	}

function proceedToPurchase(frm)
{
	 frm.action="Buy_ema-form.asp"
	 frm.target="_self";
	 frm.method="post"
	 frm.submit();
 
 return true;
}

function validateBuy_Emailer(frm)
  {
	var str,s,i
    formElements=["txtBuy_Ema_sFirstName","txtBuy_Ema_sLastName","txtBuy_Ema_sAddress1","txtBuy_Ema_sAddress2","txtBuy_Ema_sCity","txtBuy_Ema_sState","txtBuy_Ema_sPinCode","txtBuy_Ema_sEmail","txtBuy_Ema_sTelephone","txtBuy_Ema_sCompanyName","txtBuy_Ema_sUserName","txtBuy_Ema_sPassword","txtBuy_Ema_sReEnterPassword"];
	for(i=0;i<13;i++)
    	{
      		if(frm.elements[formElements[i]].value.length !=0)
      		{ 
         		str=frm.elements[formElements[i]].value
     		    s = str.replace(/^(\s)*/, '');
		        s = s.replace(/(\s)*$/, '');
        		frm.elements[formElements[i]].value=s
      		}  
    	}
	

	if (frm.txtBuy_Ema_sFirstName.value.length==0)
	{
		alert("Please enter your first name!");
		frm.txtBuy_Ema_sFirstName.focus();
		return false;
	}
	
	if (frm.txtBuy_Ema_sLastName.value.length==0)
	{
		alert("Please enter your last name!");
		frm.txtBuy_Ema_sLastName.focus();
		return false;
	}
	
	if (frm.txtBuy_Ema_sEmail.value.length==0)
	{
		alert("Please enter email!");
		frm.txtBuy_Ema_sEmail.focus();
		return false;
	}
	
	if (frm.txtBuy_Ema_sEmail.value.length != 0)
     {
		 if (!isCorrectEmail(frm.txtBuy_Ema_sEmail.value))
		  {
			alert("Please enter valid email address!");
			frm.txtBuy_Ema_sEmail.focus();
			return (false);
		  }
      }
	
    	if (frm.txtBuy_Ema_sAddress1.value.length==0)
		 {
			alert("Please enter address!");
			frm.txtBuy_Ema_sAddress1.focus();
			return false;
	 	}

	 	if (frm.txtBuy_Ema_sCity.value.length==0)
		 {
			alert("Please enter city!");
			frm.txtBuy_Ema_sCity.focus();
			return false;
	 	 }
		 
		if (frm.txtBuy_Ema_sState.value.length==0)
		 {
			alert("Please enter state!");
			frm.txtBuy_Ema_sState.focus();
			return false;
	 	 } 

		if (frm.txtBuy_Ema_sPinCode.value.length==0)
		 {
			alert("Please enter pincode!");
			frm.txtBuy_Ema_sPinCode.focus();
			return false;
	 	 } 

		if (frm.cboBuy_Ema_sCountry.value=="Select country")
		 {
			alert("Please select country!");
			frm.cboBuy_Ema_sCountry.focus();
			return false;
	 	 } 
		 
		 if (frm.txtBuy_Ema_sTelephone.value.length==0)
		 {
			alert("Please enter telephone!");
			frm.txtBuy_Ema_sTelephone.focus();
			return false;
	 	 } 

		if (frm.txtBuy_Ema_sUserName.value.length==0)
		 {
			alert("Please enter username!");
			frm.txtBuy_Ema_sUserName.focus();
			return false;
	 	 } 
		 
		 if (frm.txtBuy_Ema_sUserName.value.length !=0)
		 {		
			if (isNaN(frm.txtBuy_Ema_sUserName.value)==false)
			{
				alert("Please enter characters!");
				frm.txtBuy_Ema_sUserName.focus();
				return (false);
			} 
		}
		
		if (frm.txtBuy_Ema_sUserName.value.length <=7 || frm.txtBuy_Ema_sUserName.value.length >32)
		 {
			alert("Please enter characters length between 8 and 32!");
			frm.txtBuy_Ema_sUserName.focus();
			return false;
	 	 } 
		
		
	if (frm.txtBuy_Ema_sPassword.value.length==0)
		 {
			alert("Please enter password!");
			frm.txtBuy_Ema_sPassword.focus();
			return false;
	 	 } 
		 
		 if (frm.txtBuy_Ema_sPassword.value.length !=0)
		 {		
			if (isNaN(frm.txtBuy_Ema_sPassword.value)==false)
			{
				alert("Please enter characters!");
				frm.txtBuy_Ema_sPassword.focus();
				return (false);
			} 
		}
		
		
		if (frm.txtBuy_Ema_sPassword.value.length <=3 || frm.txtBuy_Ema_sPassword.value.length >16)
		 {
			alert("Please enter character length between 4 and 16!");
			frm.txtBuy_Ema_sPassword.focus();
			return false;
	 	 } 
		
		
		if (frm.txtBuy_Ema_sReEnterPassword.value.length==0)
		 {
			alert("Please re-enter password!");
			frm.txtBuy_Ema_sReEnterPassword.focus();
			return false;
	 	 } 
	  
		if (frm.txtBuy_Ema_sReEnterPassword.value !=frm.txtBuy_Ema_sPassword.value)
		 {
			alert("Password do not match!");
			frm.txtBuy_Ema_sReEnterPassword.focus();
			return false;
	 	 } 

		return true;
	 
	}

function validateMemberLogin(frm)
  {
	var str,s,i
    formElements=["txtBuy_Ema_sUserName","txtBuy_Ema_sPassword"];
	for(i=0;i<2;i++)
    	{
      		if(frm.elements[formElements[i]].value.length !=0)
      		{ 
         		str=frm.elements[formElements[i]].value
     		    s = str.replace(/^(\s)*/, '');
		        s = s.replace(/(\s)*$/, '');
        		frm.elements[formElements[i]].value=s
      		}  
    	}
	
	if (frm.txtBuy_Ema_sUserName.value.length==0)
	{
		alert("Please enter username!");
		frm.txtBuy_Ema_sUserName.focus();
		return false;
	}
	
	if (frm.txtBuy_Ema_sPassword.value.length==0)
	{
		alert("Please enter password!");
		frm.txtBuy_Ema_sPassword.focus();
		return false;
	}
	
   	return true;
	 
	}
	