// JavaScript Document
//复选框全选设置
//----------------------------------------------------------------------------------
function CheckBoxAll(obj,name,form){
	if(form.elements[name]!=null){
		for(var i=0;i<form.elements[name].length;i++){
			form.elements[name][i].checked = obj.checked;
		}
	}
}

//检验是否为数值
//----------------------------------------------------------------------------------
function checkNumber(obj){
	if(isNaN(obj.value)){
		alert('Please input a Number...');
		obj.focus();
		obj.select();
		return;
	}
}
//检验是否为数值并大于1
//----------------------------------------------------------------------------------
function checkQty(obj){
	if(obj.value == "" || isNaN(obj.value) || obj.value < 1){
		alert('Please enter the integer which should be larger than zero.');
		obj.focus();
		obj.select();
		return false;
	}else{
		return true;	
	}
}

function CheckContactUs(){
	var msg="";
	if(document.contact.name.value == "" || document.contact.name.value.lenght < 2){
			msg += "*Your Full Name must contain a minimum of 2 characters.\n";
	}
	if(document.contact.email.value == "" || document.contact.email.value.length < 6){
		msg += "*Your E-Mail Address must contain a minimum of 6 characters.\n";
	}
	if(document.contact.message.value == "" || document.contact.message.value.length < 10){
		msg += "*Your Enquiry must contain a minimum of 10 characters.\n";
	}
	if(msg==""){
		contact.submit();
	}else{
		msg1 = "Errors have occured during the process of your form.\n\nPlease make the following corrections:\n\n"
		alert(msg1+msg);
	}
}


//检验客户注册信息
//----------------------------------------------------------------------------------
function CheckCustomerInfo(){
	var msg="";
	if(document.register.firstname.value == "" || document.register.firstname.value.length < 2){
		msg += "*Your First Name must contain a minimum of 2 characters.\n";
	}
	if(document.register.lastname.value == "" || document.register.lastname.value.length < 2){
		msg += "*Your Last Name must contain a minimum of 2 characters.\n";
	}
	if(document.register.email.value == "" || document.register.email.value.length < 6){
		msg += "*Your E-Mail Address must contain a minimum of 6 characters.\n";
	}else if(document.register.email.value.match(/^(.+)@(.+)$/)==null){
		msg += "*Please check your email address.\n"	
	}
	if(document.register.street_no.value == "" || document.register.street_no.value.length < 1){
		msg += "*Your Street No must contain a minimum of 1 characters.\n";
	}
	if(document.register.street.value == "" || document.register.street.value.length < 5){
		msg += "*Your Street Address must contain a minimum of 5 characters.\n";
	}
	if(document.register.postcode.value == "" || document.register.postcode.value.length < 4){
		msg += "*Your Post Code must contain a minimum of 4 characters.\n";
	}
	if(document.register.city.value == "" || document.register.city.value.length < 3){
		msg += "*Your City must contain a minimum of 3 characters.\n";
	}
	if(document.register.country.value == "0"){
		msg += "*Your must select a country from this Countries pull down menu.\n";
	}
	if(document.register.state.value == "" && document.register.zone.value == "0"){
		msg += "*Your must select a state or input the Other.\n";
	}
	if(document.register.tel.value == "" || document.register.tel.value.length < 3){
		msg += "*Your Telephone Number must contain a minimum of 3 characters.\n";
	}
	if(document.register.password.value == "" || document.register.password1.value == "" || document.register.password.value.length < 5 || document.register.password1.value.length < 5){
		msg += "*Your Password must contain a minimum of 5 characters.\n";
	}else if(document.register.password.value != document.register.password1.value){
		msg += "*The Password Confirmation must match your Password.";
	}
	if(msg==""){
		register.submit();
	}else{
		msg1 = "Errors have occured during the process of your form.\n\nPlease make the following corrections:\n\n"
		alert(msg1+msg);
	}
}

function CheckEditCustomerInfo(){
	var msg="";
	if(document.editaccount.firstname.value == "" || document.editaccount.firstname.value.length < 2){
		msg += "*Your First Name must contain a minimum of 2 characters.\n";
	}
	if(document.editaccount.lastname.value == "" || document.editaccount.lastname.value.length < 2){
		msg += "*Your Last Name must contain a minimum of 2 characters.\n";
	}
	if(document.editaccount.email.value == "" || document.editaccount.email.value.length < 6){
		msg += "*Your E-Mail Address must contain a minimum of 6 characters.\n";
	}else if(document.editaccount.email.value.match(/^(.+)@(.+)$/)==null){
		msg += "*Please check your email address.\n"	
	}
	if(document.editaccount.street.value == "" || document.editaccount.street.value.length < 5){
		msg += "*Your Street Address must contain a minimum of 5 characters.\n";
	}
	if(document.editaccount.postcode.value == "" || document.editaccount.postcode.value.length < 4){
		msg += "*Your Post Code must contain a minimum of 4 characters.\n";
	}
	if(document.editaccount.city.value == "" || document.editaccount.city.value.length < 3){
		msg += "*Your City must contain a minimum of 3 characters.\n";
	}
	if(document.editaccount.country.value == "0"){
		msg += "*Your must select a country from this Countries pull down menu.\n";
	}
	if(document.editaccount.state.value == "" && document.editaccount.zone.value == "0"){
		msg += "*Your must select a state or input the Other.\n";
	}
	if(document.editaccount.tel.value == "" || document.editaccount.tel.value.length < 3){
		msg += "*Your Telephone Number must contain a minimum of 3 characters.\n";
	}
	if(msg==""){
		editaccount.submit();
	}else{
		msg1 = "Errors have occured during the process of your form.\n\nPlease make the following corrections:\n\n"
		alert(msg1+msg);
	}
}

