// JavaScript Document
function validateProductDetails(){		
	if(TextValidate(document.frmproductdetails.product_qty,"Quantity")==false) {
		document.frmproductdetails.product_qty.focus();		
		return false;	
	}else{
		if(trimAll(document.frmproductdetails.product_qty.value) == 0){
			alert("Please don't enter 0 for Quantity");
			document.frmproductdetails.product_qty.focus();		
			return false;			
		}
		if(isNaN(trimAll(document.frmproductdetails.product_qty.value))){
			alert("Please don't enter character for Quantity");
			document.frmproductdetails.product_qty.focus();		
			return false;														  
		}
	}
	if(trimAll(document.frmproductdetails.product_qty.value).length > 4){
		alert("Quantity should be less than or equal to 4 characters");
		document.frmproductdetails.product_qty.focus();
		document.frmproductdetails.product_qty.select();
		return false;		
	}	
	if(trimAll(document.frmproductdetails.product_qty.value).indexOf('.') != -1){
		alert("Please don't enter decimal value for Quantity");
		document.frmproductdetails.product_qty.focus();
		document.frmproductdetails.product_qty.select();	
		return false;
	}
	if(trimAll(document.frmproductdetails.product_qty.value).indexOf('-') != -1){
		alert("Please don't enter negative value for Quantity");
		document.frmproductdetails.product_qty.focus();
		document.frmproductdetails.product_qty.select();	
		return false;
	}	
	document.frmproductdetails.submit();
}

//To validate the username and password (login validation for all page)
function validateLogin(){
	if(EmailValidate(document.frmlogin.customer_email,"Email") == false){
		document.frmlogin.customer_email.focus();
		return false;
	}
	if(TextValidate(document.frmlogin.customer_password,"Password") == false){
		document.frmlogin.Password.focus();
		return false;
	}	
	document.frmlogin.submit();
}

//For login validation in all page
function  checkEnterLogin(e){ //e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable
	
	if(e && e.which){ //if which property of event object is supported (NN4)
	e = e
	characterCode = e.which //character code is contained in NN4's which property
	}
	else{
	//e = event
	characterCode = e.keyCode //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		validateLogin();
	}
}


