jQuery('html').addClass('hideJSContent');

jQuery(document).ready(function(){
								
/* ***********************************
 * Style application for cross browser 
 *********************************** */
	
	/* Style all input the same */
	jQuery('input[type="text"]').addClass('styledInput');
	
	/* Minicart show new items */	
    jQuery('#viewbasket').click(function() {
        jQuery('#minicart-items').slideDown().animate({opacity: 1.0}, 5000).slideUp();
        return false;
    });

	/* Preselect the first shipping method which should only Royal Mail */
	jQuery('#ShippingMethodID1').attr('checked', 'checked');
	
	/* Wrap addtobasket buttons with custom HTML for styling purposes */
	jQuery('.AddToCartButton').wrap('<div class="atb-wrapper"><span></span></div>');
	
	jQuery('.AddToCartButton').css('color', '#FFFFFF');
	
	jQuery('input[type="text"]').focus(function() {
		jQuery(this).addClass('userFocused');
	}).blur(function(){
		jQuery(this).removeClass('userFocused');
	});
	
	
/* ****************
 * Custom functions
 **************** */
	/* Hide product enlarge functions until we have proper large images */
	//var largeURL = jQuery(".product-image > div > div > a > img").attr('src');
	//jQuery(".product-image > div > div > a").attr('href', largeURL)
	
	jQuery(".product-image > div > div > a > img").removeAttr('onclick').removeAttr('style');
	//jQuery(".product-image > div > div > a").hide();
	
	jQuery("input#shippingEqBilling:checked").each(function(){
		jQuery('#tblShippingInfoBox table input, #tblShippingInfoBox table select').addClass('disabledInput');
	});
	
	/* Update delivery values to billing values on blur of input if checkbox is checked */
	jQuery("#tblBillingInfo input").keyup(function(){
		if (jQuery("input#shippingEqBilling").is(':checked'))
		{
			// Checked, copy values
			jQuery("input#ShippingFirstName").val(jQuery("input#BillingFirstName").val());
			jQuery("input#ShippingLastName").val(jQuery("input#BillingLastName").val());
			jQuery("input#ShippingPhone").val(jQuery("input#BillingPhone").val());
			jQuery("input#ShippingCompany").val(jQuery("input#BillingCompany").val());
			jQuery("input#ShippingAddress1").val(jQuery("input#BillingAddress1").val());
			jQuery("input#ShippingAddress2").val(jQuery("input#BillingAddress2").val());
			jQuery("input#ShippingCity").val(jQuery("input#BillingCity").val());
			jQuery("input#ShippingZip").val(jQuery("input#BillingZip").val());			
		}
	});
	
	/* Update delivery values to billing values on change of select option if checkbox is checked */
	jQuery("#tblBillingInfo select").change(function(){
		if (jQuery("input#shippingEqBilling").is(':checked'))
		{
			var test = jQuery("#BillingState option:selected").val();
			jQuery("#ShippingState").val(test).attr('selected', 'selected');
			
		}
	});
	
	/* UPDATE delivery values to billing values on click of checkbox or CLEAR values on uncheck */
	jQuery("input#shippingEqBilling").click(function(){
		if (jQuery("input#shippingEqBilling").is(':checked'))
		{	
			jQuery('#tblShippingInfoBox table input, #tblShippingInfoBox table select').addClass('disabledInput');
			// Checked, copy values
			jQuery("input#ShippingFirstName").val(jQuery("input#BillingFirstName").val());
			jQuery("input#ShippingLastName").val(jQuery("input#BillingLastName").val());
			jQuery("input#ShippingPhone").val(jQuery("input#BillingPhone").val());
			jQuery("input#ShippingCompany").val(jQuery("input#BillingCompany").val());
			jQuery("input#ShippingAddress1").val(jQuery("input#BillingAddress1").val());
			jQuery("input#ShippingAddress2").val(jQuery("input#BillingAddress2").val());
			jQuery("input#ShippingCity").val(jQuery("input#BillingCity").val());
			jQuery("input#ShippingZip").val(jQuery("input#BillingZip").val());
			var selectedCounty = jQuery("#BillingState option:selected").val();
			jQuery("#ShippingState").val(selectedCounty).attr('selected', 'selected');
		}
		else
		{
			jQuery('#tblShippingInfoBox table input, #tblShippingInfoBox table select').removeClass('disabledInput');
			jQuery("input#ShippingFirstName").val("");
			jQuery("input#ShippingLastName").val("");
			jQuery("input#ShippingPhone").val("");
			jQuery("input#ShippingCompany").val("");
			jQuery("input#ShippingAddress1").val("");
			jQuery("input#ShippingAddress2").val("");
			jQuery("input#ShippingCity").val("");
			jQuery("input#ShippingZip").val("");
		}
	});
	
	/* Add alert to Add to basket click! Needs further testing for kit products. I.e. button should be disabled if required fields arent compelte yet.
	atbTest = jQuery('<div class="link-button-wrapper"><span><a href="#" id="alt-atb">SUBMIT TEST</a></span></div>');
	atbTest.bind('click', function(){
		jQuery('#passback').show();
		return false;
	});
	
	jQuery('.AddToCartButton').after(atbTest);	
	jQuery('.AddToCartButton').css({'visibility': 'hidden', 'position': 'absolute', 'left': '-8000px'});
	
	jQuery("#continueShop").click(function(){
		jQuery('input.AddToCartButton').trigger('click');
		return false
	});*/
	
});