// JavaScript Document
function sigup()
{
if(document.getElementById('sup_firstname').value=="")
{
 alert("enter your first name");
 document.getElementById('sup_firstname').focus();
 return false;
}
if(document.getElementById('sup_lastname').value=="")
{
 alert("enter your last name");
 document.getElementById('sup_lastname').focus();
 return false;
}
if(document.getElementById('sup_compname').value=="")
{
 alert("enter your company name");
 document.getElementById('sup_compname').focus();
 return false;
}
if(document.getElementById('sup_addr1').value=="")
{
 alert("enter your address");
 document.getElementById('sup_addr1').focus();
 return false;
}
if(document.getElementById('sup_city').value=="")
{
 alert("enter your city");
 document.getElementById('sup_city').focus();
 return false;
}
if(document.getElementById('sup_state').value=="")
{
 alert("enter your state");
 document.getElementById('sup_state').focus();
 return false;
}
if(document.getElementById('Country').value=="")
{
 alert("enter your country");
 document.getElementById('Country').focus();
 return false;
}
if(document.getElementById('sup_phno').value=="")
{
 alert("enter your phone no");
 document.getElementById('sup_phno').focus();
 return false;
}
if(document.getElementById('sup_email').value=="")
{
 alert("enter your email address");
 document.getElementById('sup_email').focus();
 return false;
}

if(document.getElementById('sup_password').value=="")
{
 alert("enter your password");
 document.getElementById('sup_password').focus();
 return false;
}
if(document.getElementById('confirm').value=="")
{
 alert("enter your confirm password");
 document.getElementById('confirm').focus();
 return false;
}
var a=document.getElementById('sup_password').value;
//alert(a);
if(a.length<6)
{
alert("password length must be more than or equal to 6");
	document.getElementById('sup_password').focus();
	return false;
}
var b=document.getElementById('confirm').value;
//alert(b);
if((document.getElementById('sup_password').value) != (document.getElementById('confirm').value) )
//if(a.value!=b.value)
{
	alert("enter same value for both password and confirm password");
	document.getElementById('sup_password').focus();
	return false;
}
//Please select any one category groupings
if(document.getElementById('msgbox').value=="Username available to register")
{
	alert('user Already exists');
	document.getElementById('sup_email').focus();
	return false;
	
}
}
function validate() {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.getElementById('sup_email').value;
   if(reg.test(address) == false) {
      alert('Invalid Email Address');
	  document.getElementById('sup_email').focus();
      return false;
   }
}

