// JavaScript Document

//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();
	}
}

//To assign the image name and open the specific div tag for fixing the problem of shadow box : product details page
function callNormalimage(imagename,divid,colorcode){
	//document.getElementById("imgidnormalimage").src = 'productimages/normal_'+imagename;
	for(i=1 ; i<=5 ; i++){
		if(i == divid){		
			if(document.getElementById("dividcolor"+i)){	
				document.getElementById("dividcolor"+i).style.display = '';
			}
			if(document.getElementById("dividcolorclass"+i)){	
				document.getElementById("dividcolorclass"+i).setAttribute('class','color'+i+'a');
			}			
		}else{
			if(document.getElementById("dividcolor"+i)){
				document.getElementById("dividcolor"+i).style.display = 'none';
			}
			if(document.getElementById("dividcolorclass"+i)){	
				document.getElementById("dividcolorclass"+i).setAttribute('class','color'+i);
			}			
		}
	}
	
	//To animate the color picker box
	var newSrc = 'productimages/normal_'+imagename;	
	if(document.frmproductdetails.product_image.value != imagename){	
		/*$('#color'+divid).fadeTo('fast', 1, function(){	$(this).fadeTo('slow', 0, function(){ $(this).fadeTo('slow', 1, function(){}); }); })
		$('#imgidnormalimage').fadeOut('slow', function(){
			$(this).attr('src', newSrc);
			$(this).load(function() {
			  $(this).fadeIn('slow')
			})
			;
		});	*/
		document.getElementById('imgidnormalimage').src=newSrc;
	}
	document.frmproductdetails.product_color.value = colorcode;
	document.frmproductdetails.product_image.value = imagename;	
}

//To validate search field (search box validation for all page )
function validateSearch(){
	if(TextValidate(document.frmsearch.product_search,"keyword in Search Products") == false){
		document.frmsearch.product_search.focus();
		return false;
	}
	document.frmsearch.submit();
}

//For Search box validation in all page
function  checkEnterSearch(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)
		validateSearch();
	}
}