//login Page starts here
function validateMainLogin(){
	if(TextValidate(document.frmmainlogin.member_user_name,"User Name") == false){
		document.frmmainlogin.member_user_name.focus();
		return false;
	}
	if(TextValidate(document.frmmainlogin.member_password,"Password") == false){
		document.frmmainlogin.member_password.focus();
		return false;
	}	
	document.frmmainlogin.submit();
}
//For login validation in all page
function  checkEnterMainLogin(e){ //e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable
	
	if(e && e.which){ //if which property of event object is supported (NN4)
	e = e
	characterCode = e.which //character code is contained in NN4's which property
	}
	else{
	//e = event
	characterCode = e.keyCode //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		validateMainLogin();
	}
}
function callRegistration(){
	
	if(TextValidate(document.frmmember.member_name,"Name")==false) {
		document.frmmember.member_name.focus();		
		return false;	
	}else{
		if(isSpecialName(trimAll(document.frmmember.member_name.value)) == false){
			alert("Please don't enter the following special characters for Name. \"{}&/.;-,_+'*()~\\[]!@#$%^");
			document.frmmember.member_name.focus();
			document.frmmember.member_name.select();
			return false;				
		}
	}
	if(trimAll(document.frmmember.member_name.value).length > 100){
		alert("Your Name should be less than or equal to 100 characters");
		document.frmmember.member_name.focus();
		document.frmmember.member_name.select();
		return false;		
	}	
	if(TextValidate(document.frmmember.member_address,"Address")==false) {
		document.frmmember.member_address.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_address.value).length > 255){
		alert("Address should be less than or equal to 255 characters");
		document.frmmember.member_address.focus();
		document.frmmember.member_address.select();
		return false;		
	}	
	if(TextValidate(document.frmmember.member_city,"City")==false) {
		document.frmmember.member_city.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_city.value).length > 100){
		alert("City should be less than or equal to 100 characters");
		document.frmmember.member_city.focus();
		document.frmmember.member_city.select();
		return false;		
	}	
	if(TextValidate(document.frmmember.member_state,"State")==false) {
		document.frmmember.member_state.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_state.value).length > 100){
		alert("State should be less than or equal to 100 characters");
		document.frmmember.member_state.focus();
		document.frmmember.member_state.select();
		return false;		
	}	
	if(SelectValidate(document.frmmember.member_country,"Country")==false) {
		document.frmmember.member_country.focus();		
		return false;	
	}	


	if(TextValidate(document.frmmember.member_zip_code,"Zip Code")==false) {
		document.frmmember.member_zip_code.focus();		
		return false;	
	}else{
		if(isPincode(trimAll(document.frmmember.member_zip_code.value)) == false){
			alert("Please enter the valid Zip Code");
			document.frmmember.member_zip_code.focus();		
			return false;				
		}
	}
	if(trimAll(document.frmmember.member_zip_code.value).length > 20){
		alert("Zip/Pin Code should be less than or equal to 20 characters");
		document.frmmember.member_zip_code.focus();
		return false;		
	}	
	if(TextValidate(document.frmmember.member_mobile_number,"Mobile Number")==false) {
		document.frmmember.member_mobile_number.focus();		
		return false;	
	}else{
		if(isPhone(document.frmmember.member_mobile_number.value) == false){
			document.frmmember.member_mobile_number.focus();
			alert("Please enter the valid Mobile Number");
			return false;
		}
	}
	if(trimAll(document.frmmember.member_mobile_number.value).length > 20){
		alert("Mobile Number should be less than or equal to 20 characters");
		document.frmmember.member_mobile_number.focus();
		document.frmmember.member_mobile_number.select();
		return false;		
	}
	if(TextValidate(document.frmmember.member_telephone_number,"Telephone Number")==false) {
		document.frmmember.member_telephone_number.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_telephone_number.value).length > 20){
		alert("Telephone Number should be less than or equal to 20 characters");
		document.frmmember.member_telephone_number.focus();
		return false;		
	}else{
		if(isPhone(document.frmmember.member_telephone_number.value) == false){
			document.frmmember.member_telephone_number.focus();
			alert("Please enter the valid Telephone Number");
			return false;
		}
	}	
	if(EmailValidate(document.frmmember.member_email,"Email")==false) {
		document.frmmember.member_email.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_email.value).length > 50){
		alert("Email should be less than or equal to 50 characters");
		document.frmmember.member_email.focus();
		document.frmmember.member_email.select();
		return false;		
	}
	if(TextValidate(document.frmmember.member_user_name,"User Name")==false) {
		document.frmmember.member_user_name.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_user_name.value).length < 6){
		alert("User Name should be atleast 6 characters !");
		document.frmmember.member_user_name.focus();	
		document.frmmember.member_user_name.select();		
		return false;
	}	
	if(trimAll(document.frmmember.member_user_name.value).length > 50){
		alert("User Name should be less than or equal to 50 characters");
		document.frmmember.member_user_name.focus();
		document.frmmember.member_user_name.select();
		return false;		
	}	
	if(trimAll(document.frmmember.member_user_name.value).indexOf(' ') != -1){
		alert("Please don't enter space for User Name");
		document.frmmember.member_user_name.focus();
		document.frmmember.member_user_name.select();		
		return false;				
	}
	if(!isAlphanum(document.frmmember.member_user_name.value)){		
		alert("Please don't enter special character for User Name");
		document.frmmember.member_user_name.focus();
		document.frmmember.member_user_name.select();		
		return false;		
	}
	if(TextValidate(document.frmmember.member_password,"Password")==false) {
		document.frmmember.member_password.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_password.value).length < 6){
		alert("Password should be atleast 6 characters !");
		document.frmmember.member_password.focus();	
		document.frmmember.member_password.select();		
		return false;
	}	
	if(trimAll(document.frmmember.member_password.value).length > 50){
		alert("Password should be less than or equal to 50 characters");
		document.frmmember.member_password.focus();
		document.frmmember.member_password.select();
		return false;		
	}	
	if(trimAll(document.frmmember.member_password.value).indexOf(' ') != -1){
		alert("Please don't enter space for Password");
		document.frmmember.member_password.focus();
		document.frmmember.member_password.select();		
		return false;				
	}		
	if(!isAlphanum(document.frmmember.member_password.value)){		
		alert("Please don't enter special character for Password");
		document.frmmember.member_password.focus();
		document.frmmember.member_password.select();		
		return false;		
	}	
	if(TextValidate(document.frmmember.member_confirm_password,"Confirm Password")==false) {
		document.frmmember.member_confirm_password.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_confirm_password.value).length < 6){
		alert("Confirm Password should be atleast 6 characters !");
		document.frmmember.member_confirm_password.focus();	
		document.frmmember.member_confirm_password.select();		
		return false;
	}	
	if(trimAll(document.frmmember.member_confirm_password.value).length > 50){
		alert("Confirm Password should be less than or equal to 50 characters");
		document.frmmember.member_confirm_password.focus();
		document.frmmember.member_confirm_password.select();
		return false;		
	}		

	if (trimAll(document.frmmember.member_password.value) != trimAll(document.frmmember.member_confirm_password.value) )
	{
		alert("Password and Confirm Password do not match !");
		document.frmmember.member_confirm_password.focus();	
		document.frmmember.member_confirm_password.select();	
		return false;
	}	
	document.frmmember.submit();
}
function  checkRegistration(e){ //e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable
	
	if(e && e.which){ //if which property of event object is supported (NN4)
	e = e
	characterCode = e.which //character code is contained in NN4's which property
	}
	else{
	//e = event
	characterCode = e.keyCode //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		callRegistration();
	}
}
function callDeliveryAddress(chkObj){
	if(chkObj.checked == true){
		document.frmregistration.customer_del_firstname.value = trimAll(document.frmregistration.customer_firstname.value);
		document.frmregistration.customer_del_surname.value = trimAll(document.frmregistration.customer_surname.value);
		document.frmregistration.customer_del_telephone.value = trimAll(document.frmregistration.customer_telephone.value);
		document.frmregistration.customer_del_mobile.value = trimAll(document.frmregistration.customer_mobile.value);		
		document.frmregistration.customer_del_email.value = trimAll(document.frmregistration.customer_email.value);
		document.frmregistration.customer_del_address.value = trimAll(document.frmregistration.customer_invoice_address.value);
		document.frmregistration.customer_del_town.value = trimAll(document.frmregistration.customer_town.value);	
		document.frmregistration.customer_del_county.value = trimAll(document.frmregistration.customer_county.value);
		document.frmregistration.customer_del_zip_code.value = trimAll(document.frmregistration.customer_zip_code.value);			
	}else{
		document.frmregistration.customer_del_firstname.value = trimAll(document.frmregistration.customer_firstname_hid.value);
		document.frmregistration.customer_del_surname.value = trimAll(document.frmregistration.customer_surname_hid.value);
		document.frmregistration.customer_del_telephone.value = trimAll(document.frmregistration.customer_telephone_hid.value);
		document.frmregistration.customer_del_mobile.value = trimAll(document.frmregistration.customer_mobile_hid.value);		
		document.frmregistration.customer_del_email.value = trimAll(document.frmregistration.customer_email_hid.value);
		document.frmregistration.customer_del_address.value = trimAll(document.frmregistration.customer_invoice_address_hid.value);
		document.frmregistration.customer_del_town.value = trimAll(document.frmregistration.customer_town_hid.value);	
		document.frmregistration.customer_del_county.value = trimAll(document.frmregistration.customer_county_hid.value);
		document.frmregistration.customer_del_zip_code.value = trimAll(document.frmregistration.customer_zip_code_hid.value);
	}
}
//login Page ends here

