function emailCheck (email) {
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=email.match(emailPat);
if (matchArray==null) {
	alert('Invalid email id.');
	return false;
}
var user=matchArray[1];
var domain=matchArray[2];
if (user.match(userPat)==null) {
	alert('Invalid email id.');
    return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	       alert('Invalid email id.');
		return false;
	    }
    }
    return true;
}
var domainArray=domain.match(domainPat);
if (domainArray==null) {
	alert('Invalid email id.');
    return false;
}
var atomPat=new RegExp(atom,"g");
var domArr=domain.match(atomPat);
var len=domArr.length;
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
    alert('Invalid email id.');
   return false;
}
if (len<2) {
   var errStr="This address is missing a hostname!";
   alert('Invalid email id.');
   return false;
}
return true;
}


function ValidateLogin()
{
if(document.getElementById('f_name').value=='')
   {
   alert('Please Write Your First Name.');
   document.getElementById('f_name').focus();
   return false;
   }
if(document.getElementById('l_name').value=='')
   {
   alert('Please Write Your Last Name.');
   document.getElementById('l_name').focus();
   return false;
   }
if(document.getElementById('password').value=='')
   {
   alert('Please Type Password.');
   document.getElementById('password').focus();
   return false;
   }
if(document.getElementById('password').value=='')
   {
   alert('Please Type Password.');
   document.getElementById('password').focus();
   return false;
   }
if(document.getElementById('c_password').value=='')
   {
   alert('Please Type Confirm Password.');
   document.getElementById('c_password').focus();
   return false;
   }
if(document.getElementById('password').value!=document.getElementById('c_password').value)
   {
   alert('Password And Confirm Password Does Not Match.');
   document.getElementById('c_password').focus();
   return false;
   }  
if(document.getElementById('email').value=='')
   {
   alert('Please Write Your Email Id.');
   document.getElementById('email').focus();
   return false;
   }   
if(!emailCheck(document.getElementById('email').value))
	{
	 alert('Invalid Email Id.');	
	 document.getElementById('email').focus();
	 return false;
	}	   

if(document.getElementById('country').value=='select')
   {
   alert('Please Select Country Name.');
   document.getElementById('country').focus();
   return false;
   } 
if(document.getElementById('gender').value=='select_gender')
   {
   alert('Please Select Your Gender.');
   document.getElementById('gender').focus();
   return false;
   }    
if(document.getElementById('varification').value=='')
   {
   alert('Please Write Text In Given Field.');
   document.getElementById('varification').focus();
   return false;
   }     
return true;
}

function ValidateUserLogin()
 {
 if(document.getElementById('email_ids').value=='')
   {
   alert('Please Enter Your Email Id');
   document.getElementById('email_ids').focus();
   return false;
   }
   if(!emailCheck(document.getElementById('email_ids').value))
	{
	 alert('Invalid Email Id.');	
	 document.getElementById('email_ids').focus();
	 return false;
	}	   

   if(document.getElementById('passwords').value=='')
   {
   alert('Please Type Your Password');
   document.getElementById('passwords').focus();
   return false;
   }
  return true; 
 }
 
function ValidatePasswordUpdate()
 {
if(document.getElementById('o_password').value=='')
   {
   alert('Please Type Old Password.');
   document.getElementById('o_password').focus();
   return false;
   }
  if(document.getElementById('n_password').value=='')
   {
   alert('Please Type New Password.');
   document.getElementById('n_password').focus();
   return false;
   }
  if(document.getElementById('c_password').value=='')
   {
   alert('Please Type Confirm Password.');
   document.getElementById('c_password').focus();
   return false;
   } 
 if(document.getElementById('n_password').value!=document.getElementById('c_password').value)
   {
   alert('New Password And Confirm Password Does Not Match.');
   document.getElementById('c_password').focus();
   return false;
   }  
  return true; 
 }
 
function ValidateEmail()
 {
	if(!emailCheck(document.getElementById('emails').value))
	{
	 alert('Invalid Email Id.');	
	 document.getElementById('emails').focus();
	 return false;
	}	   
 }
 

function validate(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   return reg.test(email);
}

function trim(str){
	var	str = str.replace(/^\s\s*/,''),
		ws = /\s/,
		i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
}

function checkAll(){
 if(document.getElementById('emails').value=='')	
   {
	alert('Please Write Email Id(s) To Invite Must be Comma(,) Seprated.') ;
	document.getElementById('emails').focus();
	return false;
   }
	var status = true;
	var i = 0;
	var emails = document.form1.emails.value.split(",");
	last_time = emails[emails.length-1];
	for(i=0; i<emails.length; i++){
		if(!validate(trim(emails[i]))){			
			alert("Incorrect format: "+emails[i]);
			document.getElementById('emails').focus();
			return false;
			break;
		}
		if(last_time=='')
		   {
			alert(' You are using "," in end , plz remove that to send email successfully.');
			document.getElementById('emails').focus();
			return false;
		   }
	}
	if(status){
		return true;
	}
}