function validateAdvanceSearch(){
	if(trimAll(document.frmadvancesearch.product_category.value) == '' && trimAll(document.frmadvancesearch.product_search.value) == ''){
		alert("You should specify any one of the search criteria");		
		document.frmadvancesearch.product_category.focus();
		return false;
	}
	document.frmadvancesearch.submit();	
}
//login Page starts here
function validateMainLogin(){
	if(EmailValidate(document.frmmainlogin.customer_email,"Email") == false){
		document.frmmainlogin.customer_email.focus();
		return false;
	}
	if(TextValidate(document.frmmainlogin.customer_password,"Password") == false){
		document.frmmainlogin.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.frmregistration.customer_firstname,"First Name")==false) {
		document.frmregistration.customer_firstname.focus();		
		return false;	
	}	
	if(isAlpha_space(document.frmregistration.customer_firstname.value) == false){
		alert("Please don't enter special character for First Name");
		document.frmregistration.customer_firstname.focus();			
		return false;
	}	
	if(trimAll(document.frmregistration.customer_firstname.value).length > 75){
		alert("First Name should be less than or equal to 75 characters");
		document.frmregistration.customer_firstname.focus();
		document.frmregistration.customer_firstname.select();
		return false;		
	}
	if(TextValidate(document.frmregistration.customer_surname,"Surname")==false) {
		document.frmregistration.customer_surname.focus();		
		return false;	
	}	
	if(isAlpha_space(document.frmregistration.customer_surname.value) == false){
		alert("Please don't enter special character for Surname");
		document.frmregistration.customer_surname.focus();			
		return false;
	}		
	if(trimAll(document.frmregistration.customer_surname.value).length > 75){
		alert("Surname should be less than or equal to 75 characters");
		document.frmregistration.customer_surname.focus();
		document.frmregistration.customer_surname.select();
		return false;		
	}	
	if(TextValidate(document.frmregistration.customer_telephone,"Telephone Number")==false) {
		document.frmregistration.customer_telephone.focus();		
		return false;	
	}	
	if(trimAll(document.frmregistration.customer_telephone.value).length > 20){
		alert("Telephone Number should be less than or equal to 20 characters");
		document.frmregistration.customer_telephone.focus();
		document.frmregistration.customer_telephone.select();
		return false;		
	}	
	if(trimAll(document.frmregistration.customer_mobile.value).length > 20){
		alert("Mobile Number should be less than or equal to 20 characters");
		document.frmregistration.customer_mobile.focus();
		document.frmregistration.customer_mobile.select();
		return false;		
	}		
	if(EmailValidate(document.frmregistration.customer_email,"Email")==false) {
		document.frmregistration.customer_email.focus();		
		return false;	
	}	
	if(trimAll(document.frmregistration.customer_email.value).length > 100){
		alert("Email should be less than or equal to 100 characters");
		document.frmregistration.customer_email.focus();
		document.frmregistration.customer_email.select();
		return false;		
	}		
	if(TextValidate(document.frmregistration.customer_invoice_address,"Address")==false) {
		document.frmregistration.customer_invoice_address.focus();		
		return false;	
	}	
	if(trimAll(document.frmregistration.customer_invoice_address.value).length > 255){
		alert("Address should be less than or equal to 255 characters");
		document.frmregistration.customer_invoice_address.focus();
		document.frmregistration.customer_invoice_address.select();
		return false;		
	}	
	if(TextValidate(document.frmregistration.customer_town,"Town")==false) {
		document.frmregistration.customer_town.focus();		
		return false;	
	}	
	if(trimAll(document.frmregistration.customer_town.value).length > 100){
		alert("Town should be less than or equal to 100 characters");
		document.frmregistration.customer_town.focus();
		document.frmregistration.customer_town.select();
		return false;		
	}	
	if(SelectValidate(document.frmregistration.customer_country,"Country")==false) {
		document.frmregistration.customer_country.focus();		
		return false;	
	}	
	if(document.frmregistration.customer_county.type == 'text'){
		if(TextValidate(document.frmregistration.customer_county,"State")==false) {
			document.frmregistration.customer_county.focus();		
			return false;	
		}	
		if(!isNaN(document.frmregistration.customer_county.value)){
			alert("Please don't enter number for State");
			document.frmregistration.customer_county.focus();			
			return false;
		}		
	}else{
		if(SelectValidate(document.frmregistration.customer_county,"State")==false) {
			document.frmregistration.customer_county.focus();		
			return false;	
		}			
	}
	if(TextValidate(document.frmregistration.customer_zip_code,"Zip Code")==false) {
		document.frmregistration.customer_zip_code.focus();		
		return false;	
	}	
	if(trimAll(document.frmregistration.customer_zip_code.value).length > 20){
		alert("Zip Code should be less than or equal to 20 characters");
		document.frmregistration.customer_zip_code.focus();
		document.frmregistration.customer_zip_code.select();
		return false;		
	}	
	/*if(TextValidate(document.frmregistration.customer_del_firstname,"First Name")==false) {
		document.frmregistration.customer_del_firstname.focus();		
		return false;	
	}	
	if(isAlpha_space(document.frmregistration.customer_del_firstname.value) == false){
		alert("Please don't enter special character for First Name");
		document.frmregistration.customer_del_firstname.focus();			
		return false;
	}	
	if(trimAll(document.frmregistration.customer_del_firstname.value).length > 75){
		alert("First Name should be less than or equal to 75 characters");
		document.frmregistration.customer_del_firstname.focus();
		document.frmregistration.customer_del_firstname.select();
		return false;		
	}
	if(TextValidate(document.frmregistration.customer_del_surname,"Surname")==false) {
		document.frmregistration.customer_del_surname.focus();		
		return false;	
	}	
	if(isAlpha_space(document.frmregistration.customer_del_surname.value) == false){
		alert("Please don't enter special character for Surname");
		document.frmregistration.customer_del_surname.focus();			
		return false;
	}		
	if(trimAll(document.frmregistration.customer_del_surname.value).length > 75){
		alert("Surname should be less than or equal to 75 characters");
		document.frmregistration.customer_del_surname.focus();
		document.frmregistration.customer_del_surname.select();
		return false;		
	}	
	if(TextValidate(document.frmregistration.customer_del_telephone,"Telephone Number")==false) {
		document.frmregistration.customer_del_telephone.focus();		
		return false;	
	}	
	if(trimAll(document.frmregistration.customer_del_telephone.value).length > 20){
		alert("Telephone Number should be less than or equal to 20 characters");
		document.frmregistration.customer_del_telephone.focus();
		document.frmregistration.customer_del_telephone.select();
		return false;		
	}	
	if(trimAll(document.frmregistration.customer_del_mobile.value).length > 20){
		alert("Mobile Number should be less than or equal to 20 characters");
		document.frmregistration.customer_del_mobile.focus();
		document.frmregistration.customer_del_mobile.select();
		return false;		
	}		
	if(EmailValidate(document.frmregistration.customer_del_email,"Email")==false) {
		document.frmregistration.customer_del_email.focus();		
		return false;	
	}	
	if(trimAll(document.frmregistration.customer_del_email.value).length > 100){
		alert("Email should be less than or equal to 100 characters");
		document.frmregistration.customer_del_email.focus();
		document.frmregistration.customer_del_email.select();
		return false;		
	}		
	if(TextValidate(document.frmregistration.customer_del_address,"Address")==false) {
		document.frmregistration.customer_del_address.focus();		
		return false;	
	}	
	if(trimAll(document.frmregistration.customer_del_address.value).length > 255){
		alert("Address should be less than or equal to 255 characters");
		document.frmregistration.customer_del_address.focus();
		document.frmregistration.customer_del_address.select();
		return false;		
	}	
	if(TextValidate(document.frmregistration.customer_del_town,"Town")==false) {
		document.frmregistration.customer_del_town.focus();		
		return false;	
	}	
	if(trimAll(document.frmregistration.customer_del_town.value).length > 100){
		alert("Town should be less than or equal to 100 characters");
		document.frmregistration.customer_del_town.focus();
		document.frmregistration.customer_del_town.select();
		return false;		
	}	
	if(document.frmregistration.customer_del_county_input && document.getElementById("dividstateselect").style.display == 'none'){
		if(TextValidate(document.frmregistration.customer_del_county_input,"State")==false) {
			document.frmregistration.customer_del_county_input.focus();		
			return false;	
		}
		if(isAlpha_space(document.frmregistration.customer_del_county_input.value) == false){
			alert("Please don't enter special charecter and number for State");
			document.frmregistration.customer_del_county_input.focus();			
			return false;
		}				
		if(trimAll(document.frmregistration.customer_del_county_input.value).length > 100){
			alert("State should be less than or equal to 100 characters");
			document.frmregistration.customer_del_county_input.focus();
			document.frmregistration.customer_del_county_input.select();
			return false;		
		}	
	}
	if(document.frmregistration.customer_del_county_select &&  document.getElementById("dividstateinput").style.display == 'none'){
		if(SelectValidate(document.frmregistration.customer_del_county_select,"State")==false) {
			document.frmregistration.customer_del_county_select.focus();		
			return false;	
		}			
	}
	if(SelectValidate(document.frmregistration.customer_del_country,"Country")==false) {
		document.frmregistration.customer_del_country.focus();		
		return false;	
	}	
	if(TextValidate(document.frmregistration.customer_del_zip_code,"Zip Code")==false) {
		document.frmregistration.customer_del_zip_code.focus();		
		return false;	
	}	
	if(trimAll(document.frmregistration.customer_del_zip_code.value).length > 20){
		alert("Zip Code should be less than or equal to 20 characters");
		document.frmregistration.customer_del_zip_code.focus();
		document.frmregistration.customer_del_zip_code.select();
		return false;		
	}	*/		
	if(TextValidate(document.frmregistration.customer_password,"Password")==false) {
		document.frmregistration.customer_password.focus();		
		return false;	
	}	
	if(trimAll(document.frmregistration.customer_password.value).length > 100){
		alert("Password should be less than or equal to 100 characters");
		document.frmregistration.customer_password.focus();
		document.frmregistration.customer_password.select();
		return false;		
	}	
	if(trimAll(document.frmregistration.customer_password.value).length < 6)
	{
		alert("The Password should be atleast 6 characters !");
		document.frmregistration.customer_password.focus();	
		return false;
	}
	if(TextValidate(document.frmregistration.customer_confirm_password,"Confirm Password")==false) {
		document.frmregistration.customer_confirm_password.focus();		
		return false;	
	}	
	if(trimAll(document.frmregistration.customer_confirm_password.value).length > 100){
		alert("Confirm Password should be less than or equal to 100 characters");
		document.frmregistration.customer_confirm_password.focus();
		document.frmregistration.customer_confirm_password.select();
		return false;		
	}
	if(trimAll(document.frmregistration.customer_confirm_password.value).length <6)
	{
		alert("The Confirm Password should be atleast 6 characters !");
		document.frmregistration.customer_confirm_password.focus();	
		return false;
	}		

	if (trimAll(document.frmregistration.customer_password.value) != trimAll(document.frmregistration.customer_confirm_password.value) )
	{
		alert("The Password and Confirm Password do not match !");
		document.frmregistration.customer_confirm_password.focus();	   	
		return false;
	}	
	if(document.frmregistration.customer_agree.checked == false){
		alert("You should agree to the Terms & Conditions");
		document.frmregistration.customer_agree.focus();
		return false;
	}
	document.frmregistration.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();
	}
}
function validateProductDetails(){
	if(SelectValidate(document.frmproductdetails.product_measurement,"Size")==false) {
		document.frmproductdetails.product_measurement.focus();		
		return false;	
	}	
	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();
}

