function popup(url){
	window.open(url,'popup','width=350,height=150,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function ConfirmDelete(varURL, name){
	if (confirm("Are you sure you want to delete " + name + "?")){
		window.open(varURL, "_top");
		return true;
	}else{
		return false;
	}
}

function toggleHide(obj){
	var el = document.getElementById(obj);
	if(el.style.display == "block"){
		el.style.display = "none";
	}else{
		el.style.display = "block";
	}
}


function change_lang(lang){ 
	var the_url = window.location.href;
  if(the_url.match("lang=")){
		the_url = the_url.replace("&lang=en","");
		the_url = the_url.replace("&lang=ga","");
	}
  if(the_url.indexOf("?") < 1){
  	the_url = the_url + "?lang=" + lang;
  }else{
    the_url = the_url + "&lang=" + lang;    
  }
  window.location.href = the_url
}








 	 	$(document).ready(function(){
	  	$("#side_cart").load("ajax.php?action=show_cart");
	 	
 			if($("#sign_in")){
   			$("#sign_in").click(function () {
	      		$("#sign_in_selected").slideDown("slow")
	      		$("#create_account_selected").slideUp("slow");
    		});
    	}
			if($("#create_account")){    		
				$("#create_account").click(function () {
					$("#sign_in_selected").slideUp("slow");
      		$("#create_account_selected").slideDown("slow");
				});
   		}
  		if($("#login").text()){	$("#login").validate();	}
      if($("#create").text()){	$("#create").validate();	}
    
      if($("#no_account").text()){	$("#no_account").validate();	}
       if($("#comments").text()){	$("#comments").validate();	}
      if($("#get_payment_details").text()){	$("#get_payment_details").validate();	}
      if($("#checkoutbasket").text()){	$("#checkoutform").validate();	}
			
		});
		
		function showCart(){
			$("#side_cart").load("ajax.php?action=show_cart");
			$("#more_products").load("ajax.php?action=show_cart");
			$("#main_display").load("ajax.php?action=show_cart");
		
		}		
		function addToCart(id,sub_id){
			$("#side_cart").load("ajax.php?action=add_to_cart&product_id="+id+"&subproduct_id="+sub_id, null, function(){	$("#added").fadeOut(2500); });
		  $("#added").fadeOut("slow");
		}
		function removeFromCart(id,sub_id,remove,pic){
			$("#side_cart").load("ajax.php?action=remove_from_cart&product_id="+id+"&subproduct_id="+sub_id, null, function(){$("#removed").fadeOut(2500); });
			$("#verify_products").load("ajax.php?action=remove_from_cart&product_id="+id+"&subproduct_id="+sub_id+"&otherarea=true", null, function(){	$("#removed").fadeOut(2500); });
			$("#more_products").load("ajax.php?action=remove_from_cart&product_id="+id+"&subproduct_id="+sub_id+"&mainarea=true", null, function(){	$("#removed").fadeOut(2500); });	
		}
		function emptyCart(){
			$("#side_cart").load("ajax.php?action=empty_cart");
		}		
    	
    	
		function clipBasket(){
			if($("#clip_basket").css("position") == "fixed"){
				$("#clip_basket").css("position","static");
				$("#clip").attr("src","images/pin_up.gif");
			}else{
				$("#clip_basket").css("position","fixed");
				$("#clip").attr("src","images/pin_down.gif");
			}
		}		
		
		
		
		function useBillingAsDelivery(){
			if($("#use_billing_as_delivery:checked").val() == 1){
				$("#delivery_firstname").val($("#billing_firstname").val());
				$("#delivery_surname").val($("#billing_surname").val());
				$("#delivery_address").val($("#billing_address").val());
				
				$("#delivery_postcode").val($("#billing_postcode").val());
				$("#delivery_county").val($("#billing_county").val());
				$("#delivery_country").val($("#billing_country").val());
				$("#delivery_phone1").val($("#billing_phone1").val());
				$("#delivery_phone2").val($("#billing_phone2").val());
				$("#delivery_email").val($("#billing_email").val());
			}else{
				$("#delivery_firstname").val("");
				$("#delivery_surname").val("");
				$("#delivery_address").val("");
				$("#delivery_postcode").val("");
				$("#delivery_county").val("");
				$("#delivery_country").val("Ireland");
				$("#delivery_phone1").val("");
				$("#delivery_phone2").val("");
				$("#delivery_email").val("");		
			}
		}
		
