//****************************Dynamic layer setup and scrolling function by Greg Sochanik for Orange June 2001 *************************************
//******************************************************************************************************************************************************************

//************ openPopup() Generic popup window function	*************************

	function openPopup(url,target,w, h) 
	{
		window.open(url,target,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width="+w+",height="+h)		
	}
	
//************ 	browserCheck() *********************************	
	// browserCheck is a function to check the browser that is being used. The function is then called as an object "is".
	function browserCheck() 
	{
		var b = navigator.appName
		if (b=="Netscape") this.b = "ns"
		else if (b=="Microsoft Internet Explorer") this.b = "ie"
		else this.b = b
		this.v = parseInt(navigator.appVersion)
		this.ns = (this.b=="ns" && this.v>=4 )
		this.ns4 = (this.b=="ns" && this.v==4 && this.v < 5)
		this.ns6 = (navigator.appName == "Netscape" && navigator.appVersion.indexOf('5') == 0)? true:false
		this.ie = (this.b=="ie" && this.v>=4)
		this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
		this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
		this.ie55up = (((navigator.userAgent.indexOf('MSIE')>0) && this.v > 5) || (navigator.userAgent.indexOf('MSIE 6')>0))
		
		if (this.ie5) this.v = 5
		this.min = (this.ns||this.ie)
		this.mac =(navigator.appVersion.indexOf("Mac")!=-1) 
	}
	//Sets up "is" as the browserCheck object
	is = new browserCheck()
		

	
//**************** preload(imgObj, imgSrc) *************************
	//function to preload images and set them up as image objects for rollover calls. This must be done at the top of each html page as otherwise netscape doesn't like it.....
	function preload(imgObj, imgSrc)
	{
		if (document.images)
		{
			eval(imgObj+' = new Image()')
			eval(imgObj+'.src = "'+imgSrc+'"')
			
		}
	}

//**************** changeImage(parentlayer,layer, imgName, imgObj) *********************
	// This is the function for image swaps. It works for  images on layers and nested layers, although it only works two layers deep in NS4. 
	// To use you put in a handler in the <a> tage wrapped around the graphic you want to swap or trigger the swap. The first argument
	//  is a string containing the name of the parent layer. If there is no parent layer you just enter null. The second argument is a string containing the name of the layer the image is on.
	// If it's not on a layer, simply enter null. The third argument is a string containing the name of the image you want to swap, declared ias an attribute of the <img> tag marking up the image.
	// The fourth argument is a string containing the name of the image (declared in the preload function above) you want to swap it with.
	// eg <a href="#" onmouseover="changeImage(null,null,'imageA','imageA_on')" onmouseover="changeImage(null,null,'imageA','imageA_off')"><img src="image.gif" name="imageA"></a>
	// The above code demostrates what the code should look like for a rollover on an image named 'imageA' that isn't on a layer.
	function changeImage(parentlayer,layer, imgName, imgObj)
	{
		if (!is.ns4)
		{
			document.images[imgName].src = eval(imgObj+".src");		
		}
		else
		{
			if(document.layers && parentlayer != null && layer != null) 
			{
				eval('document.'+parentlayer+'.document.'+layer+'.document.images['+"imgName"+'].src= '+imgObj+'.src');
			}
			if(document.layers && parentlayer == null && layer != null) 
			{
				eval('document.'+layer+'.document.images['+"imgName"+'].src= '+imgObj+'.src');
			}
			else if (parentlayer==null && layer==null)
			{
				eval ('document.images['+"imgName"+'].src = '+imgObj+'.src');
			}
		}		
	}
	

	function initSize()
	{
		this.pgWidth = window.innerWidth;
		this.pgHeight= window.innerHeight;		
	}
	
	size = new initSize;
	
	
	function patentResizer()
	{
		if ((navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)==4)) 
		{
				
			pgWidth=window.innerWidth; 
			pgHeight=window.innerHeight; 
			if(pgWidth!=size.pgWidth || pgHeight!=size.pgHeight)
			{
				location.reload();
				size.pgWidth = pgWidth;
				size.pgHeight = pgHeight;
			}			
		}
	}
		
	if (is.ns4 && !is.mac) document.captureEvents(Event.MOUSEMOVE)
	if (is.ns4 && !is.mac) document.onmousemove = patentResizer
	if (is.ns4  || is.ie4 && is.mac) onresize = function() {location.reload();}
	
	
	function setDom(layerName, parentLayerName)
	{
		if(parentLayerName == null)
		{
			if(is.ns4) dom = eval('document.'+layerName);
			if(is.ns6 || is.ie55up) dom = document.getElementById(layerName).style;
			if((is.ie4 && !is.mac) || is.ie5 )
			{
				dom = eval(layerName+'.style');						
			} 
			if(is.ie4 && is.mac)
			{
				//Need to check on a mac!!!!!!!!
				dom = eval(layerName+'.style');				
			}
		}
		else
		{
			if(is.ns4) dom = eval('document.'+parentLayerName+'document.'+layerName);
			if(is.ns6 || is.ie55up) dom = document.getElementById(layerName).style;
			if((is.ie4 && !is.mac) || is.ie5 )
			{	
				dom = eval(parentLayerName+','+layerName+'.style');							
			} 
			if(is.ie4 && is.mac)
			{				
				//Need to check on a mac!!!!!!!!
				dom = eval(parentLayerName+','+layerName+'.style');
			}
		}
		return dom;
	}
	
	function windowSize()
	{
		if(is.ns4 || is.ns6)
		{
			this.pgWidth = window.innerWidth;
			this.pgHeight = window.innerHeight;
		}
		else
		{		
			this.pgWidth = parseInt(document.body.clientWidth);
			this.pgHeight = parseInt(document.body.clientHeight);
		}
	}
	
	
	function setLayerPos(layerName, x, y)
	{
		size = new windowSize;
		setDom(layerName);
		if(x)
		{
			dom.left = x;
		}
		if(y)
		{
			dom.top = y;
		}
	}   
	
	function showAll()
	{
		if(is.ns4) totalLayers = document.layers.length;
		if(is.ns6 || is.ie55up)
		{		 
			 obj = document.getElementsByTagName('DIV');
			 totalLayers = obj.length;		 
		}
		if(is.ie4 ||is.ie5) totalLayers = document.all.length;
	
		for(i = 0; i<totalLayers; i++)
		{
			if(is.ns4) layerNames = document.layers[i].name;
			if(is.ns6 || is.ie55up) layerNames = obj[i].id;		
			if(is.ie4 ||is.ie5)  layerNames = document.all[i].id;
			
			if(layerNames != "" && layerNames != "dropdown")
			{
				setDom(layerNames);
				
				dom.visibility = "visible";
			}
		}
	}
	
	function showHide(lyrName, parent, doWhat)
	{
		setDom(lyrName, parent);
		
		if(doWhat == "show")
		{
			dom.visibility = "visible";
		}
		else
		{
			dom.visibility = "hidden";
		}
	}

	function setLayerWidth(layerName, w, h)
	{
		setDom(layerName);
		if(w)
		{
			dom.width = w;
		}
		if(h)
		{
			dom.height = h;
		}
	}
