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 validateBuy_Market_Database(frm)
  {
	var str,s,i
    formElements=["txtBuy_MKdb_sFirstName","txtBuy_MKdb_sLastName","txtBuy_MKdb_sAddress1","txtBuy_MKdb_sAddress2","txtBuy_MKdb_sCity","txtBuy_MKdb_sState","txtBuy_MKdb_sPinCode","txtBuy_MKdb_sEmail","txtBuy_MKdb_sTelephone","txtBuy_MKdb_sCompanyName","txtBuy_MKdb_sUserName","txtBuy_MKdb_sPassword","txtBuy_MKdb_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_MKdb_sFirstName.value.length==0)
	{
		alert("Please enter your first name!");
		frm.txtBuy_MKdb_sFirstName.focus();
		return false;
	}
	
	if (frm.txtBuy_MKdb_sLastName.value.length==0)
	{
		alert("Please enter your last name!");
		frm.txtBuy_MKdb_sLastName.focus();
		return false;
	}
	
	if (frm.txtBuy_MKdb_sEmail.value.length==0)
	{
		alert("Please enter email!");
		frm.txtBuy_MKdb_sEmail.focus();
		return false;
	}
	
	if (frm.txtBuy_MKdb_sEmail.value.length != 0)
     {
		 if (!isCorrectEmail(frm.txtBuy_MKdb_sEmail.value))
		  {
			alert("Please enter valid email address!");
			frm.txtBuy_MKdb_sEmail.focus();
			return (false);
		  }
      }
	
    	if (frm.txtBuy_MKdb_sAddress1.value.length==0)
		 {
			alert("Please enter address!");
			frm.txtBuy_MKdb_sAddress1.focus();
			return false;
	 	}

	 	if (frm.txtBuy_MKdb_sCity.value.length==0)
		 {
			alert("Please enter city!");
			frm.txtBuy_MKdb_sCity.focus();
			return false;
	 	 }
		 
		if (frm.txtBuy_MKdb_sState.value.length==0)
		 {
			alert("Please enter state!");
			frm.txtBuy_MKdb_sState.focus();
			return false;
	 	 } 

		if (frm.txtBuy_MKdb_sPinCode.value.length==0)
		 {
			alert("Please enter pincode!");
			frm.txtBuy_MKdb_sPinCode.focus();
			return false;
	 	 } 

		if (frm.cboBuy_MKdb_sCountry.value=="Select country")
		 {
			alert("Please select country!");
			frm.cboBuy_MKdb_sCountry.focus();
			return false;
	 	 } 
		 
		 if (frm.txtBuy_MKdb_sTelephone.value.length==0)
		 {
			alert("Please enter telephone!");
			frm.txtBuy_MKdb_sTelephone.focus();
			return false;
	 	 } 

	if (frm.rdoBuy_MKdb_iDeliveryType[0].checked==true)
	 {
		if (frm.txtBuy_MKdb_sUserName.value.length==0)
		 {
			alert("Please enter username!");
			frm.txtBuy_MKdb_sUserName.focus();
			return false;
	 	 } 
		 
		 if (frm.txtBuy_MKdb_sUserName.value.length !=0)
		 {		
			if (isNaN(frm.txtBuy_MKdb_sUserName.value)==false)
			{
				alert("Please enter characters!");
				frm.txtBuy_MKdb_sUserName.focus();
				return (false);
			} 
		}
		
		if (frm.txtBuy_MKdb_sUserName.value.length <=7 || frm.txtBuy_MKdb_sUserName.value.length >32)
		 {
			alert("Please enter characters length between 8 and 32!");
			frm.txtBuy_MKdb_sUserName.focus();
			return false;
	 	 } 
		
		
	if (frm.txtBuy_MKdb_sPassword.value.length==0)
		 {
			alert("Please enter password!");
			frm.txtBuy_MKdb_sPassword.focus();
			return false;
	 	 } 
		 
		 if (frm.txtBuy_MKdb_sPassword.value.length !=0)
		 {		
			if (isNaN(frm.txtBuy_MKdb_sPassword.value)==false)
			{
				alert("Please enter characters!");
				frm.txtBuy_MKdb_sPassword.focus();
				return (false);
			} 
		}
		
		
		if (frm.txtBuy_MKdb_sPassword.value.length <=3 || frm.txtBuy_MKdb_sPassword.value.length >16)
		 {
			alert("Please enter character length between 4 and 16!");
			frm.txtBuy_MKdb_sPassword.focus();
			return false;
	 	 } 
		
		
		if (frm.txtBuy_MKdb_sReEnterPassword.value.length==0)
		 {
			alert("Please re-enter password!");
			frm.txtBuy_MKdb_sReEnterPassword.focus();
			return false;
	 	 } 
	  
		if (frm.txtBuy_MKdb_sReEnterPassword.value !=frm.txtBuy_MKdb_sPassword.value)
		 {
			alert("Password do not match!");
			frm.txtBuy_MKdb_sReEnterPassword.focus();
			return false;
	 	 } 
	 } 


	if (frm.cboBuy_MKdb_sCountry.value !="India" && frm.rdoBuy_MKdb_iDeliveryType[1].checked==true )
		 {
			alert("Shipping of database through CD is currently available only to Indian customers\nOther customer please choose download through internet!");
			 frm.rdoBuy_MKdb_iDeliveryType[0].focus();
			return false;
	 	 } 	
		
		
	if (frm.chkTerms.checked ==false)
	{
		alert("Please read and accept our terms and conditions!");
		frm.chkTerms.focus();
		return false;
	}

		return true;
	 
	}
	
	
function proceedToPurchase(frm)
{
	 frm.action="Buy_mkdb-form.asp"
	 frm.target="_self";
	 frm.method="post"
	 frm.submit();
 
 return true;
}

function validateMemberLogin(frm)
  {
	var str,s,i
    formElements=["txtBuy_MKdb_sUserName","txtBuy_MKdb_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_MKdb_sUserName.value.length==0)
	{
		alert("Please enter username!");
		frm.txtBuy_MKdb_sUserName.focus();
		return false;
	}
	
	if (frm.txtBuy_MKdb_sPassword.value.length==0)
	{
		alert("Please enter password!");
		frm.txtBuy_MKdb_sPassword.focus();
		return false;
	}
	
   	return true;
	 
	}


function validateNewsLetter(frm)
  {
	var str,s,i
    formElements=["txtNews_sFirstName","txtNews_sLastName","txtNews_sAddress1","txtNews_sAddress2","txtNews_sCity","txtNews_sState","txtNews_sPinCode","txtNews_sEmail","txtNews_sTelephone","txtNews_sCompanyName"];
	for(i=0;i<10;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.txtNews_sFirstName.value.length==0)
	{
		alert("Please enter your first name!");
		frm.txtNews_sFirstName.focus();
		return false;
	}
	
	if (frm.txtNews_sLastName.value.length==0)
	{
		alert("Please enter your last name!");
		frm.txtNews_sLastName.focus();
		return false;
	}
	
	if (frm.txtNews_sEmail.value.length==0)
	{
		alert("Please enter email!");
		frm.txtNews_sEmail.focus();
		return false;
	}
	
	if (frm.txtNews_sEmail.value.length != 0)
     {
		 if (!isCorrectEmail(frm.txtNews_sEmail.value))
		  {
			alert("Please enter valid email address!");
			frm.txtNews_sEmail.focus();
			return (false);
		  }
      }
	
    	if (frm.txtNews_sAddress1.value.length==0)
		 {
			alert("Please enter address!");
			frm.txtNews_sAddress1.focus();
			return false;
	 	}

	 	if (frm.txtNews_sCity.value.length==0)
		 {
			alert("Please enter city!");
			frm.txtNews_sCity.focus();
			return false;
	 	 }
		 
		if (frm.txtNews_sState.value.length==0)
		 {
			alert("Please enter state!");
			frm.txtNews_sState.focus();
			return false;
	 	 } 

		if (frm.txtNews_sPinCode.value.length==0)
		 {
			alert("Please enter pincode!");
			frm.txtNews_sPinCode.focus();
			return false;
	 	 } 

		if (frm.cboNews_sCountry.value=="Select country")
		 {
			alert("Please select country!");
			frm.cboNews_sCountry.focus();
			return false;
	 	 } 
		 
		 if (frm.txtNews_sTelephone.value.length==0)
		 {
			alert("Please enter telephone!");
			frm.txtNews_sTelephone.focus();
			return false;
	 	 } 

		return true;
	 
	}
