﻿var QLTabs={
	sTabClicked:'',
	bTrack:true,
	QLregisterClick: function(){
		$(".QLtabOff").click(function()
    	{
       		//find all siblings of this clicked tab where tabid=QLtab
    		var oSiblingTabs= $(this).siblings("[id^=QLtab]");
    		//remove active on class
    		oSiblingTabs.removeClass("QLtabOn");
    		//reset text to default color
    		oSiblingTabs.each(function(){ var oFirst = $(this).first(); oFirst.html("<font class=\"ms-rteCustom-Arial_Bold_12_005FAD\">" + oFirst.text() + "</font>"); });
    		//add active on to clicked tab
    		$(this).addClass("QLtabOn");
    		//set text to gray color
    		$(this).first().html("<font class=\"QLtabOnStyle\">" + $(this).first().text() + "</font>");
    		//hide all tab contents
    		$(this).parent().siblings("[class=QLtabContentToggle]").hide().find("td:first").hide();
    		//show tab contents for this clicked tab
    		$("#" + $(this).attr("id") + "Content").show().find("td:first").fadeIn();
    		//set leftnav background when clicks on tab
    		QLleftnav.QLhightlightLeftnavBGonTabClicked($(this).attr("id"));
    		//set tab clicked for Google Analytics tracking
    		QLTabs.sTabClicked= $(this).first().text();
    		if(QLTabs.bTrack) QLTabs.QLtrackClicked();
    	});
	},
	QLsetTrack:function(){
		this.bTrack=false;
	},
	QLgetCategory:function(){
		var sCurrentUrl=(window.location.href).toLowerCase();
		var nIndexAtqlogicDotCom=sCurrentUrl.indexOf("qlogic.com");
		var nIndexAtPages=sCurrentUrl.indexOf("pages");
		if(sCurrentUrl.indexOf('/oempartnerships')!=-1){ //special case:track by OEM
			var nIndexAtPages= sCurrentUrl.indexOf("pages");
			var nIndexAtASPX= sCurrentUrl.indexOf(".aspx");
			return(sCurrentUrl.substring(nIndexAtPages+6,nIndexAtASPX));
		}
		return sCurrentUrl.substring(nIndexAtqlogicDotCom + 11, nIndexAtPages-1);	
	},
	QLgetLabel:function(){
		if(typeof QLproducts !="undefined") return QLproducts.getProductSeriesName();
		return 'undefined';
	},
	QLtrackClicked:function(){
		//alert(this.QLgetCategory() + '___' + this.sTabClicked + '___' + this.QLgetLabel());
		_gaq.push(['_trackEvent', this.QLgetCategory(), 'Click:' + this.sTabClicked, this.QLgetLabel()]);
	},
	QLgetTabClicked:function(){
		return this.sTabClicked;
	}
}
$(document).ready(function() {
	QLTabs.QLregisterClick();
});

