

		//history.go(+1)
		window.onerror=myErrorHandler;
		
		function myErrorHandler(){return true;}
		
		function Toggle( commId )
		{	
			var div = document.getElementById(commId);
			var n = document.getElementById("chkPAddress");var n1= n.checked;			
			if(n1=="True" || n1=="true" || n1){document.all[commId].style.display = 'none';return;}
			document.all[commId].style.display = 'block';				
		}
		
		function checkBox()
		{
			document.getElementById("chkDAddress").checked = false;
			var n = document.getElementById("chkPAddress");var n1= n.checked;			
			if(n1=="True" || n1=="true" || n1)
			{
				n = document.getElementById("txtAdd1").value;
				document.getElementById("txtPA1").value=n;				
				n=document.getElementById("txtAdd2").value;
				document.getElementById("txtPA2").value=n;
				n=document.getElementById("txtArea").value;
				document.getElementById("txtA1").value=n;
				n=document.getElementById("txtCity").value;
				document.getElementById("txtCity1").value=n;
				n=document.getElementById("txtDist").value;
				document.getElementById("txtDist1").value=n;
				n=document.getElementById("txtPincode").value;
				document.getElementById("txtPincode1").value=n;
				n=document.getElementById("ddlEmirates").value;
				document.getElementById("ddState1").value=n;
			}
			Toggle("div1");
		}
		
		function DifferentAddress()
		{   			
			document.getElementById("chkPAddress").checked = false;
			document.getElementById("txtPA1").value="";
			document.getElementById("txtPA2").value="";
			document.getElementById("txtA1").value="";
			document.getElementById("txtCity1").value="";
			document.getElementById("txtDist1").value="";
			document.getElementById("txtPincode1").value="";
			//document.getElementById("ddState1").value="-1";			
			Toggle("div1"); 						
		}
		
		function isInt(x) 
		{ 
			var y=parseInt(x);if (isNaN(y)) return false; 
			return parseInt(x)== parseInt(y) && x.toString()==y.toString(); 
		} 
		
		function isFloat(x) 
		{ 
			var y=parseFloat(x);if (isNaN(y)) return false; 
			return parseFloat(x)== parseFloat(y) && x.toString()==y.toString(); 
		}
		
		String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
				
		function finalValidate()		
		{
			return confirm("Do you want to confirm this user name registration?");
		}
			
		function openWL()
		{
			window.open("../register/rptwelcomeletter.aspx","_newwindow","menubar=no,scrollbars=yes");
		}
		
		function checkUserName()
		{
			var valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";			
			for(i=0;i<document.getElementById("txtUser").value.length;i++)
			{
				if(valid.indexOf(document.getElementById("txtUser").value.charAt(i))==-1){return true;break;}
			}
		}
			
		function validate()
		{
			var n,n1;
			
			var dom = (document.getElementById) ? true : false;
			var nodyn = (!dom) ? true : false;
			if (nodyn) { event = "nope" }
			if (nodyn) return;
			n = document.getElementById("txtName");
			n1= n.value;n1=n1.trim();			
			if (n1.length < 5)
			{
				alert("Required Field (Name) cannot be blank [Min 5 Chars]");
				n.focus();return false;
			}
			
			if (checkUserName())
			{
				alert("Required Field (Name) cannot be blank [Min 5 Chars]");
				document.getElementById("txtUser").focus();return false;
			}
			
			n=document.getElementById("ddMonth");n1=n.value;     
			if (n1 == "-1" )
			{
			
				alert("Required Field (Month of Birth) to be selected");
				n.focus();return false;
			}
			
			n=document.getElementById("ddDate");
			n1=n.value;     
			if (n1 == "-1" )
			{
				alert("Required Field (Date of Birth) to be selected");
				n.focus();return false;
			}
			
			n=document.getElementById("ddYear");
			n1=n.value;     
			if (n1 == "-1" )
			{
				alert("Required Field (Year of Birth) to be selected");
				n.focus();return false;
			}
			
			n = document.getElementById("txtFName");
			n1= n.value;n1=n1.trim();			
			if (n1.length < 3)
			{
				alert("Required Field (Fathers Name) cannot be blank [Min 3 Chars]");
				n.focus();return false;
			}
			
			n = document.getElementById("txtMName");
			n1= n.value;n1=n1.trim();			
			if (n1.length < 3)
			{
				alert("Required Field (Mothers Name) cannot be blank [Min 3 Chars]");
				n.focus();return false;
			}

			n = document.getElementById('txtPAN');
			n1=n.value; n1=n1.trim();
			if(n1!="" || n1.length > 0)
			{
				if(checkPanTan(n1,'PAN')){n.focus();return false;}
			}		
			
			n = document.getElementById('txtTAN');
			n1=n.value; n1=n1.trim();
			if(n1!="" || n1.length > 0)
			{
				if(checkPanTan(n1,'TAN')){n.focus();return false;}
			}
			
			n = document.getElementById("txtOccup");
			n1= n.value;n1=n1.trim();			
			if (n1.length < 5)
			{
				alert("Required Field (Occupation) cannot be blank [Min 5 Chars]");
				n.focus();return false;
			}
			
			
			n = document.getElementById("txtPassport");
			n1= n.value;
			n1=n1.trim();			
			if (n1.length < 5)
			{
				alert("Required Field (Passport Number) cannot be blank [Min 5 Chars]");
				n.focus();return false;
			}
			
			n = document.getElementById("txtVisa");
			n1= n.value;n1=n1.trim();			
			if (n1.length < 5)
			{
				alert("Required Field (Visa) cannot be blank [Min 5 Chars]");
				n.focus();return false;
			}
			
			n = document.getElementById("txtBankName");
			n1= n.value;n1=n1.trim();			
			if (n1.length < 5)
			{
				alert("Required Field (Bank Name) cannot be blank [Min 5 Chars]");
				n.focus();return false;
			}
			
			n = document.getElementById("txtActNo");
			n1= n.value;n1=n1.trim();			
			if (n1.length < 5)
			{
				alert("Required Field (Bank Acc No) cannot be blank [Min 5 Chars]");
				n.focus();return false;
			}
			
			/*n = document.getElementById("txtIFSC");
			n1= n.value;
			n1=n1.trim();			
			if (n1.length < 5)
			{
				alert("Please Enter Bank SWIFT Code! (Minimum 5 Characters)");
				n.focus();         
				return false;
			}  */
			 
			n = document.getElementById("txtAdd1");
			n1= n.value;n1=n1.trim();			
			if (n1.length <5)
			{
				alert("Required Field (Address) cannot be blank [Min 5 Chars]");
				n.focus();return false;
			}
			
			n = document.getElementById("txtArea");
			n1= n.value;n1=n1.trim();			
			if (n1.length < 5)
			{
				alert("Required Field (Area) cannot be blank [Min 5 Chars]");
				n.focus();return false;
			}  
			
			n = document.getElementById("txtCity");
			n1= n.value;n1=n1.trim();			
			if (n1.length < 3)
			{
				alert("Required Field (City) cannot be blank [Min 5 Chars]");
				n.focus();return false;
			}			
			
			n=document.getElementById("ddlEmirates");n1=n.value;     
			if (n1 == "-1" )
			{
				alert("Required Field (Country) to be selected");
				n.focus();return false;
			}
			
			/*n = document.getElementById("txtDist");
				n1= n.value;
				n1=n1.trim();			
				if (n1.length < 3)
				{
					alert("Please Enter Nationality");
					n.focus();         
					return false;
				} */
			
			n = document.getElementById("txtPOBOX");
			n1= n.value;			
			if (n1.length < 4)
			{
				alert("Required Field (Post Box) cannot be blank [Min 4 Chars]");
				n.focus();return false;
			}
			
			if(isNaN(n1) == true)
			{
				alert("Required Field (Post Box) is valid");
				n.focus();return false;
			}
			
			n = document.getElementById("chkPAddress");	
			
			if(!(n.checked))
			{
				n = document.getElementById("txtPA1");
				n1= n.value;
				n1=n1.trim();			
				if (n1.length < 5)
				{
					alert("Required Field (Permanent: Address) cannot be blank [Min 5 Chars]");
					n.focus();return false;
				}
				
				n = document.getElementById("txtA1");
				n1= n.value;
				n1=n1.trim();			
				if (n1.length < 5)
				{
					alert("Required Field (Permanent: Area Address) cannot be blank [Min 5 Chars]");
					n.focus();return false;
				}
				
				n = document.getElementById("txtCity1");
				n1= n.value;
				n1=n1.trim();			
				if (n1.length <3)
				{
					alert("Required Field (Permanent: City) cannot be blank [Min 3 Chars]");
					n.focus();return false;
				}
				
				
				n=document.getElementById("ddState1");
				n1=n.value;     
				if (n1 == "-1" )
				{
					alert("Required Field (Permanent: Country) to be selected");
					n.focus();return false;
				}
				
				n = document.getElementById("txtPincode1");
				n1= n.value;			
				if (n1.length <5)
				{
					alert("Required Field (Permanent: POBox) cannot be blank [Min 5 Chars]");
					n.focus();return false;
				}
				
				if(isNaN(n1) == true)
				{
					alert("Required Field (Permanent: POBox) is valid");
					n.focus();return false;
				}
			}
			
			n = document.getElementById("txtRPhone");
			n1= n.value;
			n1=n1.trim();			
			if (n1.length > 0)
			{
				if(isNaN(n1) == true)
				{
					alert("Required Field (Resident Phone) is valid");
					n.focus();return false;
				}
			}
			if (n1.length > 0 && n1.length < 5)
			{
				alert("Required Field (Resident Phone) cannot be blank [Min 5 Chars]");
				n.focus();return false;
			}
			
			n = document.getElementById("txtOPhone");
			n1= n.value;
			n1=n1.trim();			
			if (n1.length > 0)
			{
				if(isNaN(n1) == true)
				{
					alert("Required Field (Office Phone) is valid");
					n.focus();return false;
				}
			}
			if (n1.length > 0 && n1.length < 5)
			{
				alert("Required Field (Office Phone) cannot be blank [Min 5 Chars]");
				n.focus();return false;
			}
			
			n = document.getElementById("txtMoblie");
			n1= n.value;
			n1=n1.trim();			
			if (n1.length > 0)
			{
				if(isNaN(n1) == true)
				{
					alert("Required Field (Mobile Phone) is valid");
					n.focus();return false;
				}
			}
			if (n1.length > 0 && n1.length <= 6)
			{
				alert("Required Field (Mobile Phone) cannot be blank [Min 6 Chars]");
				n.focus();return false;
			}
			
			n = document.getElementById("txtEmail");
			n1= n.value;
			n1=n1.trim();			
			if (n1.length <= 0)
			{
				alert("Required Field (EMail) cannot be blank");
				n.focus();return false;
			}
			if (!(ValidateEmail()))
			{
				n.focus();return false;			
			}
			
			n = document.getElementById("txtNominee");
			n1= n.value;
			n1=n1.trim();			
			if (n1.length < 3)
			{
				alert("Required Field (Nominee) cannot be blank [Min 3 Chars]");
				n.focus();return false;
			}
			
			n = document.getElementById("txtRelation");
			n1= n.value;
			n1=n1.trim();			
			if (n1.length < 3)
			{
				alert("Required Field (Relationship) cannot be blank [Min 3 Chars]");
				n.focus();return false;
			}
			
			n=document.getElementById("ddlPackage");
			n1=n.value; 			
			if (n1 == "-1" )
			{
				alert("Required Field (Package) to be selected");
				n.focus();return false;
			}
			
			n=document.getElementById("ddlCurrency");
			n1=n.value;     
			if (n1 == "-1" )
			{
				alert("Required Field (Currency Value) to be selected");
				n.focus();return false;
			}
			n = document.getElementById("txtSponsorName");
			n1= n.value;
			n1=n1.trim();			
			if (n1.length <=1)
			{
				alert("Required Field (Sponsor Name) cannot be blank [Min 3 Chars]");
				n.focus();return false;
			}
			
			n = document.getElementById("txtSponsorTrackId");
			n1= n.value;
			n1=n1.trim();			
			if (n1.length < 5)
			{
				alert("Required Field (Sponsor TrackId) cannot be blank [Min 3 Chars]");
				n.focus();return false;
			}
			
			n = document.getElementById("txtUser");
			n1= n.value;
			n1=n1.trim();			
			if (n1.length < 5)
			{
				alert("Required Field (UserName) cannot be blank [Min 5 Chars])");
				n.focus();return false;
			}
			
			n = document.getElementById("txtUser").value;
			n = n.trim();
			n1 = document.getElementById("txtSponsorName").value;
			n1 = n1.trim();
			
			if (n == n1)
			{				
				alert("Ensure Field (Name) should not matches with Field (User Name)");
				document.getElementById("txtUser").focus();
				return false;
			}
			 			
			n = document.getElementById("txtPassword");
			n1= n.value;
			n1=n1.trim();			
			if (n1.length < 5)
			{
				alert("Required Field (Password) cannot be blank [Min 5 Chars]");
				n.focus();return false;
			}
			
			n = document.getElementById("txtUser").value;
			n = n.trim();
			n1 = document.getElementById("txtPassword").value;
			n1 = n1.trim();
			
			if (n == n1)
			{
				alert("Ensure Field (Password) should not matches with Field (User Name)");
				document.getElementById("txtUser").focus();
				return false;
			}
			
			if (ChkCharacters(n1)==true){alert("Ensure Field (Password) must contain one character");  document.getElementById("txtPassword").focus();	return false;	}
			if (ChkNumbers(n1)==true){alert("Ensure Field (Password) must contain one digit");  document.getElementById("txtPassword").focus();	return false;	}			
			
			n = document.getElementById("txtCPassword");
			n1= n.value;
			n1=n1.trim();			
			if (n1.length <= 0)
			{
				alert("Required Field (Confirm Password) cannot be blank [Min 5 Chars]");
				n.focus();return false;
			}
			
			n = document.getElementById("txtCPassword").value;
			n1= document.getElementById("txtPassword").value;						
			if (n == n1)			
			{
				n="";				
			}
			else
			{
				alert("Ensure Field (Confirm Password) matches with Field (Password)");				
				return false;
			}
			
			n=document.getElementById("ddQuestion").value;			
			if (n == "0")
			{
				alert("Required Field (Hint Question) to be selected");
				return false;
			}			
			if(n=="-1")
			{
				n = document.getElementById("txtQuestion");
				n1= n.value;n1=n1.trim();			
				if (n1.length < 5)
				{
					alert("Required Field (Hint Question) cannot be blank [Min 5 Chars]");
					n.focus();return false;
				}
			}
			
			n = document.getElementById("txtAnswer");
			n1= n.value;n1=n1.trim();			
			if (n1.length < 3)
			{
				alert("Required Field (Answer) cannot be blank [Min 3 Chars]");
				n.focus();return false;
			}
			
			n = document.getElementById("rbPayment");	
			if(n.checked)
			{
			
			    n=document.getElementById("txtBank");
				n1=n.value;     
				if (n1.length < 3 )
				{
					alert("Required Field (Bank) cannot be blank [Min 3 Chars]");
					n.focus();return false;
				}
				n=document.getElementById("txtBranch");
				n1=n.value;     
				if (n1.length < 3 )
				{
					alert("Required Field (Branch) cannot be blank [Min 3 Chars]");
					n.focus();return false;
				}
				n=document.getElementById("txtDDNo");
				n1=n.value;     
				if (n1.length < 5 )
				{
					alert("Required Field (DD Number) cannot be blank [Min 5 Chars]");
					n.focus();return false;
				}
				n=document.getElementById("dddMonth");
				n1=n.value;     
				if (n1 == "-1" )
				{
					alert("Required Field (DD Month) to be selected");
					n.focus();return false;
				}
				
				n=document.getElementById("dddDate");
				n1=n.value;     
				if (n1 == "-1" )
				{
					alert("Required Field (DD Date) to be selected");
					n.focus();return false;
				}				
				
				n=document.getElementById("dddYear");
				n1=n.value;     
				if (n1 == "-1" )
				{
					alert("Required Field (DD Year) to be selected");
					n.focus();return false;
				}
			}
			
			return confirm("Do you want to Register this entry?");
		}
		function chek()
		{
			var n,n1;
			n = document.getElementById("rbPayment");				
			if(n.checked)
			{	
				document.getElementById("txtBank").disabled = false;
				document.getElementById("txtDDNo").disabled = false;
				document.getElementById("dddDate").disabled = false;
				document.getElementById("dddMonth").disabled = false;
				document.getElementById("dddYear").disabled = false;
			}
			n = document.getElementById("rbCreditcard");			
			if(n.checked)
			{	
				document.getElementById("txtBank").value = "";
				document.getElementById("txtBank").disabled = true;
				document.getElementById("txtDDNo").value = "";
				document.getElementById("txtDDNo").disabled = true;
				document.getElementById("dddDate").value= "-1";
				document.getElementById("dddDate").disabled = true;
				document.getElementById("dddMonth").value = "-1";
				document.getElementById("dddMonth").disabled = true;
				document.getElementById("dddYear").value = "-1";				
				document.getElementById("dddYear").disabled = true;
			}
			n = document.getElementById("rbCash");			
			if(n.checked)
			{	
				document.getElementById("txtBank").value = "";
				document.getElementById("txtBank").disabled = true;
				document.getElementById("txtDDNo").value = "";
				document.getElementById("txtDDNo").disabled = true;
				document.getElementById("dddDate").value= "-1";
				document.getElementById("dddDate").disabled = true;
				document.getElementById("dddMonth").value = "-1";
				document.getElementById("dddMonth").disabled = true;
				document.getElementById("dddYear").value = "-1";				
				document.getElementById("dddYear").disabled = true;
			}
			return true;
		}
		function questionchk()
		{  
			var n;
			n=document.getElementById("ddQuestion").value;
			if(n=="-1")
			{
				document.getElementById("txtQuestion").disabled = false;
			}
			else
			{
				document.getElementById("txtQuestion").disabled = true;
				document.getElementById("txtQuestion").value="";
			}
				
		}
		function onFocus()
		{
			document.getElementById("txtName").focus();
			var h = document.getElementById("HID1").value;
			if (h.length > 4) 
			{   				
				openWL();                                 
				document.getElementById("HID1").value="";
			}
			
		}
		
		
		// EPIN
		
		function emailcheck(eid) {

			var at="@";var dot=".";var lat=eid.indexOf(at);
			var lstr=eid.length;var ldot=eid.indexOf(dot);
			
			if (eid.indexOf(at)==-1){alert("Ensure Field (Email) is Valid");return false;}

			if (eid.indexOf(at)==-1 || eid.indexOf(at)==0 || eid.indexOf(at)==lstr){alert("Ensure Field (Email) is Valid");return false;}

			if (eid.indexOf(dot)==-1 || eid.indexOf(dot)==0 || eid.indexOf(dot)==lstr){alert("Ensure Field (Email) is Valid");return false;}

			if (eid.indexOf(at,(lat+1))!=-1){alert("Ensure Field (Email) is Valid");return false;}

			if (eid.substring(lat-1,lat)==dot || eid.substring(lat+1,lat+2)==dot){alert("Ensure Field (Email) is Valid");return false;}

			if (eid.indexOf(dot,(lat+2))==-1){alert("Ensure Field (Email) is Valid");return false;}
			
			if (eid.indexOf(" ")!=-1){alert("Ensure Field (Email) is Valid");return false;}

 			return true					
		}

	function ValidateEmail(){
		var emailID=document.getElementById("txtEmail");
		
		if ((emailID.value==null)||(emailID.value=="")){alert("Required Field (EMail) cannot be blank");emailID.focus();return false;}
		
		if (emailcheck(emailID.value)==false){emailID.focus();return false;}
		
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;var address = emailID.value;
		if(reg.test(address) == false) {alert('Ensure Field (Email) is Valid');	return false;}
		return true
	}
	
	function EmailExist(msg)
	{
		var s = confirm(msg);
		if(!s){ document.getElementById("btno").click(); }
		else{document.getElementById("chkPAddress").checked=false; Toggle("div1"); document.getElementById("btok").click(); }
	}	
	
	///PASSWORD VALIDATION 
	function ChkCharacters(pass)
	{	
    	reg = new Array();	reg = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
		x = new Array(); x = reg.split('');		
				
		for(var i = 0; i < parseFloat(reg.length); i++)
		{
			if (pass.indexOf(x[i]) >= 0){return false;}
		}
		return true;
	}
		
	function ChkNumbers(pass)
	{	
		reg = new Array();
		reg = '0123456789';
		x = new Array(); 
		x = reg.split('');			
		for(var i = 0; i < parseFloat(reg.length); i++) 
		{     	
			if (pass.indexOf(x[i]) >= 0) { return false; } 
		}
		return true;
	}