function validate_contactus_form() {
	var pb=document.contactus_form;
	var name_check = /^([a-zA-Z\s])+([\s])*([a-zA-Z\s])*$/;
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (pb.personName.value==0) {
		alert("Please enter your name");
		pb.personName.focus();
		return false;
	}
	if(!name_check.test(pb.personName.value)) {
		alert("Name should be in alphabets only");
		pb.personName.focus();
		return false;
	}

	if((pb.email.value.length >= 0) && (!email_check.test(pb.email.value))) {
		alert("Please enter a valid Email ID");
		pb.email.focus();
		return false;
	}

	if (pb.phone.value!=0) {
		if (pb.phone.value.length < 8) {
			alert("Please enter a valid phone number");
			pb.phone.focus();
			return false;
		}
	}

	if (pb.address.value==0) {
		alert("Please enter your address");
		pb.address.focus();
		return false;
	}

	if (pb.city.value==0) {
		alert("Please enter your city");
		pb.city.focus();
		return false;
	}
	if(!name_check.test(pb.city.value)) {
		alert("City name should be in alphabets only");
		pb.city.focus();
		return false;
	}

	if (pb.state.value!=0) {
		if(!name_check.test(pb.state.value)) {
			alert("State name should be in alphabets only");
			pb.state.focus();
			return false;
		}
	}

	if (pb.country.value==0) {
		alert("Please select your country");
		pb.country.focus();
		return false;
	}

	if (pb.comments.value==0) {
		alert("Please enter your comments / remarks.");
		pb.comments.focus();
		return false;
	}

	if(pb.security_code.value.length < 8){
		alert("Please enter word verification");
		pb.security_code.focus();
		return false;
	}
}


function validate_login_form() {
	var pb=document.login_form;

	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if((pb.email.value.length >= 0) && (!email_check.test(pb.email.value))) {
		alert("Please enter your email id");
		pb.email.value = "";
		pb.email.focus();
		return false;
	}

	if (pb.pwd.value == 0 || pb.pwd.value == "Password") {
		alert("Please enter your password");
		pb.pwd.value = "";
		pb.pwd.focus();
		return false;
	}
}


function validate_forgot_password_form() {
	var pb=document.forgot_password_form;

	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	if(pb.email.value == "" || pb.email.value == "Enter Your Email ID") {
		alert("Please enter your Email ID");
		pb.email.focus();
		return false;
	}

	if(!email_check.test(pb.email.value)) {
		alert("Invalid Email ID, Please correct the email you entered");
		pb.email.focus();
		return false;
	}
}


function validate_newsletter_form() {
	var pb=document.newsletter_form;
	var name_check = /^([a-zA-Z\s])+([\s])*([a-zA-Z\s])*$/;
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	if (pb.name.value == 0 || pb.name.value == "Enter Your Name") {
		alert("Please enter your name");
		pb.name.focus();
		return false;
	}
	if(!name_check.test(pb.name.value)) {
		alert("Name should be in alphabets only");
		pb.name.focus();
		return false;
	}

	if((pb.email.value.length >= 0) && (!email_check.test(pb.email.value))) {
		alert("Please enter a valid Email ID");
		pb.email.focus();
		return false;
	}
}


function validate_change_password_form() {
	var pb=document.change_password_form;

	if (pb.opwd.value==0) {
		alert("Please enter your old password");
		pb.opwd.focus();
		return false;
	}

	if (pb.npwd.value == 0) {
		alert("Please enter your new password");
		pb.npwd.focus();
		return false;
	}

	if (pb.npwd.value.length < 6) {
		alert("Please enter a valid password [Minimum 6 characters]");
		pb.npwd.focus();
		return false;
	}

	if (pb.cpwd.value == 0) {
		alert("Please confirm your new password");
		pb.cpwd.focus();
		return false;
	}

	if (pb.npwd.value != pb.cpwd.value) {
		alert("Confirm Password does not match");
		pb.cpwd.focus();
		return false;
	}
}


