﻿jQuery.noConflict();

function addJavascript(jsname,pos) {
	var th = document.getElementsByTagName(pos)[0];
	var s = document.createElement('script');
	s.setAttribute('type','text/javascript');
	s.setAttribute('src',jsname);
	th.appendChild(s);
}

//addJavascript('/js/thickbox.js','head');



jQuery(document).ready(function() {
    
	jQuery(".BreadcrumbItem:first").css({"background":"none","padding-left":"0px"});
	
	// remove right margin from homepage category
	jQuery(".homepageCategory:last").css({"margin-right":"0px"});

	// login overlay show/hide
	jQuery(".loginOverlay").click(function(){
		jQuery(".overlay267x182").show();
		return false;
	});
	
	jQuery(".overlayClose").click(function(){
		jQuery(".overlay267x182").hide();
		return false;
	});

	//even columns where thin column has background
	if (jQuery(".columnThick").height() > jQuery(".columnThinBg").height()) {
		jQuery(".columnThinBg").css({'height': jQuery(".columnThick").height()});
	}
	else
	{
		jQuery(".columnThick").css({'height': jQuery(".columnThinBg").height()});
	}
	
	// category page layout
	jQuery(".categoryProduct:even").css({"margin-right":"14px"});
	
	// products page layout
	var something = 1;
	while( something < jQuery(".product").size()){
	  jQuery(".product:eq("+something+")").css({"margin-left":"28px","margin-right":"28px"});
	  something=something+3;
	}
	
	//product page thumbnail
	
	jQuery(".productImageVariant img").hover(function(){
		jQuery(this).css({"border-color":"#b4132e"});												  
	}, 
    function () {
        jQuery(this).css({"border-color":"#dce3ee"});
    });
	
	//product page extra info
	jQuery(".productInfoExtraMenu a").click(function(){
		
		hideProductExtra();
		jQuery(this).parent().addClass("selected");
		if(jQuery(this).hasClass("specification"))
		{
			jQuery(".productInfoSpec").css("display","block");
		}
		else
		{
			jQuery(".productInfoFeatures").css("display","block");
		}
		return false;	
	});
	
	function hideProductExtra()
	{
		jQuery(".productInfoExtraMenu li").removeClass("selected");
		jQuery(".productInfoSpec").css("display","none");
		jQuery(".productInfoFeatures").css("display","none");
	}
	
	//recommended products product detail page
	jQuery(".productRecommendItem:lt(3)").css({"margin-right":"7px"});
	
	//recommended products shopping basket page
	jQuery(".shoppingBasket .productRecommendItem:lt(3)").css({"margin-right":"20px"});
	
	//checkout method
	jQuery(".checkoutMethod:eq(1)").css({"margin-left":"17px","margin-right":"17px"});
	
	//brand
	jQuery(".brand:even").css({"margin-right":"49px"});
	jQuery(".brand:last").css({"border":"none"});
	
	
	
	
	jQuery(".footerUpperInput").blur(function(){
	if (jQuery(this).value == '')
	{
	 jQuery(this).value = 'email address';
	 }
	});
	jQuery(".footerUpperInput").focus(function(){
	if (jQuery(this).value == 'email address')
	{
	jQuery(this).value='';
	}
	});
	
	
});

function validate_form(thisform)
{
	with (thisform)
	{
		if((Name.value == null) || (Name.value == ''))
		{
			alert("Please fill in your name");
			Name.focus();
			return false;
		}
		if((Message.value == null) || (Message.value == ''))
		{
			alert("Please fill in your message");
			Message.focus();
			return false;
		}
		if((Email.value == null) || (Email.value == ''))
		{
			alert("Please fill in your email");
			Email.focus();
			return false;
		}
		if((Email.value.indexOf(".") < 2) || (Email.value.indexOf("@") < 1))
		{
			alert("Email " + Email.value + " has an incorrect format");
			Email.focus();
			return false;
		}
		
	}
}

function validate_form_signup(thisform)
{
	with (thisform)
	{
		if((FirstName.value == null) || (FirstName.value == ''))
		{
			alert("Please fill in your first name");
			FirstName.focus();
			return false;
		}
		if((LastName.value == null) || (LastName.value == ''))
		{
			alert("Please fill in your last name");
			LastName.focus();
			return false;
		}
		if((EmailAddress.value == null) || (EmailAddress.value == ''))
		{
			alert("Please fill in your email");
			EmailAddress.focus();
			return false;
		}
		if((EmailAddress.value.indexOf(".") < 2) || (EmailAddress.value.indexOf("@") < 1))
		{
			alert("Email " + EmailAddress.value + " has an incorrect format");
			EmailAddress.focus();
			return false;
		}
		
	}
}

function querySt(ji) {
hu = window.location.search.substring(1);
gy = hu.split("&");
for (i=0;i<gy.length;i++) {
ft = gy[i].split("=");
if (ft[0] == ji) {
return ft[1];
}
}
}
