﻿// JScript File

// Show and hide layers.
var activeSub=0;
var SubNum=0;


//Define global variables

var timerID = null;
var timerOn = false;
var timecount = 1000;
var what = null;
var newbrowser = true;
var check = false;
var locationTabID = null;

function init()
{
     //alert (getCookie("activeTab"));    
     
     if (document.all){
     //alert ("Running IE");
     layerRef="document.all";
     styleSwitch=".style";
     visibleVar="visible";
     screenSize = document.body.clientWidth + 18;
     what ="ie";
     } else if (document.getElementById){
     // //alert ("Running Netscape 6");
     layerRef="document.getElementByID";
     styleSwitch=".style";
     visibleVar="visible";
     what="moz";
     } else {
     //alert("Older than 4.0 browser.");
     what="none";
     newbrowser = false;
     }
     window.status='UpClick';
     check = true;
     activeTab = getCookie("activeTab")
     locationTabID =  activeTab != "" ? activeTab : null ;     
     if (locationTabID != null)
        {         
          enableTab(locationTabID, false)
        }
}
function resetMenu()
{
      if(check){          
      if(locationTabID  != null)
        document.getElementById(locationTabID).className = 'normal';
        locationTabID = null;           
     }
}

// Turns the layers on and off
function showLayer(layerName)
{
     if(check){     
     if (what =="none"){
     return;
     } else if (what == "moz" || what == "ie"){
     if (document.getElementById(layerName) != null)
        document.getElementById(layerName).style.display="block";
     } else{
      //alert("eval");
      eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.display="block"');
     }
     } else {// //alert ("Please wait for the page to finish loading.");
     return;
     }
}

function hideLayer(layerName)
{
     if(check){
     if (what =="none"){
     return;
     } else if (what == "moz"){
     document.getElementById(layerName).style.display="none";
     } else {
     eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.display="none"');
     }
     } else {// //alert ("Please wait for the page to finish loading.");
     return;
     }
}


function startTime() { 
 if (timerOn == false ) {
 timerID=setTimeout( "hideAll()" , timecount);
 timerOn = true;
 }
}


function enableTab(tabName, saveActiveTab)
{
    //alert('tab='+tabName+' layer='+layerName);
    if(check){     
     if (what =="none")     
        return;      
     else 
        document.getElementById(tabName).className = 'selected';
        //alert(document.getElementById(tabName).outerHTML);    
     
     if(locationTabID  != null && locationTabID != tabName)
        document.getElementById(locationTabID).className = 'normal';    
        
     locationTabID = tabName;
     if(saveActiveTab)
     setCookie("activeTab", locationTabID)
     
     //locationLayerID = layerName;
     
     //alert('enabled tab');
     //alert(locationTabID+' '+ locationLayerID);
     return;
     }
}
//function enableFirstLink(layername)
//{    
//    var layer = document.getElementById(layername);    
//    
//    var listitems = layer.getElementsByTagName('a');    
//    var itemid;
//    if (listitems.length > 0) { 
//    itemid = listitems[0].getAttribute("id");
//    enableLink(itemid);
//    }
//    if(locationLinkID != null)
//        document.getElementById(locationLinkID).className = 'normal';        
//     locationLinkID = null;          
//    return;
//}


function stopTime() {
 if (timerOn) {
 clearTimeout(timerID);
 timerID = null;
 timerOn = false;
 }
}
function onLoad(){
 init();
}

function setCookie(c_name,value)
{
var exdate=new Date();
exdate.setMinutes(exdate.getMinutes()+1);
document.cookie=c_name+ "=" +escape(value)+
(";expires="+exdate.toGMTString());
}



function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
} 