function validate_checkout_form() {
	var pb=document.checkout_form;
	var name_check = /^([a-zA-Z\s])+([\s])*([a-zA-Z\s])*$/;
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if (pb.firstName.value==0) {
		alert("Please enter your name");
		pb.firstName.focus();
		return false;
	}
	if(!name_check.test(pb.firstName.value)) {
		alert("Name should be in alphabets only");
		pb.firstName.focus();
		return false;
	}
	
	if (pb.mobile.value==0) {
		alert("Please enter your mobile no");
		pb.mobile.focus();
		return false;
	}
	
	if(pb.email.value == 0) {
		alert("Please enter your email id");
		pb.email.focus();
		return false;
	}
	if(!email_check.test(pb.email.value)) {
		alert("Please enter a valid email id");
		pb.email.focus();
		return false;
	}
	
	if (pb.contactPerson.value==0) {
		alert("Please enter your billing name");
		pb.contactPerson.focus();
		return false;
	}
	if(!name_check.test(pb.contactPerson.value)) {
		alert("Billing name should be in alphabets only");
		pb.contactPerson.focus();
		return false;
	}

	if (pb.address.value==0) {
		alert("Please enter your billing address");
		pb.address.focus();
		return false;
	}
	
	if (pb.phone.value==0) {
		alert("Please enter your billing telephone number");
		pb.phone.focus();
		return false;
	}
	
	if (pb.country.value==0) {
		alert("Please select your billing country");
		pb.country.focus();
		return false;
	}

	if (pb.state.value!=0) {
		if(!name_check.test(pb.state.value)) {
			alert("State name should be in alphabets only");
			pb.state.focus();
			return false;
		}
	}
	
	if (pb.city.value==0) {
		alert("Please enter your billing city");
		pb.city.focus();
		return false;
	}
	if(!name_check.test(pb.city.value)) {
		alert("City name should be in alphabets only");
		pb.city.focus();
		return false;
	}
	
	if (pb.contactPersonShip.value==0) {
		alert("Please enter your shipping name");
		pb.contactPersonShip.focus();
		return false;
	}
	if(!name_check.test(pb.contactPersonShip.value)) {
		alert("Shipping name should be in alphabets only");
		pb.contactPersonShip.focus();
		return false;
	}

	if (pb.addressShip.value==0) {
		alert("Please enter your shipping address");
		pb.addressShip.focus();
		return false;
	}
	
	if (pb.phoneShip.value==0) {
		alert("Please enter your shipping telephone number");
		pb.phoneShip.focus();
		return false;
	}

	if (pb.countryShip.value==0) {
		alert("Please select your shipping country");
		pb.countryShip.focus();
		return false;
	}
	
	if (pb.stateShip.value!=0) {
		if(!name_check.test(pb.stateShip.value)) {
			alert("State name should be in alphabets only");
			pb.stateShip.focus();
			return false;
		}
	}
	
	if (pb.cityShip.value==0) {
		alert("Please enter your shipping city");
		pb.cityShip.focus();
		return false;
	}
	if(!name_check.test(pb.cityShip.value)) {
		alert("City name should be in alphabets only");
		pb.cityShip.focus();
		return false;
	}
}


function validate_edit_member_admin() {
	var pb=document.edit_member_admin;
	var name_check = /^([a-zA-Z\s])+([\s])*([a-zA-Z\s])*$/;
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	if (pb.firstName.value==0) {
		alert("Please enter your name");
		pb.firstName.focus();
		return false;
	}
	if(!name_check.test(pb.firstName.value)) {
		alert("Name should be in alphabets only");
		pb.firstName.focus();
		return false;
	}
	
	if (pb.mobile.value==0) {
		alert("Please enter your mobile number");
		pb.mobile.focus();
		return false;
	}

	if (pb.contactPerson.value==0) {
		alert("Please enter your billing name");
		pb.contactPerson.focus();
		return false;
	}
	if(!name_check.test(pb.contactPerson.value)) {
		alert("Billing name should be in alphabets only");
		pb.contactPerson.focus();
		return false;
	}

	if (pb.address.value==0) {
		alert("Please enter your billing address");
		pb.address.focus();
		return false;
	}
	
	if (pb.phone.value==0) {
		alert("Please enter your billing telephone number");
		pb.phone.focus();
		return false;
	}
	
	if (pb.country.value==0) {
		alert("Please select your billing country");
		pb.country.focus();
		return false;
	}
	
	if (pb.state.value!=0) {
		if(!name_check.test(pb.state.value)) {
			alert("State name should be in alphabets only");
			pb.state.focus();
			return false;
		}
	}

	if (pb.city.value==0) {
		alert("Please enter your billing city");
		pb.city.focus();
		return false;
	}
	if(!name_check.test(pb.city.value)) {
		alert("City name should be in alphabets only");
		pb.city.focus();
		return false;
	}	

	if (pb.contactPersonShip.value==0) {
		alert("Please enter your shipping name");
		pb.contactPersonShip.focus();
		return false;
	}
	if(!name_check.test(pb.contactPersonShip.value)) {
		alert("Shipping name should be in alphabets only");
		pb.contactPersonShip.focus();
		return false;
	}

	if (pb.addressShip.value==0) {
		alert("Please enter your shipping address");
		pb.addressShip.focus();
		return false;
	}
	
	if (pb.phoneShip.value==0) {
		alert("Please enter your shipping telephone number");
		pb.phoneShip.focus();
		return false;
	}
	
	if (pb.countryShip.value==0) {
		alert("Please select your shipping country");
		pb.countryShip.focus();
		return false;
	}

	if (pb.stateShip.value!=0) {
		if(!name_check.test(pb.stateShip.value)) {
			alert("State name should be in alphabets only");
			pb.stateShip.focus();
			return false;
		}
	}

	if (pb.cityShip.value==0) {
		alert("Please enter your shipping city");
		pb.cityShip.focus();
		return false;
	}
	if(!name_check.test(pb.cityShip.value)) {
		alert("City name should be in alphabets only");
		pb.cityShip.focus();
		return false;
	}
}


