
$(function() {			   	 	 	
	 $('ul.navigationComplete li ul').hide();	 
		 $('ul.navigationComplete li a.selected').parent('li').children('ul').show();	
 	$('ul.navigationComplete li ul li a.selected').parent('li').parent('ul').parent('li').children('ul').show(); 	

	
	 $('html').removeClass("js");	 
});


 $('#tncLink').attr("href","#");
 $('#tncLink').removeAttr("target");
 $('#confirmOrder').attr("disabled","disabled");


$('.addCartButton').click(function() {
  
 $.post("/add2cart", $(this.form).serialize());
  $(this).attr("disabled",true);
  alert('Product added to cart.');
    location.reload();
  
});

$('.removeButton').click(function() {
 // alert('remove item.' + $(this).attr('alt'));
 //$.get("/add2cart/remove/" +  $(this).attr('alt'));
 $(location).attr('href','/add2cart/remove/' +  $(this).attr('alt'));
  
});

$('#tncCheckbox').click(function() {
if ($('#tncCheckbox').attr('checked')) {
  $('#confirmOrder').removeAttr("disabled");	
} else {
	
  $('#confirmOrder').attr("disabled","disabled");		
}
					 
});

$('#tncLink').click(function() {
								   
$('#tnc').load('/shop_terms_and_conditions #tncContent');
$('#tnc').toggle(250);
/*
$.load("/shop_terms_and_conditions #tncContent", function(data){
   //alert("Data Loaded: " + data);
   $('#tnc').html(data);
   $('#tnc').toggle(250);
 });
*/

//$('#tnc').toggle(250);
return false;

});


$('#emptyCart').click(function() {
  alert('Cart has been emptied.');
 // $.get("/add2cart/empty");
  $(location).attr('href','/add2cart/empty');
  
});

						




// run when checkbox is clicked to synchronise the delivery details with billing details
function IsDeliverySame_clicked() {

    if (document.customerform.IsDeliverySame.checked) {

        document.customerform.DeliveryFirstnames.value = document.customerform.BillingFirstnames.value;
        document.customerform.DeliveryFirstnames.className = "inputBoxDisable";
        document.customerform.DeliveryFirstnames.disabled = true;
        
        document.customerform.DeliverySurname.value = document.customerform.BillingSurname.value;
        document.customerform.DeliverySurname.className = "inputBoxDisable";
        document.customerform.DeliverySurname.disabled = true;
        
        document.customerform.DeliveryAddress1.value = document.customerform.BillingAddress1.value;
        document.customerform.DeliveryAddress1.className = "inputBoxDisable";
        document.customerform.DeliveryAddress1.disabled = true;

        document.customerform.DeliveryAddress2.value = document.customerform.BillingAddress2.value;
        document.customerform.DeliveryAddress2.className = "inputBoxDisable";
        document.customerform.DeliveryAddress2.disabled = true; 

        document.customerform.DeliveryCity.value =  document.customerform.BillingCity.value;
        document.customerform.DeliveryCity.className = "inputBoxDisable";
        document.customerform.DeliveryCity.disabled = true;

        document.customerform.DeliveryPostCode.value = document.customerform.BillingPostCode.value ;
        document.customerform.DeliveryPostCode.className = "inputBoxDisable";
        document.customerform.DeliveryPostCode.disabled = true;

        document.customerform.DeliveryCountry.value = document.customerform.BillingCountry.value;
        document.customerform.DeliveryCountry.className = "inputBoxDisable";
        document.customerform.DeliveryCountry.disabled = true;


        document.customerform.DeliveryPhone.value = document.customerform.BillingPhone.value;
        document.customerform.DeliveryPhone.className = "inputBoxDisable";
        document.customerform.DeliveryPhone.disabled = true;
		
        document.customerform.DeliveryEmail.value = document.customerform.CustomerEmail.value;
        document.customerform.DeliveryEmail.className = "inputBoxDisable";
        document.customerform.DeliveryEmail.disabled = true;		
		
		document.customerform.DeliveryConfirmEmail.value = document.customerform.CustomerEmail.value;
        document.customerform.DeliveryConfirmEmail.className = "inputBoxDisable";
        document.customerform.DeliveryConfirmEmail.disabled = true;	
		
    } 
    else 
    {
        document.customerform.DeliveryFirstnames.disabled = false;
        document.customerform.DeliveryFirstnames.className = "inputBoxEnable";
		
        document.customerform.DeliveryFirstnames.focus();
        document.customerform.DeliverySurname.disabled = false;
        document.customerform.DeliverySurname.className = "inputBoxEnable";
		
        document.customerform.DeliveryAddress1.disabled = false;
        document.customerform.DeliveryAddress1.className = "inputBoxEnable";
		
        document.customerform.DeliveryAddress2.disabled = false;
        document.customerform.DeliveryAddress2.className = "inputBoxEnable";
		
        document.customerform.DeliveryCity.disabled = false;
        document.customerform.DeliveryCity.className = "inputBoxEnable";
		
        document.customerform.DeliveryPostCode.disabled = false;
        document.customerform.DeliveryPostCode.className = "inputBoxEnable";
		
        document.customerform.DeliveryCountry.disabled = false;
        document.customerform.DeliveryCountry.className = "inputBoxEnable";

        document.customerform.DeliveryPhone.disabled = false;
        document.customerform.DeliveryPhone.className = "inputBoxEnable";
		
		document.customerform.DeliveryEmail.disabled = false;
        document.customerform.DeliveryEmail.className = "inputBoxEnable";

		document.customerform.DeliveryConfirmEmail.disabled = false;
        document.customerform.DeliveryConfirmEmail.className = "inputBoxEnable";
    }
}


function submitForm(formName, navigateValue) {
	if (navigateValue != null && navigateValue != "") {
		document.forms[formName].navigate.value = navigateValue;
	}
    document.forms[formName].submit();
}