//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?tmpshopcart_id="+tmpshopcart_id+"&tmpshopcart_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.frmcheckout.customer_firstname,"First Name")==false) {
		document.frmcheckout.customer_firstname.focus();		
		return false;	
	}
	if(isAlpha_space(document.frmcheckout.customer_firstname.value) == false){
		alert("Please don't enter special character for First Name");
		document.frmcheckout.customer_firstname.focus();			
		return false;
	}	
	if(trimAll(document.frmcheckout.customer_firstname.value).length > 75){
		alert("First Name should be less than or equal to 75 characters");
		document.frmcheckout.customer_firstname.focus();
		document.frmcheckout.customer_firstname.select();
		return false;		
	}
	if(TextValidate(document.frmcheckout.customer_surname,"Surname")==false) {
		document.frmcheckout.customer_surname.focus();		
		return false;	
	}	
	if(isAlpha_space(document.frmcheckout.customer_surname.value) == false){
		alert("Please don't enter special character for Surname");
		document.frmcheckout.customer_surname.focus();			
		return false;
	}	
	if(trimAll(document.frmcheckout.customer_surname.value).length > 75){
		alert("Surname should be less than or equal to 75 characters");
		document.frmcheckout.customer_surname.focus();
		document.frmcheckout.customer_surname.select();
		return false;		
	}	
	if(TextValidate(document.frmcheckout.customer_telephone,"Telephone Number")==false) {
		document.frmcheckout.customer_telephone.focus();		
		return false;	
	}	
	if(trimAll(document.frmcheckout.customer_telephone.value).length > 20){
		alert("Telephone Number should be less than or equal to 20 characters");
		document.frmcheckout.customer_telephone.focus();
		document.frmcheckout.customer_telephone.select();
		return false;		
	}	
	if(trimAll(document.frmcheckout.customer_mobile.value).length > 20){
		alert("Mobile Number should be less than or equal to 20 characters");
		document.frmcheckout.customer_mobile.focus();
		document.frmcheckout.customer_mobile.select();
		return false;		
	}					
	if(TextValidate(document.frmcheckout.customer_invoice_address,"Address")==false) {
		document.frmcheckout.customer_invoice_address.focus();		
		return false;	
	}	
	if(trimAll(document.frmcheckout.customer_invoice_address.value).length > 255){
		alert("Address should be less than or equal to 255 characters");
		document.frmcheckout.customer_invoice_address.focus();
		document.frmcheckout.customer_invoice_address.select();
		return false;		
	}	
	if(TextValidate(document.frmcheckout.customer_town,"Town")==false) {
		document.frmcheckout.customer_town.focus();		
		return false;	
	}	
	if(trimAll(document.frmcheckout.customer_town.value).length > 100){
		alert("Town should be less than or equal to 100 characters");
		document.frmcheckout.customer_town.focus();
		document.frmcheckout.customer_town.select();
		return false;		
	}	
	if(SelectValidate(document.frmcheckout.customer_country,"Country")==false) {
		document.frmcheckout.customer_country.focus();		
		return false;	
	}	
	if(document.frmcheckout.customer_county.type == 'text'){
		if(TextValidate(document.frmcheckout.customer_county,"State")==false) {
			document.frmcheckout.customer_county.focus();		
			return false;	
		}	
		if(!isNaN(document.frmcheckout.customer_county.value)){
			alert("Please don't enter number for State");
			document.frmcheckout.customer_county.focus();			
			return false;
		}		
	}else{
		if(SelectValidate(document.frmcheckout.customer_county,"State")==false) {
			document.frmcheckout.customer_county.focus();		
			return false;	
		}			
	}	
	if(TextValidate(document.frmcheckout.customer_zip_code,"Zip Code")==false) {
		document.frmcheckout.customer_zip_code.focus();		
		return false;	
	}	
	if(trimAll(document.frmcheckout.customer_zip_code.value).length > 20){
		alert("Zip Code should be less than or equal to 20 characters");
		document.frmcheckout.customer_zip_code.focus();
		document.frmcheckout.customer_zip_code.select();
		return false;		
	}	
	if(TextValidate(document.frmcheckout.customer_del_firstname,"First Name")==false) {
		document.frmcheckout.customer_del_firstname.focus();		
		return false;	
	}
	if(isAlpha_space(document.frmcheckout.customer_del_firstname.value) == false){
		alert("Please don't enter special character for First Name");
		document.frmcheckout.customer_del_firstname.focus();			
		return false;
	}	
	if(trimAll(document.frmcheckout.customer_del_firstname.value).length > 75){
		alert("First Name should be less than or equal to 75 characters");
		document.frmcheckout.customer_del_firstname.focus();
		document.frmcheckout.customer_del_firstname.select();
		return false;		
	}
	if(TextValidate(document.frmcheckout.customer_del_surname,"Surname")==false) {
		document.frmcheckout.customer_del_surname.focus();		
		return false;	
	}
	if(isAlpha_space(document.frmcheckout.customer_del_surname.value) == false){
		alert("Please don't enter special character for Surname");
		document.frmcheckout.customer_del_surname.focus();			
		return false;
	}	
	if(trimAll(document.frmcheckout.customer_del_surname.value).length > 75){
		alert("Surname should be less than or equal to 75 characters");
		document.frmcheckout.customer_del_surname.focus();
		document.frmcheckout.customer_del_surname.select();
		return false;		
	}	
	if(TextValidate(document.frmcheckout.customer_del_telephone,"Telephone Number")==false) {
		document.frmcheckout.customer_del_telephone.focus();		
		return false;	
	}	
	if(trimAll(document.frmcheckout.customer_del_telephone.value).length > 20){
		alert("Telephone Number should be less than or equal to 20 characters");
		document.frmcheckout.customer_del_telephone.focus();
		document.frmcheckout.customer_del_telephone.select();
		return false;		
	}	
	if(trimAll(document.frmcheckout.customer_del_mobile.value).length > 20){
		alert("Mobile Number should be less than or equal to 20 characters");
		document.frmcheckout.customer_del_mobile.focus();
		document.frmcheckout.customer_del_mobile.select();
		return false;		
	}		
	if(EmailValidate(document.frmcheckout.customer_del_email,"Email")==false) {
		document.frmcheckout.customer_del_email.focus();		
		return false;	
	}	
	if(trimAll(document.frmcheckout.customer_del_email.value).length > 100){
		alert("Email should be less than or equal to 100 characters");
		document.frmcheckout.customer_del_email.focus();
		document.frmcheckout.customer_del_email.select();
		return false;		
	}		
	if(TextValidate(document.frmcheckout.customer_del_address,"Address")==false) {
		document.frmcheckout.customer_del_address.focus();		
		return false;	
	}	
	if(trimAll(document.frmcheckout.customer_del_address.value).length > 255){
		alert("Address should be less than or equal to 255 characters");
		document.frmcheckout.customer_del_address.focus();
		document.frmcheckout.customer_del_address.select();
		return false;		
	}	
	if(TextValidate(document.frmcheckout.customer_del_town,"Town")==false) {
		document.frmcheckout.customer_del_town.focus();		
		return false;	
	}	
	if(trimAll(document.frmcheckout.customer_del_town.value).length > 100){
		alert("Town should be less than or equal to 100 characters");
		document.frmcheckout.customer_del_town.focus();
		document.frmcheckout.customer_del_town.select();
		return false;		
	}	
	if(SelectValidate(document.frmcheckout.customer_del_country,"Country")==false) {
		document.frmcheckout.customer_del_country.focus();		
		return false;	
	}	
	if(document.frmcheckout.customer_del_county.type == 'text'){
		if(TextValidate(document.frmcheckout.customer_del_county,"State")==false) {
			document.frmcheckout.customer_del_county.focus();		
			return false;	
		}	
		if(!isNaN(document.frmcheckout.customer_del_county.value)){
			alert("Please don't enter number for State");
			document.frmcheckout.customer_del_county.focus();			
			return false;
		}		
	}else{
		if(SelectValidate(document.frmcheckout.customer_del_county,"State")==false) {
			document.frmcheckout.customer_del_county.focus();		
			return false;	
		}			
	}			
	if(TextValidate(document.frmcheckout.customer_del_zip_code,"Zip Code")==false) {
		document.frmcheckout.customer_del_zip_code.focus();		
		return false;	
	}	
	if(trimAll(document.frmcheckout.customer_del_zip_code.value).length > 20){
		alert("Zip Code should be less than or equal to 20 characters");
		document.frmcheckout.customer_del_zip_code.focus();
		document.frmcheckout.customer_del_zip_code.select();
		return false;		
	}	
	/*if(document.frmcheckout.customer_agree.checked == false){
		alert("You should agree to the Terms & Conditions");
		document.frmcheckout.customer_agree.focus();
		return false;
	}*/
	document.frmcheckout.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.frmcheckout.customer_del_firstname.value = trimAll(document.frmcheckout.customer_firstname.value);
		document.frmcheckout.customer_del_surname.value = trimAll(document.frmcheckout.customer_surname.value);
		document.frmcheckout.customer_del_telephone.value = trimAll(document.frmcheckout.customer_telephone.value);
		document.frmcheckout.customer_del_mobile.value = trimAll(document.frmcheckout.customer_mobile.value);		
		document.frmcheckout.customer_del_email.value = trimAll(document.frmcheckout.customer_email.value);
		document.frmcheckout.customer_del_address.value = trimAll(document.frmcheckout.customer_invoice_address.value);
		document.frmcheckout.customer_del_town.value = trimAll(document.frmcheckout.customer_town.value);	
		document.frmcheckout.customer_del_country.value = trimAll(document.frmcheckout.customer_country.value);		
		document.frmcheckout.customer_del_zip_code.value = trimAll(document.frmcheckout.customer_zip_code.value);			
		callStateInvoiceBasket(document.frmcheckout.customer_country,'check');	
		
	}else{
		document.frmcheckout.customer_del_firstname.value = trimAll(document.frmcheckout.customer_firstname_hid.value);
		document.frmcheckout.customer_del_surname.value = trimAll(document.frmcheckout.customer_surname_hid.value);
		document.frmcheckout.customer_del_telephone.value = trimAll(document.frmcheckout.customer_telephone_hid.value);
		document.frmcheckout.customer_del_mobile.value = trimAll(document.frmcheckout.customer_mobile_hid.value);		
		document.frmcheckout.customer_del_email.value = trimAll(document.frmcheckout.customer_email_hid.value);
		document.frmcheckout.customer_del_address.value = trimAll(document.frmcheckout.customer_invoice_address_hid.value);
		document.frmcheckout.customer_del_town.value = trimAll(document.frmcheckout.customer_town_hid.value);	
		document.frmcheckout.customer_del_country.value = trimAll(document.frmcheckout.customer_country_hid.value);		
		document.frmcheckout.customer_del_zip_code.value = trimAll(document.frmcheckout.customer_zip_code_hid.value);
		callStateInvoiceBasket(document.frmcheckout.customer_country_hid,'uncheck');		
	}
}
//invoice start here
var basketHTTP;
function callStateInvoiceBasket(country_id,flagaction) {
    url =  "ajax_get_states_basket.php?country_id="+country_id.value+"&flagaction="+flagaction;
	basketHTTP = ajaxfunctin();					
	basketHTTP.open("GET",url,true); 
	basketHTTP.send(null); 
	basketHTTP.onreadystatechange=getStatusInvoiveBasket;				
}
function getStatusInvoiveBasket() { 
	if (basketHTTP.readyState == 4) { 	
		var resObj = basketHTTP.responseText; 
		arr_flag_all = resObj.split("-----");				
		if(arr_flag_all[0] == 1){		
			tdObj = document.getElementById("tdidstatedel");
			tdObj.removeChild(document.getElementById('customer_del_county'));
			textObj = document.createElement('input');
			textObj.setAttribute('type', 'text');
			textObj.setAttribute('name', 'customer_del_county');
			textObj.setAttribute('id', 'customer_del_county');	
			textObj.setAttribute('class', 'invoiceTextBox');				
			tdObj.appendChild(textObj);					
		}else if(arr_flag_all[0] != 0 && arr_flag_all[0] != 1){
			tdObj = document.getElementById("tdidstatedel");
			tdObj.removeChild(document.getElementById('customer_del_county'));
			textObj = document.createElement('select');
			textObj.setAttribute('name', 'customer_del_county');
			textObj.setAttribute('id', 'customer_del_county');	
			textObj.setAttribute('class', 'invoiceListBox');			
			tdObj.appendChild(textObj);	
					
			arr_states_all = arr_flag_all[0].split("$$$");									
			var opt = document.createElement("option");	
			document.getElementById("customer_del_county").options.add(opt);			
			opt.text = 'Select State...';
			opt.value = '0';										
			for(i = 0 ; i < arr_states_all.length ; i++){
				arr_states_details = arr_states_all[i].split('@@@');
				var opt = document.createElement("option");					
				document.getElementById("customer_del_county").options.add(opt);		
				opt.text = arr_states_details[1];
				opt.value = arr_states_details[0];		
			}		
		}
		if(arr_flag_all[1] == 'check'){
			document.frmcheckout.customer_del_county.value = trimAll(document.frmcheckout.customer_county.value);			
		}else{			
			document.frmcheckout.customer_del_county.value = trimAll(document.frmcheckout.customer_county_hid.value);		
		}
	}
} 
//invoice end here
//basket page end

