var onTabName;
d=document;


pathPrefix="/fileadmin/templates/images/";


function changeTopButton(s){
	o=d.getElementById("topButton_"+s);
	tempString=o.src; 
	
	if(s=='a'){
		if(tempString.indexOf('header_consult.gif')>-1){
			o.src=pathPrefix+'header_consult_2.gif';
		}else if(getURLParam('id')!=22){
			o.src=pathPrefix+'header_consult.gif';
		}		
	}
	if(s=='b'){
		if(tempString.indexOf('header_roadmap.gif')>-1){
			o.src=pathPrefix+'header_roadmap_2.gif';
		}else if(getURLParam('id')!=5){
			o.src=pathPrefix+'header_roadmap.gif';
		}	
	}
}
 
function setupDoc(){

	//make active tab front tab
	s=returnActiveTab();

	if(s!=null)d.getElementById("tab_"+s).style.zIndex="50";
	
	

	
	if(getURLParam('id')==22){
		d.getElementById("topButton_a").src=pathPrefix+'header_consult_2.gif';}

	if(getURLParam('id')==5){
		d.getElementById("topButton_b").src=pathPrefix+'header_roadmap_2.gif';}

}

function returnActiveTab(){
	if(d.getElementById("health").style.display=="none"){
		return "health";
	}else if(d.getElementById("control").style.display=="none"){
		return "control";
	}else if(d.getElementById("childBirth").style.display=="none"){
		return "childBirth";
	}else if(d.getElementById("staff").style.display=="none"){
		return "staff";
	}
}
function swapStyle(idName){
	
	if(onTabName==null)onTabName=returnActiveTab();

	if(onTabName!=null&&onTabName!=idName){
		//change the current tab to off
		o=d.getElementById(onTabName);
		o.style.display="inline";
		o=d.getElementById(onTabName+"_on");
		o.style.display="none";	
		d.getElementById("tab_"+onTabName).style.zIndex="1";
	}
	
	//home page or some other page use the default switch mech.
	//change the current tab to off
	o=d.getElementById(idName);
	o.style.display="none";
	
	o=d.getElementById(idName+"_on");
	o.style.display="inline";

	d.getElementById("tab_"+idName).style.zIndex="50";
	
	//alert(d.getElementById("tab_"+idName).style.zIndex);
	
}

function swapStyleOut(idName){
// assume that this won't trigger unless onTabName has already been set.
// but just in case...

	if(onTabName!=null){
		//turn temp tab back
		o=d.getElementById(onTabName);
		o.style.display="none";
		o=d.getElementById(onTabName+"_on");
		o.style.display="inline";	
		d.getElementById("tab_"+onTabName).style.zIndex="50";
	}
	
	if(idName!=onTabName){
		//change the current tab to off
		o=d.getElementById(idName);
		o.style.display="inline";
		o=d.getElementById(idName+"_on");
		o.style.display="none";	
		
		d.getElementById("tab_"+idName).style.zIndex="1";
	}
	
	//onTabName=null;
}

function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  
  if (strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for(var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if(aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
}