// JavaScript Document

function nav(){
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();
}


/* **************** START RANDOM IMAGE COOKIE ********************************************************************************  */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}
		var expdate = new Date ();
		expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000*365)); 
		
  		lastPicNum = getCookie("phoqus");

		if (lastPicNum == 0){setCookie("phoqus", 1, expdate)};
		if (lastPicNum == 1){setCookie("phoqus", 2, expdate)};
		if (lastPicNum == 2){setCookie("phoqus", 3, expdate)};
		if (lastPicNum == 3){setCookie("phoqus", 4, expdate)};	
		if (lastPicNum == 4){setCookie("phoqus", 5, expdate)};	
		if (lastPicNum == 5){setCookie("phoqus", 0, expdate)};		
		if (lastPicNum == null){setCookie("phoqus", 1, expdate);lastPicNum = 0;};
		
		var PicLoader1 = new Array ("images/topgraphic/home1.jpg","images/topgraphic/home2.jpg","images/topgraphic/home3.jpg" , "images/topgraphic/home4.jpg", "images/topgraphic/home5.jpg", "images/topgraphic/home6.jpg");
		var PicLoader2 = new Array ("images/topgraphic/front1.jpg","images/topgraphic/front2.jpg","images/topgraphic/front3.jpg" , "images/topgraphic/front4.jpg", "images/topgraphic/front5.jpg", "images/topgraphic/front6.jpg");


		function RandPicLeft(url) {
			if (document.images) {
				document.SlideShow.src = url + PicLoader1[lastPicNum]
			}
		}
		
		function RandPicHome(url) {
			if (document.images) {
				document.SlideShow.src = url + PicLoader2[lastPicNum]
			}
		}		
/* RANDOM IMAGE COOKIE ************************************************************************************************  */