//payment checkout page
function validatePaymentCheckout(){
	if(document.getElementById("payment_pay_by_online").checked == true){
		document.frmcheckout.action = 'onlineCheckout.php';		
	}else if(document.getElementById("payment_pay_on_delivery").checked == true){
		document.frmcheckout.action = 'offlineCheckout.php';		
	}else{
		alert("Please choose payment type");
		document.getElementById("payment_pay_by_online").focus();
		return false;
	}
	if(document.frmcheckout.customer_agree.checked == false){
		alert("You should agree to the Terms & Conditions");
		document.frmcheckout.customer_agree.focus();
		return false;
	}	
	document.frmcheckout.submit();		
}
//payment checkout page ends here

//Invite friend page
function inviteFriend(){
	
	if(document.frminvitefriend.invite_name){	
		if(TextValidate(document.frminvitefriend.invite_name,"Your Name") == false){
			document.frminvitefriend.invite_name.focus();
			return false;
		}	
	}
	if(document.frminvitefriend.invite_mail){	
		if(EmailValidate(document.frminvitefriend.invite_mail,"Your E-Mail") == false){
			document.frminvitefriend.invite_mail.focus();
			return false;
		}	
	}	
	
	if(EmailValidate(document.frminvitefriend.invite_mail1,"E-Mail 1") == false){
		document.frminvitefriend.invite_mail1.focus();
		return false;
	}
	if(trimAll(document.frminvitefriend.invite_mail2.value) != ''){	
		if(EmailValidate(document.frminvitefriend.invite_mail2,"E-Mail 2") == false){
			document.frminvitefriend.invite_mail2.focus();
			return false;
		}	
	}
	if(trimAll(document.frminvitefriend.invite_mail3.value) != ''){	
		if(EmailValidate(document.frminvitefriend.invite_mail3,"E-Mail 3") == false){
			document.frminvitefriend.invite_mail3.focus();
			return false;
		}	
	}	
	if(trimAll(document.frminvitefriend.invite_mail4.value) != ''){	
		if(EmailValidate(document.frminvitefriend.invite_mail4,"E-Mail 4") == false){
			document.frminvitefriend.invite_mail4.focus();
			return false;
		}	
	}
	if(trimAll(document.frminvitefriend.invite_mail5.value) != ''){	
		if(EmailValidate(document.frminvitefriend.invite_mail5,"E-Mail 5") == false){
			document.frminvitefriend.invite_mail5.focus();
			return false;
		}	
	}	
	var optionvalues=new Array(new Array(document.getElementById("invite_mail1"),"E-Mail 1"),new Array(document.getElementById("invite_mail2"),"E-Mail 2"),new Array(document.getElementById("invite_mail3"),"E-Mail 3"),new Array(document.getElementById("invite_mail4"),"E-Mail 4"),new Array(document.getElementById("invite_mail5"),"E-Mail 5"));	
	if(comparevaluesasequal(optionvalues) == false){
		return false;
	}	
	if(TextValidate(document.frminvitefriend.invite_message,"Message") == false){
		document.frminvitefriend.invite_message.focus();
		return false;
	}	
	document.frminvitefriend.submit();
}
//Invite friend page starts here

