

function sb_textclear(ob, txtmsg){
	if(ob.value==txtmsg){
	ob.value="";
	}
}
function sb_textset(ob, txtmsg){
	if(ob.value==""){
	ob.value=txtmsg;
	}
}

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;				
	}

function ValidateForm(){
	
	var name=document.vform.f_name;
	var lastname=document.vform.last_name;
	var emailID=document.vform.email;
	var street=document.vform.st_add;
	var po_code=document.vform.po_code;
	var city=document.vform.city;
	var st_provin=document.vform.st_provin;
	var telephone =document.vform.telephone;
	var password =document.vform.pass;
	var pass2 =document.vform.pass2;
	var country =document.vform.country;
	
	// for shipping
	
	var check = document.vform.check;
	var s_first =document.vform.s_first;
	var s_lastname =document.vform.s_lastname;
	var s_country =document.vform.s_country;
	var s_zip =document.vform.s_zip;
	var s_state =document.vform.s_state;
	var s_city =document.vform.s_city;
	var s_address =document.vform.s_address;
	var s_ph =document.vform.s_ph;

	if ((name.value==null)||(name.value=="")){
		alert("Please Enter your First Name");
		name.focus();
		return false;
	}
	if ((lastname.value==null)||(lastname.value=="")){
		alert("Please Enter your Last Name");
		lastname.focus();
		return false;
	}
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID");
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return false;
	}
	if ((street.value==null)||(street.value=="")){
		alert("Please Enter Street Name");
		street.focus();
		return false;
	}
	if ((po_code.value==null)||(po_code.value=="")){
		alert("Please Enter Post Code Name");
		po_code.focus();
		return false;
	}
	if ((city.value==null)||(city.value=="")){
		alert("Please Enter City Name");
		city.focus();
		return false;
	}
	if ((st_provin.value==null)||(st_provin.value=="")){
		alert("Please Enter State/Province Name");
		st_provin.focus();
		return false;
	}
	if ((country.value==null)||(country.value=="")){
		alert("Please Select Country");
		country.focus();
		return false;
	}
	if ((telephone.value==null)||(telephone.value=="")){
		alert("Please Enter valid Telephone");
		telephone.focus();
		return false;
	}
	if (isNaN(telephone.value)){
		alert("Please Enter Numbers only");
		telephone.focus();
		return false;
	}
	
	
	var x = document.getElementById("curr_pass");

   if(x.value == '') {
   
   }
   else 
   {
	   	var curr_pass =document.vform.curr_pass;
   		if ((curr_pass.value==null)||(curr_pass.value=="")){
		alert("Please Enter Current Password");
		curr_pass.focus();
		return false;
		}
		
		if ((password.value==null)||(password.value=="")){
		alert("Please Enter your Password");
		password.focus();
		return false;
		}
		if ((pass2.value==null)||(pass2.value=="")){
			alert("Please Enter Confirm Password");
			pass2.focus();
			return false;
		}
		
		if(password.value!=pass2.value)
		{
			alert("Wrong Confirm Password");
			pass2.focus();
			return false;
		}
		
		
   }

	
	
	
	
	
	if(check.checked == false){
	

	
	if ((s_first.value==null)||(s_first.value=="")){
		alert("Please Enter your First name of the person to ship");
		s_first.focus();
		return false;
	}
	if ((s_lastname.value==null)||(s_lastname.value=="")){
		alert("Please Enter your Last name to Ship");
		s_lastname.focus();
		return false;
	}
	if ((s_country.value==null)||(s_country.value=="")){
		alert("Please Enter your Country to ship");
		s_country.focus();
		return false;
	}if ((s_zip.value==null)||(s_zip.value=="")){
		alert("Please Enter your Zip code to ship");
		s_zip.focus();
		return false;
	}if ((s_address.value==null)||(s_address.value=="")){
		alert("Please Enter your Address to ship");
		s_address.focus();
		return false;
	}if ((s_ph.value==null)||(s_ph.value=="")){
		alert("Please Enter your Phone number to Ship");
		s_ph.focus();
		return false;
	}
	
	}
	
	return true;
 }

