//Global variables
var PAGEWIDTH = 800 ; 
var MENUTIMER = new Array() ; 
var TIMER = new Array() ; // 1=AnimateLoadingMsg(), 2=KeepPageWidth()
var isIE,isNN,isOP ;

/* W3C Images */
var W3C_XHTML_A = new Image ;
var W3C_XHTML_B = new Image ;
var W3C_CSS_A = new Image ;
var W3C_CSS_B = new Image ;
W3C_XHTML_A.src = "../IMAGES/w3c_XHTML1.0_A.gif" ;
W3C_XHTML_B.src = "../IMAGES/w3c_XHTML1.0_B.gif" ;
W3C_CSS_A.src = "../IMAGES/w3c_CSS_A.gif" ;
W3C_CSS_B.src = "../IMAGES/w3c_CSS_B.gif" ;
function chgW3Cimg(imgName,newImg) {
 document.getElementById(imgName).src = eval(newImg + '.src') ;
}

//on-page-open processing
if(navigator.userAgent.indexOf('MSIE') != -1){ isIE = true ; }
if(navigator.userAgent.indexOf('Gecko') != -1){ isNN = true ; }
if(navigator.userAgent.indexOf('Opera') != -1){ isOP = true ; }
window.onresize = PageLoader;

function PageLoader(){
 KeepPageWidth();
 KeepPageHeight();
 SetStyles();
}


function SetStyles(){
 var ScriptStyles = document.getElementById('ScriptStyles') ;
 if(isIE){
  var NavBar = document.getElementById('NavBar') ;
  NavBar.style.height = NavBar.offsetParent.offsetHeight + "px" ;
 }
}


function HideDropDownMenu(NavIDNumber){
 if (document.getElementById("DropDownMenu" + NavIDNumber) != null){
  var DropDownMenu = document.getElementById("DropDownMenu" + NavIDNumber) ;
  DropDownMenu.className = "HiddenDropDownMenu" ;
 }
}


function ShowDropDownMenu(NavIDNumber){
 window.clearTimeout(MENUTIMER[NavIDNumber]);
 var NavLink = document.getElementById("NavLink" + NavIDNumber) ;
 if (document.getElementById("DropDownMenu" + NavIDNumber) != null){
  var DropDownMenu = document.getElementById("DropDownMenu" + NavIDNumber) ;
	DropDownMenu.style.top = NavLink.offsetTop + "px" ;
  DropDownMenu.style.left = (NavLink.offsetLeft + NavLink.offsetWidth) + "px" ;
	DropDownMenu.className = "VisibleDropDownMenu" ;
 }
}


function KeepPageWidth(){
 var PageDiv = document.getElementById('PageDiv') ;
 if (document.body.offsetWidth <= PAGEWIDTH){  
	PageDiv.style.width = PAGEWIDTH + "px" ;
 }
 else {
	PageDiv.style.width = null ;
 }
}


function KeepPageHeight(){
 var PageDiv = document.getElementById('PageDiv') ;
 var Body = document.body ;
 
 if(screen.height > (PageDiv.offsetHeight + 200)){  
  //Netscape Processing
  if(isNN){
	 Body.style.height = "865px" ;
	}
 }
 else{
	PageDiv.style.height = null ;
 }
 
 // Opera Processing
 if(isOP){
  var NavBar = document.getElementById('NavBar') ;
	NavBar.style.height = PageDiv.offsetHeight + "px" ;
 }
}


function AnimateLoadingMsg(){
 var Msg = document.getElementById('LoadingMsg');
 if(Msg.innerHTML.indexOf("...") == -1){
  Msg.innerHTML = Msg.innerHTML.replace(/\&nbsp;/,".") ;
 }
 else{
  Msg.innerHTML = Msg.innerHTML.replace(/\.\.\./,"&nbsp;&nbsp;&nbsp;") ;
 }
 TIMER[1] = window.setTimeout('AnimateLoadingMsg()',750) ;
}


function DisplayMap(){
 window.clearTimeout(TIMER[1]) ;
 var Msg = document.getElementById('LoadingMsg');
 var Map = document.getElementById('BZMap');
 Msg.style.display = "none" ;
 Map.style.display = "inline" ;
}


function ChangeMapSize(MapSize){
 var MapSizesArray = new Array() ; // values are comma delimited MapWidth,MapHeight,MileMeasureWidth
 MapSizesArray[1] = "234,293,10" ;
 MapSizesArray[2] = "467,584,21" ;
 MapSizesArray[3] = "701,877,31" ;
 MapSizesArray[4] = "934,1169,42" ;
 MapSizesArray[5] = "1168,1461,52" ;
 MapSizesArray[6] = "1401,1753,62" ;
 MapSizesArray[7] = "1635,2045,73" ;
 MapSizesArray[8] = "1868,2338,83" ;
 MapSizesArray[9] = "2102,2630,94" ;
 MapSizesArray[10] = "2335,2922,104" ;
 
 var SplitArray = MapSizesArray[MapSize].split(",") ;
 window.MapFrame.document.getElementById("BZMap").style.width = SplitArray[0] + "px" ;
 window.MapFrame.document.getElementById("BZMap").style.height = SplitArray[1] + "px" ;
 document.getElementById("BZMap_MileMeasure").style.width = SplitArray[2] + "px" ;
 window.MapFrame.scrollTo(SplitArray[0]*0.4,SplitArray[1]*0.4)
}


function OpenNewWindow(Location){
 open(Location, 'NewWindow','resizable=no, toolbar=no, location=no, directories=no, status=no, menubar=yes, scrollbars=yes, width=720, height=500')
}