//get in touch page
function validateGetInTouch(){
	if(document.frmgetintouch.getintouch_name){	
		if(TextValidate(document.frmgetintouch.getintouch_name,"Your Name") == false){
			document.frmgetintouch.getintouch_name.focus();
			return false;
		}	
	}
	if(document.frmgetintouch.getintouch_email){	
		if(EmailValidate(document.frmgetintouch.getintouch_email,"Your E-mail") == false){
			document.frmgetintouch.getintouch_email.focus();
			return false;
		}	
	}	
	
	if(TextValidate(document.frmgetintouch.getintouch_enquiry_about,"data in Enquiry About field") == false){
		document.frmgetintouch.getintouch_enquiry_about.focus();
		return false;
	}
	if(TextValidate(document.frmgetintouch.getintouch_enquiry_details,"Enquiry Details") == false){
		document.frmgetintouch.getintouch_enquiry_details.focus();
		return false;
	}
	if(TextValidate(document.frmgetintouch.txtcaptchacode,"Security Code") == false){
		document.frmgetintouch.txtcaptchacode.focus();
		return false;
	}	
	if(document.frmgetintouch.txtcaptchacode.value != ""){
		checkCode(document.frmgetintouch.txtcaptchacode.value);
		return false;
	}		
	document.frmgetintouch.submit();	
}
var captchaHTTP;
function checkCode(thecode) {
    url =  "captcheck.php?code="+thecode;
	captchaHTTP = ajaxfunctin();					
	captchaHTTP.open("GET",url,true); 
	captchaHTTP.send(null); 
	captchaHTTP.onreadystatechange=getStatusInTouch;				
}
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 getStatusInTouch() { 
	if (captchaHTTP.readyState == 4) { 	
		var showElements = captchaHTTP.responseText; 
		if(showElements == "N") { 
			alert('The entered Security Code is not correct. Please try again'); 
			document.frmgetintouch.txtcaptchacode.value=''; 
			document.frmgetintouch.txtcaptchacode.focus(); 
			return false;
		}else if(showElements == "Y"){
			document.frmgetintouch.txtflag.value='success';
			document.frmgetintouch.action = "getInTouch.php";
			document.frmgetintouch.submit();
		}else if(showElements == "SE"){
			alert('Your session has expired.Please enter Security Code again');
			document.frmgetintouch.action = "getInTouch.php";
			document.frmgetintouch.submit();		
		}
	}
} 
//get in touch 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.customer_email,"Email") == false){
		document.frmforgetpassword.customer_email.focus();
		return false;
	}
	document.frmforgetpassword.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

