function loadProducts(vars){
		
	document.getElementById("products").innerHTML = '<div class="loading"></div>';
	
	$.post("/ajax/products.php", {vars:vars}, function(data) {
		document.getElementById("products").innerHTML = data;
		var script = document.getElementById("script").innerHTML;
		eval(script);
	});
}

function changeCurrency(id){
	
	document.getElementById("products").innerHTML = '<div class="loading"></div>';
	
	$.post("/ajax/products.php", {action:"change_currency",currency_id:id}, function(data) {
		document.getElementById("products").innerHTML = data;
		var script = document.getElementById("script").innerHTML;
		eval(script);
	});
}

function changeCurrencyBasket(id){
	
	$.post("/ajax/change_currency.php", {action:"change_currency",currency_id:id}, function(data) {
		location.reload();
	});
}

function changeCurrencySingle(id,product_id){
	
	document.getElementById("price").innerHTML = "Loading...";
	
	$.post("/ajax/change_currency.php", {currency_id:id,product_id:product_id}, function(data) {
		document.getElementById("price").innerHTML = data;
	});
}

function changeOrder(url,rst){
	
	var n_products = document.forms['products'].n_products.value;
	var start = document.forms['products'].start.value;
	
	if(rst==1){start=0;}
	
	location.href = url+'?n_products='+n_products+'&start='+start;
}

function changeOrderButton(which,url){
	
	if(which=="previous"){
		document.forms['products'].start.selectedIndex = document.forms['products'].start.selectedIndex-1;
	}
	
	if(which=="next"){
		document.forms['products'].start.selectedIndex = document.forms['products'].start.selectedIndex+1;
	}
	
	changeOrder(url,0);
	
}

function addToBasket(product_id,b){
	
	$.post("/ajax/add_to_basket.php", {product_id:product_id}, function(data) {
												  
		b.innerHTML = "Product Added";
		b.className = "button_small button_disabled";
		b.href = "javascript:;";
		
		document.getElementById("basket_count").innerHTML = data;
	});
}

function password(){

var bad=0;
	
	if(document.forms['password'].email.value==""){bad=1;}
	
if(bad==1){
		alert(alerts['alert_valid_email']);
		return;
	}
	
	document.forms['password'].submit();
}


function register(){
	
	var bad1=0;
	var bad2=0;
	var bad3=0;


	if(document.forms['register'].f_name.value==""){bad1=1;}
	if(document.forms['register'].l_name.value==""){bad1=1;}
	if(document.forms['register'].address_1.value==""){bad1=1;}
	if(document.forms['register'].town.value==""){bad1=1;}
	if(document.forms['register'].postcode.value==""){bad1=1;}
		if(document.forms['register'].email.value==""){bad1=1;}
	
	if(document.forms['register'].country.selectedIndex==0){bad2=1;}
	//if(document.forms['checkout'].country.value==""){bad=1;}
	
	if ((document.forms['register'].password_1.value != '') && (document.forms['register'].password_2.value != document.forms['register'].password_1.value))
{
   bad3=1; 

 }


	
	if(bad1==1){
		alert(alerts['alert_fields']);
		return;
	}
	if(bad2==1){
		alert(alerts['alert_country']);
document.forms['register'].country.focus();
		return;
	}
	if(bad3==1){
	alert(alerts['alert_password']);
 
document.forms['register'].password_1.focus();
		return;
	}
	
	$.post("/check-email.php",{ email:document.forms['register'].email.value } ,function(data)
        {
		  if(data=='yes') //if email not avaiable
		  {
		  	alert(alerts['alert_email_exists']);
 			document.forms['register'].email.focus();
			return;
		  }else{
			  document.forms['register'].submit();
		  }
				
    });
	
	//document.forms['checkout'].submit();
}

function update_user(){
	
	var bad1=0;
	var bad2=0;
	var bad3=0;


	if(document.forms['update_user'].f_name.value==""){bad1=1;}
	if(document.forms['update_user'].l_name.value==""){bad1=1;}
	if(document.forms['update_user'].address_1.value==""){bad1=1;}
	if(document.forms['update_user'].town.value==""){bad1=1;}
	if(document.forms['update_user'].postcode.value==""){bad1=1;}
	if(document.forms['update_user'].email.value==""){bad1=1;}
	if(document.forms['update_user'].country.selectedIndex==0){bad2=1;}
	
	
	if(bad1==1){
		alert(alerts['alert_fields']);
		return;
	}
	if(bad2==1){
		alert(alerts['alert_country']);
		document.forms['update_user'].country.focus();
		return;
	}
	if(bad3==1){
		alert(alerts['alert_password']);
		document.forms['update_user'].password_1.focus();
		return;
	}
	
	$.post("/check_email_update_user.php",{ email:document.forms['update_user'].email.value } ,function(data2)
        {
			  
		  if(data2=='yes') //if email not avaiable
		  {
		  	alert(alerts['alert_email_exists']);
 			document.forms['update_user'].email.focus();
			return;
		  }else{
			  document.forms['update_user'].submit();
		  }
				
    });
	
	//document.forms['checkout'].submit();
}

////////////