function validate_refer_friend_form() {
	var pb=document.refer_friend_form;

	var name_check = /^([a-zA-Z\s])+([\s])*([a-zA-Z\s])*$/;
	if((pb.your_name.value.length >= 0) && (!name_check.test(pb.your_name.value))) {
		alert("Please enter your name, should be in alphabets only");
		pb.your_name.focus();
		return false;
	}

	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	if((pb.your_email.value.length >= 0) && (!email_check.test(pb.your_email.value))) {
		alert("Please enter a valid email id");
		pb.your_email.focus();
		return false;
	}

	if((pb.friend_name.value.length >= 0) && (!name_check.test(pb.friend_name.value))) {
		alert("Please enter your friend's name, should be in alphabets only");
		pb.friend_name.focus();
		return false;
	}

	if((pb.friend_email.value.length >= 0) && (!email_check.test(pb.friend_email.value))) {
		alert("Please enter a valid email id of your friend");
		pb.friend_email.focus();
		return false;
	}
}


function validate_ebook_login_form() {
	var pb=document.ebook_login_form;

	var name_check = /^([a-zA-Z\s])+([\s])*([a-zA-Z\s])*$/;
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	if(pb.userName.value == 0) {
		alert("Please enter your name, should be in alphabets only");
		pb.userName.focus();
		return false;
	}
	if(!name_check.test(pb.userName.value)) {
		alert("Name should be in alphabets only");
		pb.userName.focus();
		return false;
	}

	if(pb.email.value == 0) {
		alert("Please enter your email id");
		pb.email.focus();
		return false;
	}
	if(!email_check.test(pb.email.value)) {
		alert("Please enter a valid email id");
		pb.email.focus();
		return false;
	}
}


function validate_testimonial_form() {
	var pb=document.testimonial_form;

	var name_check = /^([a-zA-Z\s])+([\s])*([a-zA-Z\s])*$/;
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	if(pb.personName.value == 0) {
		alert("Please enter your name, should be in alphabets only");
		pb.personName.focus();
		return false;
	}
	if(!name_check.test(pb.personName.value)) {
		alert("Name should be in alphabets only");
		pb.personName.focus();
		return false;
	}

	if(pb.email.value == 0) {
		alert("Please enter your email id");
		pb.email.focus();
		return false;
	}
	if(!email_check.test(pb.email.value)) {
		alert("Please enter a valid email id");
		pb.email.focus();
		return false;
	}

	if(pb.title.value == 0) {
		alert("Please enter your title");
		pb.title.focus();
		return false;
	}

	if(pb.content.value == 0) {
		alert("Please enter your testimonial details");
		pb.content.focus();
		return false;
	}
	if(pb.content.value.length > 3000) {
		alert("Content overflow! Maximum characters limit is 3000 characters.");
		pb.content.focus();
		return false;
	}
}


