// JavaScript Document

function Validate_reg(form)
{
    
   if(form.txtname.value=="")
   {
       alert("Your Name must be filled out!")
       form.txtname.focus();
       return false;
   }
   
   if(form.txtemail.value=="")
   {
       alert("Your Email must be filled out!")
       form.txtemail.focus();
       return false;
   } 
   if(form.txtemail.value!="")
   {
        if(echeck(form.txtemail.value)==false)
        {       
            form.txtemail.focus();
            return false;
        }        
   }
   if(form.txtConfirmEmail=="")
   {
       
       alert("your confirmemail must be filled out!")
       form.txtConfirmEmail.focus();
       return false;
    } 
   
   if(form.txtemail.value!=form.txtConfirmEmail.value)
   {
       alert("confirm email should match with email")
       form.txtConfirmEmail.focus();
       return false;
   }
   
   if(form.txtPassword.value=="")
   {
   alert("Your Password must be filled out!")
   form.txtPassword.focus();
   return false;
   } 
         if(form.txtcpassword.value=="")
   {
   alert("Your Confirm Password must be filled out!")
   form.txtcpassword.focus();
   return false;
   } 

   if(form.txtPassword.value!=form.txtcpassword.value)
   {
   alert("Confirm Password should match with Password")
   form.txtcpassword.focus();
   return false;
   }
   /// ----- asdjkflasdjfkljasdlf
   
   if(form.txtCompany.value=="")
   {
   alert("Your Company must be filled out!")
   form.txtCompany.focus();
   return false;
   } 
    if(form.txtDescription.value=="")
   {
   alert("Your Description must be filled out!")
   form.txtDescription.focus();
   return false;
   } 
     if(form.txtAddress.value=="")
   {
   alert("Your Address must be filled out!")
   form.txtAddress.focus();
   return false;
   } 
      if(form.txtCity.value=="")
   {
   alert("Your City must be filled out!")
   form.txtCity.focus();
   return false;
   } 
   
        if(form.TxtState.value=="")
   {
   alert("Your State must be filled out!")
   form.TxtState.focus();
   return false;
   }      
    

		if(form.TxtPinCode.value=="")
		{
    alert("Pincode should not be null")
     form.TxtPinCode.focus();
     return false;	
      }		
if(form.TxtPinCode.value!="")
    {
            var iChars ="0123456789 ";
					var string=form.TxtPinCode.value;
					var zip=0;					
					if (string.length!=0)
					{
					    for( i =0; i< string.length; i++)
					    {
					    //alert(iChars.indexOf(string.charAt(i)))
					      if (iChars.indexOf(string.charAt(i))== -1)
					        zip =1;
					    }					    
					}
					else if(isNaN(form.TxtPinCode.value)==false)
					{
					       zip=1;
					}
					if (zip==1)
					{
					    alert("Pincode can have only "+iChars+" Numbers")					    
					    form.TxtPinCode.focus();
					    return false;
					}
    }
    
   
    if(form.txtPhone.value=="")
               {
                       alert("Your Phone Number must be filled out!")
                       form.txtPhone.focus();
                       return false;
               } 
//     if(form.txtPhone.value!="")
//      {
//              if(ValidateForm(form.txtPhone.value)==false)
//              {
//              form.txtPhone.focus();
//              return false;
//              }
//      }
 
   if(form.txtFax.value=="")
		{
			    alert("Fax should not be null")
			    form.txtFax.focus();
                return false;	
           
         }  
    		
    if(form.txtFax.value!="") 
    {
             var iChars ="0123456789 ";
					var string=form.txtFax.value;
					var zip=0;					
					if (string.length!=0)
					{
					    for( i =0; i< string.length; i++)
					    {
					    //alert(iChars.indexOf(string.charAt(i)))
					      if (iChars.indexOf(string.charAt(i))== -1)
					        zip =1;
					    }					    
					}
					else if(isNaN(form.txtFax.value)==false)
					{
					       zip=1;
					}
					if (zip==1)
					{
					    alert("Pincode can have only "+iChars+" Numbers")					    
					    form.txtFax.focus();
					    return false;
					}
    }
    
   
//    if(form.txtwebsite.value=="")
//   {
//   alert("Your Website must be filled out!")
//   form.txtwebsite.focus();
//   return false;
//   }
//   else
//   {
//        website =/^([w]{3}\.[a-zA-Z\d]+\.[a-z]{3})$/
//			    if (!website.test(form.txtwebsite.value))
//			    {
//			        alert("Please enter correct Website (eg: www.mysoretrendz.com)")
//                    form.txtwebsite.focus();
//				    return false;  			    
//			    }
//   }

//alert("hello");
  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("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1)
		 {
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		 {
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1)
		 {
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1)
		 {
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}



///**
// * DHTML phone number validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
// */

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;
  
function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone)
{
    s=stripCharsInBag(strPhone,validWorldPhoneChars);
    return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
function ValidateForm(Phone)
{
	//var Phone=document.frmSample.txtPhone
	
	if (Phone==null || Phone=="")
	{
		alert("Please Enter your Phone Number")
		return false;
	}
//	if (checkInternationalPhone(Phone)==false)
//	{
//		alert("Please Enter a Valid Phone Number ,\n Your phone number should have minimum 10 digits")
//		return false;
//	}
//	return true;
 }
 
 function Validate_changepwd(form)
{
if(form.textbox1.value=="")
{
alert("please enter Current Password")
form.textbox1.focus();
return false;
}
if(form.textbox2.value=="")
{
alert("please enter New password")
form.textbox2.focus();
return false;
}
if(form.textbox3.value=="")
{
alert("please enter Confirm Password")
form.textbox3.focus();
return false;
}
if(form.textbox2.value!=form.textbox3.value)
{
alert("confirm password should match with new password")
form.textbox3.focus();
return false;
}
}
function Validate_pur0(form)
{
  if(form.txtname1.value=="")
   {
   alert("Your Name must be filled out!")
   form.txtname1.focus();
   return false;
   }
       if(form.txtemail1.value=="")
   {
   alert("Your Email must be filled out!")
   form.txtemail1.focus();
   return false;
   } 
   if(form.txtemail1.value!="")
   {
    if(echeck(form.txtemail1.value)==false)
    {
   
    form.txtemail1.focus();
    return false;
    }
   }
    if(form.confirme.value=="")
   {
   alert("Your Confirm Email must be filled out!")
   form.confirme.focus();
   return false;
   } 
  
   if(form.txtemail1.value!=form.confirme.value)
   {
   alert("Your Confirm Email should match with Email")
   form.confirme.focus();
   return false;
   }
        if(form.txtpwd.value=="")
   {
   alert("Your Password must be filled out!")
   form.txtpwd.focus();
   return false;
   }
   
        if(form.confirmp.value=="")
   {
   alert("Your ConfirmPassword must be filled out!")
   form.confirmp.focus();
   return false;
   } 
    if(form.txtpwd.value!=form.confirmp.value)
   {
   alert("Your Confirm Password should match with ")
   form.confirmp.focus();
   return false;
   }
   
  if(form.txtphone1.value=="")
   {
   alert("Your Phone Number must be filled out!")
   form.txtphone1.focus();
   return false;
   } 
//     if(form.txtphone1.value!="")
//  {
//      if(ValidateForm(form.txtphone1.value)==false)
//      {
//      form.txtphone1.focus();
//      return false;
//      }
//  }
      if(form.txtaddress1.value=="")
   {
   alert("Your Address must be filled out!")
   form.txtaddress1.focus();
   return false;
   } 
      if(form.DropDownList2.value=="")
   {
   alert("Your Location must be filled out!")
   form.DropDownList2.focus();
   return false;
   } 
      if(form.txtQualification.value=="")
   {
   alert("Your Qualifications must be filled out!")
   form.txtQualification.focus();
   return false;
   } 
        if(form.txtexp.value=="")
   {
   alert("Your Experiance must be filled out!")
   form.txtexp.focus();
   return false;
   } 
   
      if(form.txtks.value=="")
   {
   alert("Your Keyskills must be filled out!")
   form.txtks.focus();
   return false;
   } 
       if(form.txtdob.value=="")
   {
   alert("Your D.O.B must be filled out!")
   form.txtdob.focus();
   return false;
   }  
   
   
     if(form.txtresume.value=="")
      {
      alert("Please send your resume")
      form.txtresume.focus();
      return false;
      } 
   }
   function Validate_signin(form)
   {
   if(form.txtemail.value=="")
   {
   alert("Your Email must be filled out!")
   form.txtemail.focus();
   return false;
   }
   if(form.txtemail.value!="")
   {
        if(echeck(form.txtemail.value)==false)
        {       
            form.txtemail.focus();
            return false;
        }        
   }
   if(form.txtpassword.value=="")
   {
   alert("Your Password must be filled out!")
   form.txtpassword.focus();
   return false;
   }
   }
   
   
//   
//   
//   //zipcode
//	
//		
//		

////   --------------------------------------------------------------------------------------------------------------
//   function echeck1(str)
// {

//		var at="WWW"
//		var dot="."
//		var dot1="."
//		var lat=str.indexOf(at)
//		var lstr=str.length
//		var ldot=str.indexOf(dot)
//		var 1dot1=str.indexOf(dot1)
//		if (str.indexOf(at)==-1)
//		{
//		   alert("Invalid Website")
//		   return false
//		}

//		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
//		{
//		   alert("Invalid Website")
//		   return false
//		}

//		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
//		{
//		    alert("Invalid Website")
//		    return false
//		}
//			if (str.indexOf(dot1)==-1 || str.indexOf(dot1)==0 || str.indexOf(dot1)==lstr)
//		{
//		    alert("Invalid Website")
//		    return false
//		}

//		 if (str.indexOf(at,(lat+1))!=-1)
//		 {
//		    alert("Invalid Website")
//		    return false
//		 }

//		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
//		 {
//		    alert("Invalid Website")
//		    return false
//		 }
// if (str.substring(lat-1,lat)==dot1 || str.substring(lat+1,lat+2)==dot1)
//		 {
//		    alert("Invalid Website")
//		    return false
//		 }

//		 if (str.indexOf(dot,(lat+2))==-1)
//		 {
//		    alert("Invalid Website")
//		    return false
//		 }
//		  if (str.indexOf(dot1,(lat+2))==-1)
//		 {
//		    alert("Invalid Website")
//		    return false
//		 }
//		
//		 if (str.indexOf(" ")!=-1)
//		 {
//		    alert("Invalid Website")
//		    return false
//		 }

// 		 return true					
//	}

