//Primary tab nav


function switchPrimeTabs() {
	var t1 = document.getElementById('tab1');
	var t2 = document.getElementById('tab2');
	var t3 = document.getElementById('tab3');	
	var tab1Info = document.getElementById('tab1Info');
	var tab2Info = document.getElementById('tab2Info');
	var tab3Info = document.getElementById('tab3Info');
	
	function getCurrentSub(tabId){
		var curDiv;		
		var divs = document.getElementsByTagName('div');
		for (i = 0; i<divs.length; i++){
			if(divs[i].className.indexOf('currentSub') !=-1){				
				divs[i].className = 'hide';																					
			}
			if (divs[i].id == (tabId+'Info') ){
				divs[i].className = 'currentSub';
			}
		}			
	}
		
	t1.onclick = function(){
		if (this.className != 'tab1_on'){
			this.className = 'tab1_on';
			t2.className = 'tab2b_off';
			t3.className = 'tab3_off';
			getCurrentSub(this.id);	
			SetCookie("currentTab","0");			
		}
	}	
	t2.onclick = function(){
		if (this.className != 'tab2_on'){
			this.className = 'tab2_on';
			t1.className = 'tab1b_off';
			t3.className = 'tab3b_off';
			getCurrentSub(this.id);
			SetCookie("currentTab","1");
		}
	}	
	t3.onclick = function(){
		if (this.className != 'tab3_on'){
			this.className = 'tab3_on';
			t1.className = 'tab1_off';
			t2.className = 'tab2c_off';
			getCurrentSub(this.id);
			SetCookie("currentTab","2");
		}
	}	
}



function hasIndexOf(theString, theIndex) {
	if(theString.indexOf(theIndex) == -1) {
		return false;
	}
	return true;
}

var _QUERYSTRING;

function getCurrentProject() {
	retVal = GetCookie( "currentProject ");
	retVal = ( retVal ) ? retVal : 0;
	return retVal;
}

function getCurrentTab() {
	retVal = GetCookie( "currentTab" );
	retVal = ( retVal ) ? retVal : 0;
	return retVal;
}

function getQSValue(getThisVar) {
	if( _QUERYSTRING ) {
		return( _QUERYSTRING[ getThisVar ] );
	} else {
		var toReturn = "";
		//kick out if theres no Query String
		if(!hasIndexOf(document.URL, "?")) {return false;}
		var QS = document.URL.substring(document.URL.indexOf("?") + 1);
		var variables = QS.split("&");
		for(var i = 0; i < variables.length; i++) {
			if(hasIndexOf(variables[i], getThisVar)) {
				//if we find it the return its value
				toReturn = variables[i].split("=")[1];
				return toReturn;
			}
		}
		//if all else fails return false
		return false;
	}
}



window.onload = function() { switchPrimeTabs()};