function filldata() {
	var pb=document.checkout_form;
  if(pb.chk.checked==1) {
	  pb.contactPersonShip.value=pb.contactPerson.value;
	  pb.addressShip.value=pb.address.value;
	  pb.cityShip.value=pb.city.value;
	  pb.stateShip.value=pb.state.value;
	  pb.countryShip.value=pb.country.value;
	  pb.zipcodeShip.value=pb.zipcode.value;
	  pb.phoneShip.value=pb.phone.value;
	  pb.faxShip.value=pb.fax.value;
  }
  else{
	  pb.contactPersonShip.value="";
	  pb.addressShip.value="";
	  pb.cityShip.value="";
	  pb.stateShip.value="";
	  pb.countryShip.value="";
	  pb.zipcodeShip.value="";
	  pb.phoneShip.value="";
	  pb.faxShip.value="";
  }
}


function filldata_admin() {
	var pb=document.manage_members;
  if(pb.chk.checked==1) {
	  pb.contactPersonShip.value=pb.contactPerson.value;
	  pb.addressShip.value=pb.address.value;
	  pb.cityShip.value=pb.city.value;
	  pb.stateShip.value=pb.state.value;
	  pb.countryShip.value=pb.country.value;
	  pb.zipcodeShip.value=pb.zipcode.value;
	  pb.phoneShip.value=pb.phone.value;
	  pb.faxShip.value=pb.fax.value;
  }
  else{
	  pb.contactPersonShip.value="";
	  pb.addressShip.value="";
	  pb.cityShip.value="";
	  pb.stateShip.value="";
	  pb.countryShip.value="";
	  pb.zipcodeShip.value="";
	  pb.phoneShip.value="";
	  pb.faxShip.value="";
  }
}


function submit_form(formName, url, hiddenAttribute1, useId1, hiddenAttribute2, useId2) {
	var useId=document.getElementById(useId2).value;
	document.getElementById(hiddenAttribute1).value=useId1;
	document.getElementById(hiddenAttribute2).value=useId;
	document.getElementById(formName).action =url;
	document.getElementById(formName).submit();
	return true;
}


function validate_keyword_search() {
	var pb=document.keyword_search;
	if (pb.keyword.value==0 || pb.keyword.value=="Enter Keyword ...") {
		alert("Please enter search keyword");
		pb.keyword.focus();
		return false;
	}
}


function validate_advanced_search() {
	var pb=document.advanced_search;

	if (pb.minimumPrice.value == 0) {
		alert("Please select minimum price");
		pb.minimumPrice.focus();
		return false;
	}

	if (pb.maximumPrice.value == 0) {
		alert("Please select maximum price");
		pb.maximumPrice.focus();
		return false;
	}

	if (parseInt(pb.maximumPrice.value) <= parseInt(pb.minimumPrice.value)) {
		alert("Please select maximum price greater than minimum price");
		pb.maximumPrice.focus();
		return false;
	}

}


function Check_All() {
	var pb=document.shopping_cart_form;
	var count = pb.elements.length;

	if(pb.chk.checked == 0) {
		for (i=0; i < count; i++) {
			if(pb.elements[i].type=="checkbox") {
				pb.elements[i].checked = 0;
				pb.checked=0;
			}
		}
	}

	if(pb.chk.checked == 1 ) {
		for (i=0; i < count; i++) {
			if(pb.elements[i].type=="checkbox") {
				pb.elements[i].checked = 1;
				pb.chk.checked=1;
			}
		}
	}
}


function increase_quantity(fldName) {
	var qty=document.getElementById(fldName).value;
	qty++;
	document.getElementById(fldName).value=qty;
}


function decrease_quantity(fldName) {
	var qty=document.getElementById(fldName).value;
	if (parseInt(qty) >1) {
		qty--;
	}
	document.getElementById(fldName).value=qty;
}


function chk_unchk(val, form_name) {
	pb=eval('document.'+form_name);
	len=pb.elements.length;
	var i=0;
	for (i=0; i<len; i++) {
		if (pb.elements[i].type == "checkbox") {
			if (val == 1) {
				pb.elements[i].checked=true;
			}
			else {
				pb.elements[i].checked=false;
			}
		}
	}
}


