/*********************************************************************************
 Global variables
*********************************************************************************/
//Default browsercheck
function browsercheck(){
    this.ver=navigator.appVersion
    this.agent=navigator.userAgent
    this.dom=document.getElementById?1:0
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
    this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
    this.ie4=(document.all && !this.dom)?1:0;
    this.ie=this.ie4||this.ie5||this.ie6
    this.mac=this.agent.indexOf("Mac")>-1
    this.opera5=this.agent.indexOf("Opera 5")>-1
    this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
    this.ns4=(document.layers && !this.dom)?1:0;
    this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5 || this.dom)
    return this
}
var bw=browsercheck()
if(!bw.bw){
        alert("I'm sorry some of the scripts on this page may not work with\n" +
              "your browser.  Please update your browser and visit again.\n");
}


var PageImages = new Array();
var PageAltImages = new Array();
var timer
var timer2
var speed = 10
var hideID = 0	
var lastViewed = "chalayer"	
var layerOver = 0
var nest = "";
var menuimg = "";
var loaded = 0;
var active="childLayer1";

/*********************************************************************************
Utility functions
*********************************************************************************/
function fnFalse() {
	return false;
}

/*********************************************************************************
Window Resize
*********************************************************************************/
if (bw.ns4){
    origWidth = innerWidth;
    origHeight = innerHeight;
 }

function reDo() {
   if (innerWidth != origWidth || innerHeight != origHeight) {
      location.reload();
	  window.reload();
   }
}

if (bw.ns4) onresize = reDo;

/*********************************************************************************
Images Preload
*********************************************************************************/
		
function LoadActiveImages() {
	var num = document.images.length;
	for (var i = 0; i < num; i++) {
		var thisImage = document.images[i];
		var thisImageSrc = thisImage.src;
		var imageName = thisImageSrc.substring(0,thisImageSrc.indexOf("_o"));
		//document.write(imageName + "<BR>");
		if (thisImageSrc.indexOf("_off") != -1) {
			PageImages[i] = new Image(thisImage.width, thisImage.height);
      	     	PageImages[i].src = imageName + "_on.gif";
		} else if (thisImage.src.indexOf("_on") != -1) {
			PageAltImages[i] = new Image(thisImage.width, thisImage.height);
      	     	PageAltImages[i].src = imageName + "_off.gif";
			//var ImagePtr = getImage(thisImage);
			//document.images[getImage(thisImage)].src = imageName + "_off.gif";
			//document.images[getImage(thisImage)].src = imageName + "_off.gif";
		}
    }
}
	
/*********************************************************************************
Convert object name string or object reference into a valid object reference
*********************************************************************************/

/*function getObject(obj) {
	var divNest='', argLength = arguments.length; 
	for (i = 1; i < argLength; i++)  { divNest=divNest+'document.'+arguments[i]+'.'; }; theObj=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(divNest+'document.'+obj):0; if (theObj.style) { theObj=theObj.style;} ;return theObj
}*/

function getObject(obj) {
	var divNest='', argLength = arguments.length
	for (i = 1; i < argLength; i++)  
	divNest=divNest+'document.'+arguments[i]+'.';
	theObj=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(divNest+'document.'+obj):0;
	if (theObj.style) { theObj=theObj.style;}
	return theObj
}

/*********************************************************************************
Image Swap
*********************************************************************************/
function imageSwap(which, state) {
     	
	//which - required input of image name
	//state - required input of image rollover state (1 for on, 0 for off)
	//div1,div2,... - optional input layer hierarchy for Netscape 4.0 browsers

	//declare the local function variables
	var divNest=''
	var argLength = arguments.length
	
	//loop over the arguments, to check for any passed div id's, and set the nesting
	if (argLength>2) {
		for (var i = 2; i < argLength; i++)  
		divNest=divNest+'document.'+arguments[i]+'.';
	}
	
	//get the element obj reference
    bw.dom?thisImage=document.getElementById(which):bw.ie4?document.all[which]:thisImage=eval(divNest+"document[which]");
	
	//find the image src name
	var imageName = thisImage.src.substring(0,thisImage.src.lastIndexOf("_o"));
	//toggle the src name based on state
	state == 0?layerOver==0?endString = "_off.gif":'':endString = "_on.gif";
	//alert(layerOver);
	//set the image src to the new src
	thisImage.src=imageName + endString;
}


function imageSwapSlow(obj, state) {
	//clear any timeouts for imageSwapSlow
	timer2=(!timer2) ? '':window.clearTimeout(timer2);
	
	//set the new timeout
	timer2 = window.setTimeout("imageSwap(" + "\'" + obj + "\'," + state + ")", speed)	
}	

function imageReplace(which, imgGraphic) {
	//which - required input of image name attribute
	//imgGraphic - filename of image replacing the current one
	//div1,div2,... - optional input layer hierarchy for Netscape 4.0 browsers

	//declare the local function variables
	var divNest=''
	var argLength = arguments.length
	
	//loop over the arguments, to check for any passed div id's, and set the nesting
	if (argLength>2) {
		for (var i = 2; i < argLength; i++)  
		divNest=divNest+'document.'+arguments[i]+'.';
	}
	
	//get the element obj reference
    bw.dom?thisImage=document.getElementById(which):bw.ie4?document.all[which]:thisImage=eval(divNest+"document[which]");
	
	//replace the image src 
	var imagePath = thisImage.src.substring(0,thisImage.src.lastIndexOf("/"));
	thisImage.src = imagePath  + "/" + imgGraphic;
}



/*********************************************************************************
Window Functions
*********************************************************************************/	

// suppress errors
function stopError() {
	return true;
}
window.onerror = stopError;
	
if (window.focus) {
	self.focus();
}

function popWindow(URL,name,widgets) {
	popwin = window.open(URL, name, widgets)	
	popwin.focus()	
	popwin.opener = self
	window.name = "MainWin"			
}
	

function closeWin(){
	window.close()
}
