
// Function for validating the form inputs
function CheckValidation()
{	
	var lstr_FieldString = "";
	var status=false;
//Mandatory  - Email Field Check length 100
if(document.getElementById("radIntertestDistributor").checked==true)
	{
	status=true;
	}else if(document.getElementById("radcollectionagents").checked==true)
	{
	status=true;
	}
	 if(status==false)
	 {
	   alert("Por favor seleccione su interes!")
	   return false;
	 }

		lstr_FieldString = document.frmPage.txtName.value;
	if(lstr_FieldString=='') 
	{
       alert("Ingresar el nombre!")
   		document.frmPage.txtName.select();
		document.frmPage.txtName.focus();
		return false;
	}
	if(lstr_FieldString.length>50)
	{
		alert("El nombre postal no debe contener mas de 50 caracteres!");
		document.frmPage.txtName.select();
		document.frmPage.txtName.focus();
   		return false;
	}
	lstr_FieldString = document.frmPage.txtPhone.value;
   if(lstr_FieldString !="")
   {
	if(lstr_FieldString.length>15)
	{
		alert("El codigo postal no debe contener mas de 15 caracteres!");
		document.frmPage.txtPhone.select();
		document.frmPage.txtPhone.focus();
   		return false;
	}
	}
	
	
	lstr_FieldString = document.frmPage.txtemailID.value;
	 		
			if(lstr_FieldString=='') 
			{
			    alert("E-mail (requerido)!")
   				document.frmPage.txtemailID.select();
				document.frmPage.txtemailID.focus();
				return false;
			}	
		
			if (echeck(lstr_FieldString)==false)
				{
					document.frmPage.txtemailID.select();
				    document.frmPage.txtemailID.focus();
		            return false;
	             }
	
	 
	 var lstrCodeNo = document.getElementById('CodeNumberTextBox').value;	
		if(lstrCodeNo=='')
		{
		   alert("Codigo de Seguridad (requerido)!")
			document.getElementById('CodeNumberTextBox').select();
			document.getElementById('CodeNumberTextBox').focus();
   			return false;
		
		}
	return true;	
	}	
	
	function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("ĦEl e-mail debe ser valido!!")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("ĦEl e-mail debe ser valido!!")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("ĦEl e-mail debe ser valido!!")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("ĦEl e-mail debe ser valido!!")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("ĦEl e-mail debe ser valido!!")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("ĦEl e-mail debe ser valido!!")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("ĦEl e-mail debe ser valido!!")
		    return false
		 }

 		 return true					
	}
	
	
	
	function refreshCaptcha()
{  
   document.getElementById("captchaImg").src="JpegImage.aspx";
}