  function validEmail(email)
    {
                invalidChars = " /:,;";
                if (email == "") {
                        return true;
                }
                for (i=0; i<invalidChars.length; i++) {
                        badChar = invalidChars.charAt(i);
                        if (email.indexOf(badChar,0) != -1) {
                                return false;
                        }
                }
                atPos = email.indexOf("@",1);
                if (atPos == -1) {
                        return false;
                }
                if (email.indexOf("@",atPos+1) != -1) {
                        return false;
                }
                periodPos = email.indexOf(".",atPos);
                if (periodPos == -1) {
                        return false;
                }
                if (periodPos+3 > email.length)        {
                        return false;
                }
                return true;
        }



function validate()
{

        if(document.form1.email.value<=0)
        {
                alert('First fill your email id!');
                document.form1.email.focus();
                return false;
        }      
          if(!validEmail(document.form1.email.value))
        {
                alert('E-Mail address1 is invalid');
                document.form1.email.focus();
                return false;
        }      
         
        
         if(document.form1.password.value <=0)
         {
                 alert('Password cannot be left blank!');
                 document.form1.password.focus();
                 return false;
         }
         if(document.form1.rpassword.value <=0)
         {
                 alert('First confirm your Password !');
                 document.form1.rpassword.focus();
                 return false;
         }
           if(document.form1.password.value != document.form1.rpassword.value )
         {
                 alert('Confirm Password must be same as password!');
                 document.form1.password.focus();
                 return false;
         }
           if(document.form1.fname.value <=0)
         {
                 alert('Full name cannot be left blank!');
                 document.form1.fname.focus();
                 return false;
         }
        
         if(document.form1.address.value <= 0)
		 {
			 alert('Please give your correct address');
			 document.form1.address.focus();
			 return false;
		 }
         if(document.form1.city.value <=0)
         {
                 alert('city cannot be left blank!');
                 document.form1.city.focus();
                 return false;
         }
         if(document.form1.state.value <=0)
         {
                 alert('State cannot be left blank!');
                 document.form1.state.focus();
                 return false;
         }
          if(document.form1.zipcode.value <=0)
         {
                 alert('Please Fill Your City Zipcode First!');
                 document.form1.zipcode.focus();
                 return false;
         }
              
		 if(document.form1.phone_no.value <=0)
		 {
				alert('Please give your Phone Number.');
				document.form1.phone_no.focus();
				return false;
		 }
         var selectbox=document.form1.country;
         if(selectbox.options[selectbox.selectedIndex].value <='0')
         {
          alert('Select country from list!');
          return false;
          }
         var selectbox=document.form1.age_group;
         if(selectbox.options[selectbox.selectedIndex].value <='0')
         {
          alert('Select age group from list!');
          return false;
          }
         var selectBox = document.form1.gender;
        if(selectBox.options[selectBox.selectedIndex].value <='0')
         {
			 alert('Select Gender!');
			 return false;
         }
         var selectBox = document.form1.user_type;
        if(selectBox.options[selectBox.selectedIndex].value <='0')
         {
			 alert('Select Your type first!');
			 return false;
         }
        if(document.form1.conditions.checked!=true)
         {
			  alert('First make sure that you have read all  terms \n and conditions and then click on checkbox!'); 
			  return false;
         }     
		if(document.form1.wherehear.value == 0)
		{
			   alert('Please let us know where you heard about us');
			   document.form1.wherehear.focus();
			   return false;
		}
 return true;
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
 if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
 }
  function showLayer(layera,field)
	{
		layera.style.top = event.clientY - 115;
		layera.style.left = event.clientX - 240/2;
		//alert(field.clientLeft);
	//	layera.style.left = field.clientLeft;
		layera.style.visibility = "visible";
	}
	
	function hideLayer(layera)
	{
		layera.style.visibility = "hidden";
	}
	
	MM_reloadPage(true);





//-----------------------------mask-------------------------------


//browser detection
                        var strUserAgent = navigator.userAgent.toLowerCase();
                        var isIE = strUserAgent.indexOf("msie") > -1;
                        var isNS6 = strUserAgent.indexOf("netscape6") > -1;
                        var isNS4 = !isIE && !isNS6  && parseFloat(navigator.appVersion) < 5;

                        //regular expressions
                        var reValidChars = /\d/;
                        var reKeyboardChars = /[\x08\x0D]/;

                        //mask function
                        function maskKeyPress(objEvent) {
                                var iKeyCode, strKey;

                                if (isIE) {
                                    iKeyCode = objEvent.keyCode;
                                } else {
                                    iKeyCode = objEvent.which;
                                }

                                strKey = String.fromCharCode(iKeyCode);

                                if (!reValidChars.test(strKey) && !reKeyboardChars.test(strKey)) {
                                      // alert("Invalid Character Detected!\nKeyCode = " + iKeyCode + "\nCharacter =" + strKey);
                                        return false;
                                }
                       
                         }

//------------------------------------------mask---------------------------------------------