function  checkEnterProductDetails(e){ //e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable
	
	if(e && e.which){ //if which property of event object is supported (NN4)
	e = e
	characterCode = e.which //character code is contained in NN4's which property
	}
	else{
	//e = event
	characterCode = e.keyCode //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		validateProductDetails();
	}
}


//shopping basket page
var basketHTTP;
function updateBasket(qtyObj,tmpshopcart_id,product_price){
	flagvalue = qtyObj.value;
	if(isNaN(qtyObj.value) || qtyObj.value == 0 || qtyObj.value.indexOf(".") != -1){
		qtyObj.value = qtyObj.value.substr(0,qtyObj.value.length-1);
/*		if(flagvalue == 0 && flagvalue != ''){
			qtyObj.value = document.getElementById('product_qty_hid'+tmpshopcart_id).value;
		}*/
		return false;
	}
    url =  "ajax_update_basket.php?temp_cart_id="+tmpshopcart_id+"&temp_cart_qty="+qtyObj.value+"&product_price="+product_price;
	basketHTTP = ajaxfunctin();					
	basketHTTP.open("GET",url,true); 
	basketHTTP.send(null); 
	basketHTTP.onreadystatechange=getStatusUpdateBasket;				
}
function ajaxfunctin()
{
	var xmlHttp;
	try
	{
			xmlHttp=new XMLHttpRequest();
	}
	catch(e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e)
			{
				alert("browser does not support AJAX");
				return false;
			}
		}
	}
	return xmlHttp;
}
function getStatusUpdateBasket() { 
	if (basketHTTP.readyState == 4) { 	
		var result = basketHTTP.responseText; 
		product_details = result.split("$$$");
		document.getElementById("tdidtotalproductprice"+product_details[0]).innerHTML = product_details[1]+" $";
		document.getElementById("dividtotalprice").innerHTML = product_details[2]+" $";
	}
} 

function removeBasket(tmpshopcart_id){
	if(confirm("Are you sure to remove this product from basket?")){
		window.location.href = "basket_delete.php?tmpshopcart_id="+tmpshopcart_id;
	}else{
		return false;
	}
}
function validateBasketCheckOut(){
	ctnbasket = document.getElementById("noofproductsinbasket").value;
	for(i = 0 ; i < ctnbasket ; i++){
		if(TextValidate(document.getElementById("product_qty"+i),"Quantity")==false) {
			document.getElementById("product_qty"+i).focus();		
			return false;	
		}else{
			if(trimAll(document.getElementById("product_qty"+i).value) == 0){
				alert("Please don't enter 0 for Quantity");
				document.getElementById("product_qty"+i).focus();		
				return false;			
			}
			if(isNaN(trimAll(document.getElementById("product_qty"+i).value))){
				alert("Please don't enter character for Quantity");
				document.getElementById("product_qty"+i).focus();		
				return false;														  
			}
		}
		if(trimAll(document.getElementById("product_qty"+i).value).length > 4){
			alert("Quantity should be less than or equal to 4 characters");
			document.getElementById("product_qty"+i).focus();
			document.getElementById("product_qty"+i).select();
			return false;		
		}	
		if(trimAll(document.getElementById("product_qty"+i).value).indexOf('.') != -1){
			alert("Please don't enter decimal value for Quantity");
			document.getElementById("product_qty"+i).focus();
			document.getElementById("product_qty"+i).select();	
			return false;
		}	
		if(trimAll(document.getElementById("product_qty"+i).value).indexOf('-') != -1){
			alert("Please don't enter negative value for Quantity");
			document.getElementById("product_qty"+i).focus();
			document.getElementById("product_qty"+i).select();	
			return false;
		}		
	}
	window.location.href = 'basketCheckout.php';
}
//shopping basket page end here//

