jQuery(document).ready(function(){
	jQuery("body").append("<div style='display:none;'>Visitor Country Code: " + visitor_cc + "</div>");
	jQuery("body").append("<div style='display:none;'>Site URL: " + document.location.hostname + "</div>");
	jQuery("body").append("<div style='display:none;'>Site URL: " + document.location + "</div>");
	jQuery("body").append("<div style='display:none;'>Site URL Pathname: " + document.location.pathname + "</div>");
	
	if(document.location.hostname == "www.kennettonline.com"){
		// US user found on the UK domain.
		if(visitor_cc === "US"){
			document.location = "http://us.kennettonline.com" + document.location.pathname;
		}
	}else if(document.location.hostname == "us.kennettonline.com"){
		// Non-US user found on the US domain.
		if(visitor_cc !== "US"){
			document.location = "http://www.kennettonline.com" + document.location.pathname;
		}
	}else{
		// jQuery("body").append("<div style='display:none;'>Switch fell through.</div>");
	}
	
	// Populating the header area with cart statistics
	jQuery.get("/OrderRetrievev2.aspx",function(data,textStatus,jqHXR){
		var $html = jQuery(data);
		
		if($html.find(".cart-statistics").length > 0){
			var number_of_items = $html.find(".cart-statistics-number-of-items").text();
			var cart_total = $html.find(".cart-statistics-total").text();
			
			var cart_summary = number_of_items + " item(s), Total: " + cart_total + " View Cart";
			
			jQuery("#cornertop .cart-summary").text(cart_summary);
		}
	});

	jQuery(".click-clear").each(function(){
		jQuery(this).data("placeholder",jQuery(this).val());
		
		jQuery(this).bind({
			focus: function(){
				if(jQuery(this).val() === jQuery(this).data("placeholder")){
					jQuery(this).val("");
				}
			},
			blur: function(){
				if(jQuery(this).val() === ""){
					jQuery(this).val(jQuery(this).data("placeholder"));
				}
			}
		});
	});
});