function CheckEditPassword(){
	var msg="";
	if(document.editpassword.oldpass.value == "" || document.editpassword.newpass1.value == "" || document.editpassword.newpass2.value == "" || document.editpassword.oldpass.value.length < 5 || document.editpassword.newpass1.value.length < 5 || document.editpassword.newpass2.value.length < 5){
		msg += "*Your Password must contain a minimum of 5 characters.\n";
	}else if(document.editpassword.newpass1.value != document.editpassword.newpass2.value){
		msg += "*The Password Confirmation must match your Password.";
	}
	if(msg==""){
		return true;
	}else{
		msg1 = "Errors have occured during the process of your form.\n\nPlease make the following corrections:\n\n"
		alert(msg1+msg);
		return false;
	}
}

function CheckMail(){
	var msg="";
	if(document.contact.name.value == ""){
		msg += "*Please enter your name.\n";	
	}
	if(document.contact.email.value == "" && document.contact.email1.value == ""){
		msg += "*Please enter your Email.\n";
	}else if(document.contact.email.value != document.contact.email1.value){
		msg += "*The Email Confirmation must match your Email.\n";
	}else if(document.contact.email.value.match(/^(.+)@(.+)$/)==null || document.contact.email1.value.match(/^(.+)@(.+)$/)==null){
		msg += "*Please check your email address.\n"	
	}
	if(document.contact.subject.value == ""){
		msg += "*Please enter Message Subject.\n";	
	}
	if(document.contact.message.value == "" ){
		msg += "*Please enter your comments.\n";
	}
	if(msg==""){
		return true;
	}else{
		msg1 = "Errors have occured during the process of your form.\n\nPlease make the following corrections:\n\n"
		alert(msg1+msg);
		return false;
	}
}

//检验客户注册信息
//----------------------------------------------------------------------------------
function CheckAddBooksInfo(){
	var msg="";
	if(document.addbooks.firstname.value == "" || document.addbooks.firstname.value.length < 2){
		msg += "*Your First Name must contain a minimum of 2 characters.\n";
	}
	if(document.addbooks.lastname.value == "" || document.addbooks.lastname.value.length < 2){
		msg += "*Your Last Name must contain a minimum of 2 characters.\n";
	}
	if(document.addbooks.street.value == ""  || document.addbooks.street.value.length < 5){
		msg += "*Your Street Address must contain a minimum of 5 characters.\n";
	}
	if(document.addbooks.postcode.value == "" || document.addbooks.postcode.value.length < 4){
		msg += "*Your Post Code must contain a minimum of 4 characters.\n";
	}
	if(document.addbooks.city.value == "" || document.addbooks.city.value.length < 3){
		msg += "*Your City must contain a minimum of 3 characters.\n";
	}
	if(document.addbooks.country.value == "0"){
		msg += "*Your must select a country from this Countries pull down menu.\n";
	}
	if(document.addbooks.state.value == "" && document.addbooks.zone.value == "0"){
		msg += "*Your must select a state or input the Other.\n";
	}
	if(document.addbooks.telephone.value == "" || document.addbooks.telephone.value.length < 3){
		msg += "*Your Telephone Number must contain a minimum of 3 characters.\n";
	}
	if(msg==""){
		addbooks.submit();
	}else{
		msg1 = "Errors have occured during the process of your form.\n\nPlease make the following corrections:\n\n"
		alert(msg1+msg);
	}
}

//检验付款信息
function CheckPaymentInfo(){
	var msg="";
	if(document.payment.payment.value == "1"){
		if(document.payment.moneriseselectplus_cc_number.value == ""){
			msg += "*Please enter the Credit Card Number.\n";
		}
		if(document.payment.moneriseselectplus_cc_cvs.value == ""){
			msg += "*Please enter the Card Identification Number.\n";
		}
		if(document.payment.moneriseselectplus_street_number.value == ""){
			msg += "*Please enter the Street Number.\n";
		}
		if(document.payment.moneriseselectplus_street_name.value == ""){
			msg += "*Please enter the Street Name.\n";
		}
		if(document.payment.moneriseselectplus_zipcode.value == ""){
			msg += "*Please enter the Zipcode.\n";
		}
		if(msg==""){
			return true;
		}else{
			msg1 = "Errors have occured during the process of your form.\n\nPlease make the following corrections:\n\n"
			alert(msg1+msg);
			return false;
		}
	}else{
		return true;	
	}
}