function validate_signUp(obj){


	if(Trim(obj.sup_firstname.value)==''){
		alert("Please enter first Name");
		obj.sup_firstname.focus();
		return false;
	}
	if(!checkForm(obj.sup_firstname.value)){		
		obj.sup_firstname.focus();
		return false;
	}
	if(Trim(obj.sup_lastname.value)==''){
		alert("Please enter last Name");
		obj.sup_lastname.focus();
		return false;
	}
	if(!checkForm(obj.sup_lastname.value)){		
		obj.sup_lastname.focus();
		return false;
	}
	if(Trim(obj.sup_compname.value)==''){
		alert("Please enter company Name");
		obj.sup_compname.focus();
		return false;
	}
	if(!checkForm(obj.sup_compname.value)){		
		obj.sup_compname.focus();
		return false;
	}
	if(Trim(obj.sup_addr1.value)==''){
		alert("Please enter address Name");
		obj.sup_addr1.focus();
		return false;
	}
	if(Trim(obj.sup_city.value)==''){
		alert("Please enter city Name");
		obj.sup_city.focus();
		return false;
	}
	if(!checkForm(obj.sup_city.value)){		
		obj.sup_city.focus();
		return false;
	}/*else if(obj.sup_state.selectedIndex==0 || obj.sup_state.selectedIndex==''){
		alert("Please select your state");
		obj.sup_state.focus();
		return false;
	}*/
	if(obj.Country.selectedIndex==0 || obj.Country.selectedIndex==""){
		alert("Please select your country");
		obj.Country.focus();
		return false;
	}
	if(Trim(obj.sup_zip.value)==''){
		alert("Please enter your Postal/Zip code");
		obj.sup_zip.focus();
		return false;
	}
	if(!isNaN(obj.sup_zip.value)){
	    var len=Trim(obj.sup_zip.value).length;	
	    if(len != '5')
	    {
		alert("Please enter valid Postal/Zip code");
		obj.sup_zip.focus();
		return false;
		}
	}
	if(isNaN(obj.sup_zip.value)){
		var match = /[^a-zA-Z0-9 ]/.test(obj.sup_zip.value);
		//var match = /[^a-zA-Z ]/.test(obj.sup_zip.value);
	    //alert(match);
	    if(match)
	    {	 		   
		 alert('Please enter valid Postal/Zip code.');
		 obj.sup_zip.focus();
		 return false;
	    }	   
	}
	if(isNaN(obj.sup_zip.value)){
	    var len=Trim(obj.sup_zip.value).length;	
	    if(len != '7')
	    {
		alert("Please enter valid Postal/Zip code");
		obj.sup_zip.focus();
		return false;
		}
	}
	if(isNaN(obj.sup_zip.value)){
	    var ln=Trim(obj.sup_zip.value);	   
        var pos=ln.indexOf(" ");	   
		   if(pos!='3')
		   {		   
		   alert('Please enter valid Postal/Zip code');
		   obj.sup_zip.focus();
		   return false;
		   }	    
	}
	if(Trim(obj.sup_phno.value)==''){
		alert("Please enter your Phone No");
		obj.sup_phno.focus();
		return false;
	}
	if(!numberCheck(obj.sup_phno.value)){
		obj.sup_phno.focus();
		return false;
	}
	if(Trim(obj.sup_email.value)==''){
		alert("Please enter your email address");
		obj.sup_email.focus();
		return false;
	}
	if(!validateEmail(obj.sup_email.value)){
		obj.sup_email.focus();
		return false;
	}
	if(Trim(obj.sup_password.value)==''){
		alert("Please enter your password");
		obj.sup_password.focus();
		return false;
	}
	if(Trim(obj.password_confirm.value)==''){
		alert("Please enter confirm password");
		obj.password_confirm.focus();
		return false;
	}
	if(Trim(obj.sup_password.value)!=Trim(obj.password_confirm.value)){
		alert("confirmation password doesn't match with original password");
		obj.sup_password.focus();
		return false;
	}
	
}

/*************category selection  *************/
function category_selection(){

	var cate_gory=document.getElementsByName('cat[]');
	var cate_goryChecked=false;	
	for(i=0;i<cate_gory.length;i++){
		if(cate_gory[i].checked==true){
			cate_goryChecked=true;
		}		
	}	
	if(cate_goryChecked==false){		
		cate_goryChecked=false;	
		return false;		
	}

}
/***********end*************/


/*****************************Lead Validation  ************************************/

function validate_lead(){
	
	var confirmation=confirm("Dear customer! make sure to fill required fields.");
	if(confirmation){
		window.location="";
	}else{
	}
	
	return false;
}


/*************************Redirection page**********************************/

function redirect_page(duration){
	setTimeout("go_to()",duration);	
}
function go_to(){
	window.location="index.php";
}

/*************************signup second  page**********************************/
function validateform(obj)
{
	var category=document.getElementsByName('subcat[]');
	var country=document.getElementsByName('txtcountry[]');	
	var len = document.category_insert["txtcountry[]"].length
	
	var categoryChecked=false;
	var countryChecked=false;
	
	for(i=0;i<category.length;i++){
		if(category[i].checked==true){
			categoryChecked=true;
			var spanID="price_"+category[i].value;
			var price=document.getElementById(spanID).innerHTML;
			if(price=='$wait list' || price=='$Wait list' || price=='$Wait List'){
				//alert("You must select at least one category");
				categoryChecked=false;
				var flag="wait";
				break;
			}
		}		
	}	
	if(categoryChecked==false){
		if(flag){
			alert("Please don't select category having waiting list");
			categoryChecked=false;	
			return false;	
		}else{
			alert("You must select at least one category");
			categoryChecked=false;	
			return false;		
		}
	}
		
	for(j=0;j<country.length;j++){
		if(country[j].selectedIndex!=0){
			countryChecked=true;			
		}		
	}	

	if(countryChecked==false ){
		if(!flag){
			alert("You must select at least one country");
			return false;
		}
	}	
	
	

	
	
}
