// <![CDATA[
$(function() {
		
		//Hide the tabbed content areas
		$("#content div.tab-content").hide();
		
		//Rework the hrefs on the tab links so that they do NOT have an an actual corresponding anchor.
		//This will prevent the page from trying to jump to the corresponding area. Sneaky.
		$("body#printers-page #tab1-link a").attr("href", "#printer-amazing-speed");
		$("body#printers-page #tab2-link a").attr("href", "#printer-laser-alternative");
		$("body#printers-page #tab3-link a").attr("href", "#printer-ink-technology");
		$("body#printers-page #tab4-link a").attr("href", "#printer-news-articles");
		$("body#printers-page #tab5-link a").attr("href", "#printer-eco-features");
		$("body#projectors-page #tab1-link a").attr("href", "#projector-market-leader");
		$("body#projectors-page #tab2-link a").attr("href", "#projector-three-lcd");
		$("body#projectors-page #tab3-link a").attr("href", "#projector-accessories");
		$("body#scanners-page #tab1-link a").attr("href", "#scanner-why-buy");
		$("body#scanners-page #tab2-link a").attr("href", "#scanner-epson-solutions");
		$("body#scanners-page #tab3-link a").attr("href", "#scanner-product-compare");
		$("body#scanners-page #tab4-link a").attr("href", "#scanner-software");
		
		//Get the current hash of the page
		var currentHash = window.location.hash.substr(1);
		
		//Map hash to tab #1
		if (currentHash=="printer-amazing-speed" || currentHash=="projector-market-leader" || currentHash=="scanner-why-buy" || currentHash=="") {
			$("#tab-nav").attr("class", "").addClass("tab1active");
			$("#tab1-content").show();
		}
		//Map hash to tab #2
		if (currentHash=="printer-laser-alternative" || currentHash=="projector-three-lcd" || currentHash=="scanner-epson-solutions") {
			$("#tab-nav").attr("class", "").addClass("tab2active");
			$("#tab2-content").show();
		}
		//Map hash to tab #3
		if (currentHash=="printer-ink-technology" || currentHash=="projector-accessories" || currentHash=="scanner-product-compare") {
			$("#tab-nav").attr("class", "").addClass("tab3active");
			$("#tab3-content").show();
		}
		//Map hash to tab #4
		if (currentHash=="printer-news-articles" || currentHash=="scanner-software") {
			$("#tab-nav").attr("class", "").addClass("tab4active");
			$("#tab4-content").show();
		}
		//Map hash to tab #5
		if (currentHash=="printer-eco-features") {
			$("#tab-nav").attr("class", "").addClass("tab5active");
			$("#tab5-content").show();
		}

		
		//Tab clicking functions.
		$("#tab1-link a").click(function(){
			$("#tab-nav").attr("class", "").addClass("tab1active");
			$("#content div.tab-content").hide();
			$("#tab1-content").fadeIn();
		});
		$("#tab2-link a").click(function(){
			$("#tab-nav").attr("class", "").addClass("tab2active");
			$("#content div.tab-content").hide();
			$("#tab2-content").fadeIn();
		});
		$("#tab3-link a").click(function(){
			$("#tab-nav").attr("class", "").addClass("tab3active");
			$("#content div.tab-content").hide();
			$("#tab3-content").fadeIn();
		});
		$("#tab4-link a").click(function(){
			$("#tab-nav").attr("class", "").addClass("tab4active");
			$("#content div.tab-content").hide();
			$("#tab4-content").fadeIn();
		});
		$("#tab5-link a").click(function(){
			$("#tab-nav").attr("class", "").addClass("tab5active");
			$("#content div.tab-content").hide();
			$("#tab5-content").fadeIn();
		});
		
});
// ]]>
