function saveQuantity() { jQuery.cookie('quantity', jQuery("#quantity").val(), { expires: 7 }); }
function addToCart() { jQuery('#checkout').css('display', 'block'); jQuery('#cart').css('display', 'none'); }

var triggered = false;
var focusdraw = false;


function pop_up(page){
	window.open(page,"_new","toolbar=no,location=no,menubar=no,status=no,scrollbars=yes,resizeable=yes,width=400,height=500");
}
	


/* There is something messed up in here that I didn't have time to fix. Please look at this */

jQuery(document).ready(function() {

	setTimeout(function() { 
		if(!triggered) { 
			jQuery('input#fname').parent().parent().addClass("drawfocus"); 
			focusdraw = true;
		}}, 5000);
	
		
	if(jQuery.cookie('quantity') == "" || jQuery.cookie('quantity') == null) {
		jQuery("#itemquantity").val(1);
		quantityChanged();
	}
	else {
		//alert(jQuery.cookie('quantity'));
		jQuery("#itemquantity").val(jQuery.cookie('quantity'));
		updatePrices();
	}
});


jQuery(document).ready(function() {
								
	
								
	jQuery('#add_insurance').click(function() {
		var checked = jQuery('#add_insurance').attr('checked'); 
		var total =  jQuery('#totalhidden').val().substr(1);
		var insurance =  jQuery('#insurancehidden').val().substr(1);
		
		if(checked) {
			jQuery('#insurance').val("£" +insurance);
			jQuery('#total').val("£" +total)
			updatePrices();
		
		} else {
			jQuery('#insurance').val("£" + "0.00");
			//jQuery('total').val(jQuery('#cost').val());
			total = (parseFloat(total) - parseFloat(insurance)).toFixed(2);
			jQuery('#total').val("£" +total)
			updatePricesOnCheck();
		}
	}); 

	jQuery('input.text, select').focus(function() {
		triggered = true;								
		
		/* Remove focus puller if active  */
		if(focusdraw) {
			jQuery('input#fname').parent().parent().removeClass("drawfocus");
		}
		
		jQuery(this).parent().parent().addClass("active");
		jQuery(this).animate({ backgroundColor: '#b1b1b1' }, 250);
	}).blur(function() {
		jQuery(this).parent().parent().removeClass("active");
		jQuery(this).animate({ backgroundColor: '#cfd2d2' }, 250);
	});
});