function ValidateContactUs()
 {
  if(document.getElementById('f_name').value=='')	 
    {
	alert('Please Write Your First Name.');
	document.getElementById('f_name').focus();
	return false;
	}
  if(document.getElementById('l_name').value=='')	 
    {
	alert('Please Write Your Last Name.');
	document.getElementById('l_name').focus();
	return false;
	}	
  if(document.getElementById('email_id').value=='')	 
    {
	alert('Please Write Your Email Id.');
	document.getElementById('email_id').focus();
	return false;
	}
  if(document.getElementById('email_id').value!='')	 
    {
		if(!emailCheck(document.getElementById('email_id').value))
		{
		 alert('Invalid Email Id.');	
		 document.getElementById('email_id').focus();
		 return false;
		}
	}
  if(document.getElementById('message').value=='')	 
    {
	alert('Please Write Your Message.');
	document.getElementById('message').focus();
	return false;
	}	
return true;	
 }
 
 function ValidateShipping()
 {
  if(document.getElementById('first_name').value=='')	 
    {
	alert('Please Write Your First Name.');
	document.getElementById('first_name').focus();
	return false;
	}
  if(document.getElementById('last_name').value=='')	 
    {
	alert('Please Write Your Last Name.');
	document.getElementById('last_name').focus();
	return false;
	}	
  if(document.getElementById('address').value=='')	 
    {
	alert('Please Write Your Address.');
	document.getElementById('address').focus();
	return false;
	}
  if(document.getElementById('city').value=='')	 
    {
	alert('Please Write Your City Name.');
	document.getElementById('city').focus();
	return false;
	}
if(document.getElementById('state').value=='')	 
    {
	alert('Please Write Your State Name.');
	document.getElementById('state').focus();
	return false;
	}
  if(document.getElementById('zip').value=='' || isNaN(document.getElementById('zip').value))	 
    {
	alert('Please Write Your Zip Code In Numeric.');
	document.getElementById('zip').focus();
	return false;
	}	
  if(document.getElementById('country').value=='select_country')	 
    {
	alert('Please Select Country Name.');
	document.getElementById('country').focus();
	return false;
	}
  if(document.getElementById('phone').value=='' || isNaN(document.getElementById('phone').value))	 
    {
	alert('Please Write Your Contact No In Numeric.');
	document.getElementById('phone').focus();
	return false;
	}	
	
return true;	
 }
 
 function ValidateBilling()
 {
  if(document.getElementById('name').value=='')	 
    {
	alert('Please Write Your Name As On Your Credit Card.');
	document.getElementById('name').focus();
	return false;
	}
  if(document.getElementById('billing_address').value=='')	 
    {
	alert('Please Write Your Address.');
	document.getElementById('billing_address').focus();
	return false;
	}
  if(document.getElementById('billing_city').value=='')	 
    {
	alert('Please Write Your City Name.');
	document.getElementById('billing_city').focus();
	return false;
	}
 if(document.getElementById('billing_country').value=='country_select')	 
    {
	alert('Please Select Country Name.');
	document.getElementById('billing_country').focus();
	return false;
	}
  if(document.getElementById('billing_zip').value=='' || isNaN(document.getElementById('billing_zip').value))	 
    {
	alert('Please Write Your Zip Code In Numeric.');
	document.getElementById('billing_zip').focus();
	return false;
	}	
 
  if(document.getElementById('billing_phone').value=='' || isNaN(document.getElementById('billing_phone').value))	 
    {
	alert('Please Write Your Contact No In Numeric.');
	document.getElementById('billing_phone').focus();
	return false;
	}	
	
return true;	
 }
 
 function ShowHide(div_id)
  {
	  if(document.getElementById(div_id).style.display=='none')
	     document.getElementById(div_id).style.display='block';
	  else
	    document.getElementById(div_id).style.display = 'none';
  }
  
 function ValidateGoldMemeber()
   {
	if(document.getElementById('creditCard').value=='' || isNaN(document.getElementById('creditCard').value))   
	   {
		alert('Please Write Your Credit Card No. In Numeric.');   
		document.getElementById('creditCard').focus();
		return false;
		}
	if(document.getElementById('cvv2Number').value=='' || isNaN(document.getElementById('cvv2Number').value))   
	   {
		alert('Please Write Your Credit Card Varification No. In Numeric.');   
		document.getElementById('cvv2Number').focus();
		return false;
		}
	return true;   
   }
  
  
function ValidateForgetPassword()
    {
	if(document.getElementById('forget_email').value=='')
	  {
		alert('Please Write Your Email Id.');  
		document.getElementById('forget_email').focus();
		return false;
	 }
	if(document.getElementById('forget_email').value!='')	 
    {
		if(!emailCheck(document.getElementById('forget_email').value))
		{
		 alert('Invalid Email Id.');	
		 document.getElementById('forget_email').focus();
		 return false;
		}
	} 
	return true;   
	}