// When you click a tyre, wheel or wrench in the banner
function swapBannerSelection(item) {
	$("#bannerNav .selected").removeClass("selected");
	$("#bannerNav .bn-" + item).addClass("selected");
	$("#banner .split-side").css("display","none");
	$("#banner .split-side.bs-" + item).css("display","block");
}



// Four easy steps tutorial

$(document).ready( function(){ 
	$('.foureasysteps-tutorial ul').innerfade({
		speed: 'slow', timeout: 2000 
	}); 
});


// PNG Fix
$(document).ready(function(){
	$('#banner, #cmdSubmit, a.btn').pngFix();
});


// Logo Cycle
$(document).ready(function(){
	$('#scroller-sidebar').innerfade({ containerheight: "164px" });
});

function generateBanner(){
	var randbanner = Math.floor(Math.random()*10) + 1;
	var bannerimg = "<img src='/images/common/store_ban" + randbanner + ".jpg' alt='' />";
	$("#store_banner").html(bannerimg);
}

function removeJSParameter() {
	// remove the js=false attribute from the store listings since we have javascript
	$(".par-stores li a, #store-list li a").each(function() {
		var curHref = $(this).attr("href");
		$(this).attr("href", curHref.replace(/[&\?]?js=false/gi, ""));
	});
	
	// also redirect if we have javascript
	if (document.location.href.match(/[\?&]js=false/)) {
		document.location.href = document.location.href.replace(/[\?&]js=false/, '');
	}
}

$(document).ready(function() {
	removeJSParameter();	
});

function checkEnter(e, fn){ //e is event object passed from function invocation
	var characterCode; // literal character code will be stored in this variable

	if(e && e.which){ //if which property of event object is supported (NN4)
		e = e;
		characterCode = e.which; //character code is contained in NN4's which property
	} else {
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}

	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		fn();
		return false;
	} else {
		return true;
	}
}