//basket page
function callBasketCheckout(){
	
	if(TextValidate(document.frmmember.member_name,"Name")==false) {
		document.frmmember.member_name.focus();		
		return false;	
	}else{
		if(isSpecialName(trimAll(document.frmmember.member_name.value)) == false){
			alert("Please don't enter the following special characters for Name. \"{}&/.;-,_+'*()~\\[]!@#$%^");
			document.frmmember.member_name.focus();
			document.frmmember.member_name.select();
			return false;				
		}
	}
	if(trimAll(document.frmmember.member_name.value).length > 100){
		alert("Your Name should be less than or equal to 100 characters");
		document.frmmember.member_name.focus();
		document.frmmember.member_name.select();
		return false;		
	}	
	if(TextValidate(document.frmmember.member_address,"Address")==false) {
		document.frmmember.member_address.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_address.value).length > 255){
		alert("Address should be less than or equal to 255 characters");
		document.frmmember.member_address.focus();
		document.frmmember.member_address.select();
		return false;		
	}	
	if(TextValidate(document.frmmember.member_city,"City")==false) {
		document.frmmember.member_city.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_city.value).length > 100){
		alert("City should be less than or equal to 100 characters");
		document.frmmember.member_city.focus();
		document.frmmember.member_city.select();
		return false;		
	}	
	if(TextValidate(document.frmmember.member_state,"State")==false) {
		document.frmmember.member_state.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_state.value).length > 100){
		alert("State should be less than or equal to 100 characters");
		document.frmmember.member_state.focus();
		document.frmmember.member_state.select();
		return false;		
	}	
	if(SelectValidate(document.frmmember.member_country,"Country")==false) {
		document.frmmember.member_country.focus();		
		return false;	
	}	


	if(TextValidate(document.frmmember.member_zip_code,"Zip Code")==false) {
		document.frmmember.member_zip_code.focus();		
		return false;	
	}else{
		if(isPincode(trimAll(document.frmmember.member_zip_code.value)) == false){
			alert("Please enter the valid Zip Code");
			document.frmmember.member_zip_code.focus();		
			return false;				
		}
	}
	if(trimAll(document.frmmember.member_zip_code.value).length > 20){
		alert("Zip/Pin Code should be less than or equal to 20 characters");
		document.frmmember.member_zip_code.focus();
		return false;		
	}	
	if(TextValidate(document.frmmember.member_mobile_number,"Mobile Number")==false) {
		document.frmmember.member_mobile_number.focus();		
		return false;	
	}else{
		if(isPhone(document.frmmember.member_mobile_number.value) == false){
			document.frmmember.member_mobile_number.focus();
			alert("Please enter the valid Mobile Number");
			return false;
		}
	}
	if(trimAll(document.frmmember.member_mobile_number.value).length > 20){
		alert("Mobile Number should be less than or equal to 20 characters");
		document.frmmember.member_mobile_number.focus();
		document.frmmember.member_mobile_number.select();
		return false;		
	}
	if(TextValidate(document.frmmember.member_telephone_number,"Telephone Number")==false) {
		document.frmmember.member_telephone_number.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_telephone_number.value).length > 20){
		alert("Telephone Number should be less than or equal to 20 characters");
		document.frmmember.member_telephone_number.focus();
		return false;		
	}else{
		if(isPhone(document.frmmember.member_telephone_number.value) == false){
			document.frmmember.member_telephone_number.focus();
			alert("Please enter the valid Telephone Number");
			return false;
		}
	}	
	if(EmailValidate(document.frmmember.member_email,"Email")==false) {
		document.frmmember.member_email.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_email.value).length > 50){
		alert("Email should be less than or equal to 50 characters");
		document.frmmember.member_email.focus();
		document.frmmember.member_email.select();
		return false;		
	}

	/*if(TextValidate(document.frmmember.member_del_name,"Name")==false) {
		document.frmmember.member_del_name.focus();		
		return false;	
	}else{
		if(isSpecialName(trimAll(document.frmmember.member_del_name.value)) == false){
			alert("Please don't enter the following special characters for Name. \"{}&/.;-,_+'*()~\\[]!@#$%^");
			document.frmmember.member_del_name.focus();
			document.frmmember.member_del_name.select();
			return false;				
		}
	}
	if(trimAll(document.frmmember.member_del_name.value).length > 100){
		alert("Your Name should be less than or equal to 100 characters");
		document.frmmember.member_del_name.focus();
		document.frmmember.member_del_name.select();
		return false;		
	}	
	if(TextValidate(document.frmmember.member_del_address,"Address")==false) {
		document.frmmember.member_del_address.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_address.value).length > 255){
		alert("Address should be less than or equal to 255 characters");
		document.frmmember.member_address.focus();
		document.frmmember.member_address.select();
		return false;		
	}	
	if(TextValidate(document.frmmember.member_del_city,"City")==false) {
		document.frmmember.member_del_city.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_del_city.value).length > 100){
		alert("City should be less than or equal to 100 characters");
		document.frmmember.member_del_city.focus();
		document.frmmember.member_del_city.select();
		return false;		
	}	
	if(TextValidate(document.frmmember.member_del_state,"State")==false) {
		document.frmmember.member_del_state.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_del_state.value).length > 100){
		alert("State should be less than or equal to 100 characters");
		document.frmmember.member_del_state.focus();
		document.frmmember.member_del_state.select();
		return false;		
	}	
	if(SelectValidate(document.frmmember.member_del_country,"Country")==false) {
		document.frmmember.member_del_country.focus();		
		return false;	
	}	


	if(TextValidate(document.frmmember.member_del_zip_code,"Zip Code")==false) {
		document.frmmember.member_zip_code.focus();		
		return false;	
	}else{
		if(isPincode(trimAll(document.frmmember.member_del_zip_code.value)) == false){
			alert("Please enter the valid Zip Code");
			document.frmmember.member_zip_code.focus();		
			return false;				
		}
	}
	if(trimAll(document.frmmember.member_del_zip_code.value).length > 20){
		alert("Zip/Pin Code should be less than or equal to 20 characters");
		document.frmmember.member_del_zip_code.focus();
		return false;		
	}	
	if(TextValidate(document.frmmember.member_del_mobile_number,"Mobile Number")==false) {
		document.frmmember.member_del_mobile_number.focus();		
		return false;	
	}else{
		if(isPhone(document.frmmember.member_del_mobile_number.value) == false){
			document.frmmember.member_del_mobile_number.focus();
			alert("Please enter the valid Mobile Number");
			return false;
		}
	}
	if(trimAll(document.frmmember.member_del_mobile_number.value).length > 20){
		alert("Mobile Number should be less than or equal to 20 characters");
		document.frmmember.member_del_mobile_number.focus();
		document.frmmember.member_del_mobile_number.select();
		return false;		
	}
	if(TextValidate(document.frmmember.member_del_telephone_number,"Telephone Number")==false) {
		document.frmmember.member_del_telephone_number.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_del_telephone_number.value).length > 20){
		alert("Telephone Number should be less than or equal to 20 characters");
		document.frmmember.member_del_telephone_number.focus();
		return false;		
	}else{
		if(isPhone(document.frmmember.member_del_telephone_number.value) == false){
			document.frmmember.member_del_telephone_number.focus();
			alert("Please enter the valid Telephone Number");
			return false;
		}
	}	
	if(EmailValidate(document.frmmember.member_del_email,"Email")==false) {
		document.frmmember.member_del_email.focus();		
		return false;	
	}	
	if(trimAll(document.frmmember.member_del_email.value).length > 50){
		alert("Email should be less than or equal to 50 characters");
		document.frmmember.member_del_email.focus();
		document.frmmember.member_del_email.select();
		return false;		
	}*/
	
	document.frmmember.submit();
}
function  checkBasketCheckout(e){ //e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable
	
	if(e && e.which){ //if which property of event object is supported (NN4)
	e = e
	characterCode = e.which //character code is contained in NN4's which property
	}
	else{
	//e = event
	characterCode = e.keyCode //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		callBasketCheckout();
	}
}
function callDeliveryAddressCheckout(chkObj){	
	if(chkObj.checked == true){
		document.frmmember.member_del_name.value = trimAll(document.frmmember.member_name.value);
		document.frmmember.member_del_telephone_number.value = trimAll(document.frmmember.member_telephone_number.value);
		document.frmmember.member_del_mobile_number.value = trimAll(document.frmmember.member_mobile_number.value);		
		document.frmmember.member_del_email.value = trimAll(document.frmmember.member_email.value);
		document.frmmember.member_del_address.value = trimAll(document.frmmember.member_address.value);
		document.frmmember.member_del_city.value = trimAll(document.frmmember.member_city.value);	
		document.frmmember.member_del_state.value = trimAll(document.frmmember.member_state.value);	
		document.frmmember.member_del_country.value = trimAll(document.frmmember.member_country.value);		
		document.frmmember.member_del_zip_code.value = trimAll(document.frmmember.member_zip_code.value);					
	}else{
		document.frmmember.member_del_name.value = '';
		document.frmmember.member_del_telephone_number.value = '';
		document.frmmember.member_del_mobile_number.value = '';		
		document.frmmember.member_del_email.value = '';
		document.frmmember.member_del_address.value = '';
		document.frmmember.member_del_city.value = '';	
		document.frmmember.member_del_state.value = '';	
		document.frmmember.member_del_country.value = 0;		
		document.frmmember.member_del_zip_code.value = '';							
	}
}