//customer change password page
function  checkEnterChangePassword(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)
		validateChangePassword();
	}
}
function validateChangePassword(){
	if(TextValidate(document.frmchangepassword.customer_old_password,"Old Password") == false){
		document.frmchangepassword.customer_old_password.focus();
		return false;
	}
	if(TextValidate(document.frmchangepassword.customer_password,"Password") == false){
		document.frmchangepassword.customer_password.focus();
		return false;
	}
	if(TextValidate(document.frmchangepassword.customer_confirm_password,"Confirm Password") == false){
		document.frmchangepassword.customer_confirm_password.focus();
		return false;
	}
	if(trimAll(document.frmchangepassword.customer_password.value).length <6)
	{
		alert("Password should be atleast 6 characters !");
		document.frmchangepassword.customer_password.focus();	
		return false;
	}		
	if(trimAll(document.frmchangepassword.customer_confirm_password.value).length <6)
	{
		alert("Confirm Password should be atleast 6 characters !");
		document.frmchangepassword.customer_confirm_password.focus();	
		return false;
	}
	if (trimAll(document.frmchangepassword.customer_password.value) != trimAll(document.frmchangepassword.customer_confirm_password.value) )
	{
		alert("Password and Confirm Password do not match !");
		document.frmchangepassword.customer_confirm_password.focus();	   	
		return false;
	}		
	document.frmchangepassword.submit();	
}
//ends here

