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('#ctl00_PageContent_tblShippingInfoBox table input, #ctl00_PageContent_tblShippingInfoBox table select').addClass('disabledInput');
	});
	
	/* Update delivery values to billing values on blur of input if checkbox is checked */
	jQuery("#ctl00_PageContent_tblBillingInfo input").keyup(function() {
		if (jQuery("input#shippingEqBilling").is(':checked'))
		{
			// Checked, copy values
		    jQuery("input#ctl00_PageContent_ShippingFirstName").val(jQuery("input#ctl00_PageContent_BillingFirstName").val());
		    jQuery("input#ctl00_PageContent_ShippingLastName").val(jQuery("input#ctl00_PageContent_BillingLastName").val());
		    jQuery("input#ctl00_PageContent_ShippingPhone").val(jQuery("input#ctl00_PageContent_BillingPhone").val());
		    jQuery("input#ctl00_PageContent_ShippingCompany").val(jQuery("input#ctl00_PageContent_BillingCompany").val());
		    jQuery("input#ctl00_PageContent_ShippingAddress1").val(jQuery("input#ctl00_PageContent_BillingAddress1").val());
		    jQuery("input#ctl00_PageContent_ShippingAddress2").val(jQuery("input#ctl00_PageContent_BillingAddress2").val());
		    jQuery("input#ctl00_PageContent_ShippingCity").val(jQuery("input#ctl00_PageContent_BillingCity").val());
		    jQuery("input#ctl00_PageContent_ShippingZip").val(jQuery("input#ctl00_PageContent_BillingZip").val());			
		}
	});
	
	/* Update delivery values to billing values on change of select option if checkbox is checked */
	jQuery("#ctl00_PageContent_tblBillingInfo select").change(function() {
		if (jQuery("input#shippingEqBilling").is(':checked'))
		{
		    var test = jQuery("#ctl00_PageContent_BillingState option:selected").val();
			jQuery("#ctl00_PageContent_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('#ctl00_PageContent_tblShippingInfoBox table input, #ctl00_PageContent_tblShippingInfoBox table select').addClass('disabledInput');
			// Checked, copy values
			jQuery("input#ctl00_PageContent_ShippingFirstName").val(jQuery("input#ctl00_PageContent_BillingFirstName").val());
			jQuery("input#ctl00_PageContent_ShippingLastName").val(jQuery("input#ctl00_PageContent_BillingLastName").val());
			jQuery("input#ctl00_PageContent_ShippingPhone").val(jQuery("input#ctl00_PageContent_BillingPhone").val());
			jQuery("input#ctl00_PageContent_ShippingCompany").val(jQuery("input#ctl00_PageContent_BillingCompany").val());
			jQuery("input#ctl00_PageContent_ShippingAddress1").val(jQuery("input#ctl00_PageContent_BillingAddress1").val());
			jQuery("input#ctl00_PageContent_ShippingAddress2").val(jQuery("input#ctl00_PageContent_BillingAddress2").val());
			jQuery("input#ctl00_PageContent_ShippingCity").val(jQuery("input#ctl00_PageContent_BillingCity").val());
			jQuery("input#ctl00_PageContent_ShippingZip").val(jQuery("input#ctl00_PageContent_BillingZip").val());
			var selectedCounty = jQuery("#ctl00_PageContent_BillingState option:selected").val();
			jQuery("#ctl00_PageContent_ShippingState").val(selectedCounty).attr('selected', 'selected');
		}
		else
		{
		    jQuery('#ctl00_PageContent_tblShippingInfoBox table input, #ctl00_PageContent_tblShippingInfoBox table select').removeClass('disabledInput');
			jQuery("input#ctl00_PageContent_ShippingFirstName").val("");
			jQuery("input#ctl00_PageContent_ShippingLastName").val("");
			jQuery("input#ctl00_PageContent_ShippingPhone").val("");
			jQuery("input#ctl00_PageContent_ShippingCompany").val("");
			jQuery("input#ctl00_PageContent_ShippingAddress1").val("");
			jQuery("input#ctl00_PageContent_ShippingAddress2").val("");
			jQuery("input#ctl00_PageContent_ShippingCity").val("");
			jQuery("input#ctl00_PageContent_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
	});*/
	
});