//basket page end

//payment checkout page
function validatePaymentCheckout(){
	document.frmmember.action = 'onlineCheckout.php';		
	document.frmmember.submit();		
}
//payment checkout page ends here



//forget password page
function  checkEnterForgetPassword(e){ //e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable
	
	if(e && e.which){ //if which property of event object is supported (NN4)
	e = e
	characterCode = e.which //character code is contained in NN4's which property
	}
	else{
	//e = event
	characterCode = e.keyCode //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		validateForgetPassword();
	}
}
function validateForgetPassword(){
	if(EmailValidate(document.frmforgetpassword.member_email,"Email") == false){
		document.frmforgetpassword.member_email.focus();
		return false;
	}
	document.frmforgetpassword.submit();	
}
function validateEnquiry(){
	if(TextValidate(document.frmenquiry.member_name,"Your Name") == false){
		document.frmenquiry.member_name.focus();
		return false;
	}
	if(EmailValidate(document.frmenquiry.member_email,"Your E-mail Address") == false){
		document.frmenquiry.member_email.focus();
		return false;
	}
	if(TextValidate(document.frmenquiry.member_about,"Message Subject") == false){
		document.frmenquiry.member_about.focus();
		return false;
	}
	if(TextValidate(document.frmenquiry.member_details,"Your Message") == false){
		document.frmenquiry.member_details.focus();
		return false;
	}
	document.frmenquiry.submit();	
}

