/* stop IE6 flicker */
try { document.execCommand("BackgroundImageCache", false, true); } catch(err) {}

// Return true if browser is Internet Explorer and version 6 or earlier
$.IE6Below = function() {
	if ($.browser.msie) {
		try {
			if (ScriptEngineMajorVersion() <= 5 && ScriptEngineMinorVersion() < 7) { // ie 6- only
				return true;
			}
		} catch(err) { return false; };
		return false;
	} else {
		return false;
	};
};





// ** Misc **
// **      **
$(function(){ // (executes when the dom is ready)
	// make logo a link to go back to home page
	$("#logo span").click(function(){
		document.location = "/";
	}).css("cursor","pointer");
	// make any links with rel="external" to open in new windows
	$("a[ @ rel$='external']").click(function(){
		this.target = "_blank";
	});
});



// ** Product detail view related **
// **                             **
$.HideProductDetailsAndMakeClickable = function() {
	$(".large-view-wrapper").each(function (i){
		// hide all tabs except the first
		(i>0) ? $(this).css("display","none") : '';
	});
	$(".thumbnail a").click(function(){
		var productnumber = $(".thumbnail a").index(this);
		$(".large-view-wrapper").each(function (i){
			// hide all tabs except the one we want
			(i==productnumber) ? $(this).css("display","block") : $(this).css("display","none");
		});
		return false;
	});
};



// ** Tabs related **
// **              **
$.HideTabsAndMakeClickable = function() {
	$(".tab").each(function (i){
		// hide all tabs except the first
		(i>0) ? $(this).css("display","none") : '';
	});
	$("#tabs p").click(function(){
		var tabnumber = $("#tabs p").index(this);
		$(".tab").each(function (i){
			// hide all tabs except the one we want
			(i==tabnumber) ? $(this).css("display","block") : $(this).css("display","none");
		});
		$("#tabs p").each(function(i){
			// change tab to active or not
			(i==tabnumber) ? $(this).css("cursor","default").addClass("active") : $(this).css("cursor","pointer").removeClass("active");
		});
	});
};