//newsletter subscribe
function  checkEnterSubscribe(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)
		callSubscribe();
	}
}
function callSubscribe(){
	if(EmailValidate(document.frmsubscribe.newsletter_email,"Signup for Email Updates") == false){
		document.frmsubscribe.newsletter_email.focus();
		return false;
	}
	document.frmsubscribe.submit();
}

/** common for login, myaccount and basket checout page **/
//deleivery start here
var deliveryHTTP;
function callStateDelivery(country_id) {
    url =  "ajax_get_states.php?country_id="+country_id.value;
	deliveryHTTP = ajaxfunctinstate();					
	deliveryHTTP.open("GET",url,true); 
	deliveryHTTP.send(null); 
	deliveryHTTP.onreadystatechange=getStatusDelivery;				
}
function ajaxfunctinstate()
{
	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 getStatusDelivery() { 
	if (deliveryHTTP.readyState == 4) { 	
		var resObj = deliveryHTTP.responseText; 				
		if(resObj == 1){		
			tdObj = document.getElementById("tdidstatedel");
			tdObj.removeChild(document.getElementById('customer_del_county'));
			textObj = document.createElement('input');
			textObj.setAttribute('type', 'text');
			textObj.setAttribute('name', 'customer_del_county');
			textObj.setAttribute('id', 'customer_del_county');	
			textObj.setAttribute('class', 'invoiceTextBox');			
			tdObj.appendChild(textObj);					
		}else if(resObj != 0 && resObj != 1){
			tdObj = document.getElementById("tdidstatedel");
			tdObj.removeChild(document.getElementById('customer_del_county'));
			textObj = document.createElement('select');
			textObj.setAttribute('name', 'customer_del_county');
			textObj.setAttribute('id', 'customer_del_county');	
			textObj.setAttribute('class', 'invoiceListBox');			
			tdObj.appendChild(textObj);	
					
			arr_states_all = resObj.split("$$$");									
			var opt = document.createElement("option");	
			document.getElementById("customer_del_county").options.add(opt);			
			opt.text = 'Select State...';
			opt.value = '0';										
			for(i = 0 ; i < arr_states_all.length ; i++){
				arr_states_details = arr_states_all[i].split('@@@');
				var opt = document.createElement("option");					
				document.getElementById("customer_del_county").options.add(opt);		
				opt.text = arr_states_details[1];
				opt.value = arr_states_details[0];		
			}		
		}		
	}
} 
//deliver end here
function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=1;i--)
	{
		selectbox.remove(i);
	}
}
//invoice start here
var invoiceHTTP;
function callStateInvoice(country_id) {
    url =  "ajax_get_states.php?country_id="+country_id.value;
	invoiceHTTP = ajaxfunctin();					
	invoiceHTTP.open("GET",url,true); 
	invoiceHTTP.send(null); 
	invoiceHTTP.onreadystatechange=getStatusInvoive;				
}
function getStatusInvoive() { 
	if (invoiceHTTP.readyState == 4) { 	
		var resObj = invoiceHTTP.responseText; 					
		if(resObj == 1){		
			tdObj = document.getElementById("tdidstate");
			tdObj.removeChild(document.getElementById('customer_county'));
			textObj = document.createElement('input');
			textObj.setAttribute('type', 'text');
			textObj.setAttribute('name', 'customer_county');
			textObj.setAttribute('id', 'customer_county');	
			textObj.setAttribute('class', 'invoiceTextBox');			
			tdObj.appendChild(textObj);					
		}else if(resObj != 0 && resObj != 1){
			tdObj = document.getElementById("tdidstate");
			tdObj.removeChild(document.getElementById('customer_county'));
			textObj = document.createElement('select');
			textObj.setAttribute('name', 'customer_county');
			textObj.setAttribute('id', 'customer_county');	
			textObj.setAttribute('class', 'invoiceListBox');			
			tdObj.appendChild(textObj);	
					
			arr_states_all = resObj.split("$$$");									
			var opt = document.createElement("option");	
			document.getElementById("customer_county").options.add(opt);			
			opt.text = 'Select State...';
			opt.value = '0';										
			for(i = 0 ; i < arr_states_all.length ; i++){
				arr_states_details = arr_states_all[i].split('@@@');
				var opt = document.createElement("option");					
				document.getElementById("customer_county").options.add(opt);		
				opt.text = arr_states_details[1];
				opt.value = arr_states_details[0];		
			}		
		}		
	}
} 
//invoice end here
/** common for login, myaccount and basket checout page end here**/