//forget password page ends here

//customer myaccount page
function validateMyAccount(){	
	if(TextValidate(document.frmmyaccount.customer_firstname,"First Name")==false) {
		document.frmmyaccount.customer_firstname.focus();		
		return false;	
	}	
	if(isAlpha_space(document.frmmyaccount.customer_firstname.value) == false){
		alert("Please don't enter special character for First Name");
		document.frmmyaccount.customer_firstname.focus();			
		return false;
	}	
	if(trimAll(document.frmmyaccount.customer_firstname.value).length > 75){
		alert("First Name should be less than or equal to 75 characters");
		document.frmmyaccount.customer_firstname.focus();
		document.frmmyaccount.customer_firstname.select();
		return false;		
	}	
	if(TextValidate(document.frmmyaccount.customer_surname,"Surname")==false) {
		document.frmmyaccount.customer_surname.focus();		
		return false;	
	}	
	if(isAlpha_space(document.frmmyaccount.customer_surname.value) == false){
		alert("Please don't enter special character for Surname");
		document.frmmyaccount.customer_surname.focus();			
		return false;
	}	
	if(trimAll(document.frmmyaccount.customer_surname.value).length > 75){
		alert("Surname should be less than or equal to 75 characters");
		document.frmmyaccount.customer_surname.focus();
		document.frmmyaccount.customer_surname.select();
		return false;		
	}		
	if(TextValidate(document.frmmyaccount.customer_telephone,"Telephone Number")==false) {
		document.frmmyaccount.customer_telephone.focus();		
		return false;	
	}	
	if(trimAll(document.frmmyaccount.customer_telephone.value).length > 20){
		alert("Telephone Number should be less than or equal to 20 characters");
		document.frmmyaccount.customer_telephone.focus();
		document.frmmyaccount.customer_telephone.select();
		return false;		
	}		
	if(trimAll(document.frmmyaccount.customer_mobile.value).length > 20){
		alert("Mobile Number should be less than or equal to 20 characters");
		document.frmmyaccount.customer_mobile.focus();
		document.frmmyaccount.customer_mobile.select();
		return false;		
	}			
	if(EmailValidate(document.frmmyaccount.customer_email,"Email")==false) {
		document.frmmyaccount.customer_email.focus();		
		return false;	
	}	
	if(trimAll(document.frmmyaccount.customer_email.value).length > 100){
		alert("Email should be less than or equal to 100 characters");
		document.frmmyaccount.customer_email.focus();
		document.frmmyaccount.customer_email.select();
		return false;		
	}		
	if(TextValidate(document.frmmyaccount.customer_invoice_address,"Address")==false) {
		document.frmmyaccount.customer_invoice_address.focus();		
		return false;	
	}	
	if(trimAll(document.frmmyaccount.customer_invoice_address.value).length > 255){
		alert("Address should be less than or equal to 255 characters");
		document.frmmyaccount.customer_invoice_address.focus();
		document.frmmyaccount.customer_invoice_address.select();
		return false;		
	}		
	
	if(TextValidate(document.frmmyaccount.customer_town,"Town")==false) {
		document.frmmyaccount.customer_town.focus();		
		return false;	
	}	
	if(trimAll(document.frmmyaccount.customer_town.value).length > 100){
		alert("Town should be less than or equal to 100 characters");
		document.frmmyaccount.customer_town.focus();
		document.frmmyaccount.customer_town.select();
		return false;		
	}		
	if(SelectValidate(document.frmmyaccount.customer_country,"Country")==false) {
		document.frmmyaccount.customer_country.focus();		
		return false;	
	}	
	if(document.frmmyaccount.customer_county.type == 'text'){
		if(TextValidate(document.frmmyaccount.customer_county,"State")==false) {
			document.frmmyaccount.customer_county.focus();		
			return false;	
		}	
		if(!isNaN(document.frmmyaccount.customer_county.value)){
			alert("Please don't enter number for State");
			document.frmmyaccount.customer_county.focus();			
			return false;
		}		
	}else{
		if(SelectValidate(document.frmmyaccount.customer_county,"State")==false) {
			document.frmmyaccount.customer_county.focus();		
			return false;	
		}			
	}	
	if(TextValidate(document.frmmyaccount.customer_zip_code,"Zip Code")==false) {
		document.frmmyaccount.customer_zip_code.focus();		
		return false;	
	}	
	if(trimAll(document.frmmyaccount.customer_zip_code.value).length > 20){
		alert("Zip Code should be less than or equal to 20 characters");
		document.frmmyaccount.customer_zip_code.focus();
		document.frmmyaccount.customer_zip_code.select();
		return false;		
	}		
	/*if(TextValidate(document.frmmyaccount.customer_del_firstname,"First Name")==false) {
		document.frmmyaccount.customer_del_firstname.focus();		
		return false;	
	}	
	if(isAlpha_space(document.frmmyaccount.customer_del_firstname.value) == false){
		alert("Please don't enter special character for First Name");
		document.frmmyaccount.customer_del_firstname.focus();			
		return false;
	}	
	if(trimAll(document.frmmyaccount.customer_del_firstname.value).length > 75){
		alert("First Name should be less than or equal to 75 characters");
		document.frmmyaccount.customer_del_firstname.focus();
		document.frmmyaccount.customer_del_firstname.select();
		return false;		
	}
	if(TextValidate(document.frmmyaccount.customer_del_surname,"Surname")==false) {
		document.frmmyaccount.customer_del_surname.focus();		
		return false;	
	}
	if(isAlpha_space(document.frmmyaccount.customer_del_surname.value) == false){
		alert("Please don't enter special character for Surname");
		document.frmmyaccount.customer_del_surname.focus();			
		return false;
	}	
	if(trimAll(document.frmmyaccount.customer_del_surname.value).length > 75){
		alert("Surname should be less than or equal to 75 characters");
		document.frmmyaccount.customer_del_surname.focus();
		document.frmmyaccount.customer_del_surname.select();
		return false;		
	}	
	if(TextValidate(document.frmmyaccount.customer_del_telephone,"Telephone Number")==false) {
		document.frmmyaccount.customer_del_telephone.focus();		
		return false;	
	}	
	if(trimAll(document.frmmyaccount.customer_del_telephone.value).length > 20){
		alert("Telephone Number should be less than or equal to 20 characters");
		document.frmmyaccount.customer_del_telephone.focus();
		document.frmmyaccount.customer_del_telephone.select();
		return false;		
	}	
	if(trimAll(document.frmmyaccount.customer_del_mobile.value).length > 20){
		alert("Mobile Number should be less than or equal to 20 characters");
		document.frmmyaccount.customer_del_mobile.focus();
		document.frmmyaccount.customer_del_mobile.select();
		return false;		
	}		
	if(EmailValidate(document.frmmyaccount.customer_del_email,"Email")==false) {
		document.frmmyaccount.customer_del_email.focus();		
		return false;	
	}	
	if(trimAll(document.frmmyaccount.customer_del_email.value).length > 100){
		alert("Email should be less than or equal to 100 characters");
		document.frmmyaccount.customer_del_email.focus();
		document.frmmyaccount.customer_del_email.select();
		return false;		
	}		
	if(TextValidate(document.frmmyaccount.customer_del_address,"Address")==false) {
		document.frmmyaccount.customer_del_address.focus();		
		return false;	
	}	
	if(trimAll(document.frmmyaccount.customer_del_address.value).length > 255){
		alert("Address should be less than or equal to 255 characters");
		document.frmmyaccount.customer_del_address.focus();
		document.frmmyaccount.customer_del_address.select();
		return false;		
	}	
	if(TextValidate(document.frmmyaccount.customer_del_town,"Town")==false) {
		document.frmmyaccount.customer_del_town.focus();		
		return false;	
	}	
	if(trimAll(document.frmmyaccount.customer_del_town.value).length > 100){
		alert("Town should be less than or equal to 100 characters");
		document.frmmyaccount.customer_del_town.focus();
		document.frmmyaccount.customer_del_town.select();
		return false;		
	}	
	if(document.frmmyaccount.customer_del_county_input && document.getElementById("dividstateselect").style.display == 'none'){
		if(TextValidate(document.frmmyaccount.customer_del_county_input,"State")==false) {
			document.frmmyaccount.customer_del_county_input.focus();		
			return false;	
		}
		if(isAlpha_space(document.frmmyaccount.customer_del_county_input.value) == false){
			alert("Please don't enter special charecter and number for State");
			document.frmmyaccount.customer_del_county_input.focus();			
			return false;
		}			
		if(trimAll(document.frmmyaccount.customer_del_county_input.value).length > 100){
			alert("State should be less than or equal to 100 characters");
			document.frmmyaccount.customer_del_county_input.focus();
			document.frmmyaccount.customer_del_county_input.select();
			return false;		
		}	
	}
	if(document.frmmyaccount.customer_del_county_select &&  document.getElementById("dividstateinput").style.display == 'none'){
		if(SelectValidate(document.frmmyaccount.customer_del_county_select,"State")==false) {
			document.frmmyaccount.customer_del_county_select.focus();		
			return false;	
		}			
	}	
	if(SelectValidate(document.frmmyaccount.customer_del_country,"Country")==false) {
		document.frmmyaccount.customer_del_country.focus();		
		return false;	
	}		
	if(TextValidate(document.frmmyaccount.customer_del_zip_code,"Zip Code")==false) {
		document.frmmyaccount.customer_del_zip_code.focus();		
		return false;	
	}	
	if(trimAll(document.frmmyaccount.customer_del_zip_code.value).length > 20){
		alert("Zip Code should be less than or equal to 20 characters");
		document.frmmyaccount.customer_del_zip_code.focus();
		document.frmmyaccount.customer_del_zip_code.select();
		return false;		
	}	*/
	document.frmmyaccount.submit();		
}
function  checkEnterMyaccount(e){ //e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable
	
	if(e && e.which){ //if which property of event object is supported (NN4)
	e = e
	characterCode = e.which //character code is contained in NN4's which property
	}
	else{
	//e = event
	characterCode = e.keyCode //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		validateMyAccount();
	}
}
function callDeliveryAddressMyaccount(chkObj){
	if(chkObj.checked == true){
		document.frmmyaccount.customer_del_firstname.value = trimAll(document.frmmyaccount.customer_firstname.value);
		document.frmmyaccount.customer_del_surname.value = trimAll(document.frmmyaccount.customer_surname.value);
		document.frmmyaccount.customer_del_telephone.value = trimAll(document.frmmyaccount.customer_telephone.value);
		document.frmmyaccount.customer_del_mobile.value = trimAll(document.frmmyaccount.customer_mobile.value);		
		document.frmmyaccount.customer_del_email.value = trimAll(document.frmmyaccount.customer_email.value);
		document.frmmyaccount.customer_del_address.value = trimAll(document.frmmyaccount.customer_invoice_address.value);
		document.frmmyaccount.customer_del_town.value = trimAll(document.frmmyaccount.customer_town.value);	
		document.frmmyaccount.customer_del_county.value = trimAll(document.frmmyaccount.customer_county.value);
		document.frmmyaccount.customer_del_country.value = trimAll(document.frmmyaccount.customer_country.value);		
		document.frmmyaccount.customer_del_zip_code.value = trimAll(document.frmmyaccount.customer_zip_code.value);			
	}else{
		document.frmmyaccount.customer_del_firstname.value = trimAll(document.frmmyaccount.customer_firstname_hid.value);
		document.frmmyaccount.customer_del_surname.value = trimAll(document.frmmyaccount.customer_surname_hid.value);
		document.frmmyaccount.customer_del_telephone.value = trimAll(document.frmmyaccount.customer_telephone_hid.value);
		document.frmmyaccount.customer_del_mobile.value = trimAll(document.frmmyaccount.customer_mobile_hid.value);		
		document.frmmyaccount.customer_del_email.value = trimAll(document.frmmyaccount.customer_email_hid.value);
		document.frmmyaccount.customer_del_address.value = trimAll(document.frmmyaccount.customer_invoice_address_hid.value);
		document.frmmyaccount.customer_del_town.value = trimAll(document.frmmyaccount.customer_town_hid.value);	
		document.frmmyaccount.customer_del_county.value = trimAll(document.frmmyaccount.customer_county_hid.value);
		document.frmmyaccount.customer_del_country.value = trimAll(document.frmmyaccount.customer_country_hid.value);		
		document.frmmyaccount.customer_del_zip_code.value = trimAll(document.frmmyaccount.customer_zip_code_hid.value);
	}	
}
//customer myaccount page ends here