// JavaScript Document

function init(){
var div = document.getElementById('thecontent');
var tile1 =document.getElementById('expando1');
tile1.style.height=div.offsetHeight+40; //look at again
	NavItems = document.getElementById('navst1').getElementsByTagName('a');
	setImgArray();
	for(var a=0;a<NavItems.length;a++){
		var _Img;

    NavItems[a].childNodes[0].onmouseover=function(){//finds images within the a tags and sets up the rollovers
        _Img = this.src // get img src
        if(_Img.indexOf('_')==-1){ //if it has an underscore in it (and is therefore in the down state)
          _Suffix=_Img.substr(0,_Img.length-4); // otherwise it just the src minus 4 characters for '.gif'
          this.src=_Suffix+'_over.gif';
        }
    }
    NavItems[a].childNodes[0].onmouseout=function(){
        this.src=_Suffix+'.gif';
        resetImages();// has to reset all images to the original ones incase one was originally in the active state;
    }

		if(NavItems[a].className=='roll'){
			NavItems[a].setAttribute('id','nav'+a)
			NavItems[a].onmouseover=function(){
				hideEm();
				clearTimeout(t);
				buildNav(this.id);
			
			}
			NavItems[a].onmouseout=function(){
				t=setTimeout('hideEm()',200);
			}
		}
		else{
			NavItems[a].onmouseover=function(){
				//alert('no')
			}
		}
	}
}
function setImgArray(){
	ImgArray=new Array();
	for(var b=0;b<NavItems.length;b++){
		ImgArray[b] = NavItems[b].childNodes[0].src;
	}
}
function resetImages(){
	for(var c=0;c<NavItems.length;c++){
		NavItems[c].childNodes[0].src=ImgArray[c]
	}
}

function buildNav(ID){
mainNavID=ID;
getMenuItems(ID);

    if (menuItems != null)
    {
      var Table='<table align="left" border="0" cellpadding="0" cellspacing="0" width="200">';
      for(var d=0;d<menuItems[0].length;d++){
        Table+='<tr><td style="padding-left:18px;">'+menuItems[0][d]+'</td></tr>';
      }
      Table +='</table>';
      var setDiv = document.getElementById('menudiv');
      setDiv.style.left=menuPosL+'px';
      setDiv.innerHTML=Table;
      
      SubNavParents=document.getElementById('menudiv').getElementsByTagName('td');
      for(var e=0;e<SubNavParents.length;e++){
        SubNavParents[e].setAttribute('id','subnav'+e)

        SubNavParents[e].onmouseover=function(){
          if (document.getElementById(ID).childNodes[0].src.indexOf('_') == -1){
            document.getElementById(ID).childNodes[0].src=_Suffix+'_over.gif'
          }
          this.style.background='#FCD227';
          buildSubNav(this.id)
        }
        SubNavParents[e].onmouseout=function(){
          if (document.getElementById(ID).childNodes[0].src.indexOf('_') == -1){
            document.getElementById(ID).childNodes[0].src=_Suffix+'.gif'
          }
          this.style.background='#fff';
        }

      }
      setDiv.style.display='block';	
    }
}

function buildSubNav(theID){
var setSubDiv = document.getElementById('submenudiv');
var whichMenuItem=parseInt(theID.substr(6,99))+1;
var subTable = '<table align="left" border="0" cellpadding="0" cellspacing="0" width="200">';
if(menuItems[whichMenuItem]){
	if(menuItems[whichMenuItem]!=''){
		for(var f=0;f<menuItems[whichMenuItem].length;f++){
			subTable+='<tr><td padding-left:18px;>'+menuItems[whichMenuItem][f]+'</td></tr>';
		}
	subTable +='</table>';
	if(menuPosL>460){
		setSubDiv.style.left=parseInt(menuPosL)-200+'px';
		//setSubDiv.style.filter='progid:DXImageTransform.Microsoft.dropshadow(OffX=-2, OffY=2, Color=#C4BFD6, Positive=true)';
	}
	else{
		setSubDiv.style.left=parseInt(menuPosL)+200+'px';
		//setSubDiv.style.filter='progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color=#C4BFD6, Positive=true)';
	}
	setSubDiv.style.top='265px';
var menuPosT = setSubDiv.style.top;
menuPosT = parseInt(menuPosT)+((whichMenuItem-1)*14)+'px';
setSubDiv.style.top = menuPosT;
	setSubDiv.innerHTML=subTable;
	SubNavChilds=document.getElementById('submenudiv').getElementsByTagName('td');
	for(var f=0;f<SubNavChilds.length;f++){
		SubNavChilds[f].onmouseover=function(){
    if (document.getElementById(mainNavID).childNodes[0].src.indexOf('_') == -1){
		  document.getElementById(mainNavID).childNodes[0].src=_Suffix+'_over.gif'
    }
		document.getElementById(theID).style.background='#FCD227';
			this.style.background='#FCE489';
		}
		SubNavChilds[f].onmouseout=function(){
      if (document.getElementById(mainNavID).childNodes[0].src.indexOf('_') == -1){
  			document.getElementById(mainNavID).childNodes[0].src=_Suffix+'.gif'
	    }
      document.getElementById(theID).style.background='#fff';
			this.style.background='#FCD227';
		}
	}
	setSubDiv.style.display='block';
	}
	else{
	setSubDiv.style.display='none';
	}
}
else{
return;
}
}


function hideEm(){
	document.getElementById('menudiv').style.display='none';
	document.getElementById('submenudiv').style.display='none';
}

function layerShow(LayerName, vis){
  var layerObj = document.getElementById(LayerName);
  if (layerObj && layerObj.style){
    layerObj.style.visibility = (vis ? "visible" : "hidden");
  }
}


var windowObj;

function openwindow(strURL, width, height){
  if (windowObj != undefined)  {
    windowObj.close();
  }
  windowObj = window.open(strURL, "new", "location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0,titlebar=0,height=" + height +",width=" + width );
  windowObj.focus();
}