function validate_manage_members() {
	var pb=document.manage_members;
	var name_check = /^([a-zA-Z\s])+([\s])*([a-zA-Z\s])*$/;
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	if((pb.email.value.length >= 0) && (!email_check.test(pb.email.value))) {
		alert("Please enter a valid Email ID");
		pb.email.focus();
		return false;
	}

	if (pb.pwd.value.length < 6) {
		alert("Please enter a valid password [Minimum 6 characters]");
		pb.pwd.focus();
		return false;
	}
	
	if (pb.cpwd.value == 0) {
		alert("Please confirm your password");
		pb.cpwd.focus();
		return false;
	}

	if (pb.pwd.value != pb.cpwd.value) {
		alert("Confirm Password does not match");
		pb.cpwd.focus();
		return false;
	}

	if (pb.firstName.value==0) {
		alert("Please enter your name");
		pb.firstName.focus();
		return false;
	}
	if(!name_check.test(pb.firstName.value)) {
		alert("Name should be in alphabets only");
		pb.firstName.focus();
		return false;
	}

	if (pb.mobile.value==0) {
		alert("Please enter your mobile number");
		pb.mobile.focus();
		return false;
	}


	if (pb.contactPerson.value==0) {
		alert("Please enter your billing name");
		pb.contactPerson.focus();
		return false;
	}
	if(!name_check.test(pb.contactPerson.value)) {
		alert("Contact person name should be in alphabets only");
		pb.contactPerson.focus();
		return false;
	}

	if (pb.address.value==0) {
		alert("Please enter your billing address");
		pb.address.focus();
		return false;
	}

	if (pb.phone.value==0) {
		alert("Please enter your billing phone number");
		pb.phone.focus();
		return false;
	}

	if (pb.country.value==0) {
		alert("Please select your billing country");
		pb.country.focus();
		return false;
	}
	
	if (pb.country.value=="Australia") {
  	if (pb.stateAus.value==0) {
  		alert("Please select your billing state");
  		return false;
  	}  	
	}
	
	if (pb.state.value!=0) {
		if(!name_check.test(pb.state.value)) {
			alert("State name should be in alphabets only");
			pb.state.focus();
			return false;
		}
	}

	if (pb.city.value==0) {
		alert("Please enter your billing city");
		pb.city.focus();
		return false;
	}
	if(!name_check.test(pb.city.value)) {
		alert("City name should be in alphabets only");
		pb.city.focus();
		return false;
	}

	if (pb.contactPersonShip.value==0) {
		alert("Please enter your shipping name");
		pb.contactPersonShip.focus();
		return false;
	}
	if(!name_check.test(pb.contactPersonShip.value)) {
		alert("Contact person name should be in alphabets only");
		pb.contactPersonShip.focus();
		return false;
	}

	if (pb.addressShip.value==0) {
		alert("Please enter your shipping address");
		pb.addressShip.focus();
		return false;
	}

	if (pb.phoneShip.value==0) {
		alert("Please enter your shipping phone number");
		pb.phoneShip.focus();
		return false;
	}

	if (pb.countryShip.value==0) {
		alert("Please select your shipping country");
		pb.countryShip.focus();
		return false;
	}
	
	if (pb.countryShip.value=="Australia") {
  	if (pb.stateAusShip.value==0) {
  		alert("Please select your shipping state");
  		return false;
  	}  	
	}
	
	if (pb.stateShip.value!=0) {
		if(!name_check.test(pb.stateShip.value)) {
			alert("State name should be in alphabets only");
			pb.stateShip.focus();
			return false;
		}
	}

	if (pb.cityShip.value==0) {
		alert("Please enter your shipping city");
		pb.cityShip.focus();
		return false;
	}
	if(!name_check.test(pb.cityShip.value)) {
		alert("City name should be in alphabets only");
		pb.cityShip.focus();
		return false;
	}
}


function view_state_options(val) {
  document.getElementById("state_drop_down").style.display='none';
	document.getElementById("state_text_box").style.display='block';

	if (val == "Australia") {
		document.getElementById("state_drop_down").style.display='block';
		document.getElementById("state_text_box").style.display='none';		
	}
}


function view_state_options_ship(val) {
	document.getElementById("state_drop_down_ship").style.display='none';
	document.getElementById("state_text_box_ship").style.display='block';

	if (val == "Australia") {
		document.getElementById("state_drop_down_ship").style.display='block';
		document.getElementById("state_text_box_ship").style.display='none';		
	}
}
