//****************************Dynamic layer setup and scrolling function by Greg Sochanik(greg@zonegroup.com) for Orange June 2001 *************************************
//******************************************************************************************************************************************************************
	// This constant is the speed at which the nav slows down, before it reaches the edge of an image.The lower it is the longer it takes to slow down.
    decrement = 0.4
	//scrollWidth = 353 // Must enter set width of main container parent layer in here for Netscapes benefit(for this site it's 353 )
	toppos = 80
	
	
//************ openPopup() Generic popup window function	*************************

	function openPopup(w,h,url,target) 
	{
		window.open(url,target,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width="+w+",height="+h)		
	}
	
//************ convertChar(str) checks for accents and converts them to escapes! ************************************************************

	charArr = new Array("À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ñ","Ò","Ó","Ô","Õ","Ö","Ø","Ù","Ú","Û","Ü","Ý", "à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ñ","ò","ó","ô","õ","ö","ø","ù","ú","û","ü","ý","œ", "ß")

	escArr = new Array("&Agrave;","&Aacute;","&Acirc;","&Atilde;", "&Auml;", "Aring;", "&AElig;", "&Ccedil;", "&Egrave;", "&Eacute;", "&Ecirc;", "&Euml;", "&Igrave;", "&Iacute;", "&Icirc;", "&Iuml;", "&Ntilde;", "&Ograve;", "&Oacute;", "&Ocirc;", "&Otilde;", "&Ouml;","&Oslash;","&Ugrave;", "&Uacute;", "&Ucirc;", "&Uuml;", "&Yacute;","&agrave;","&aacute;","&acirc;","&atilde;", "&auml;", "&aring;", "&aelig;", "&ccedil;", "&egrave;", "&eacute;", "&ecirc;", "&euml;", "&igrave;", "&iacute;", "&icirc;", "&iuml;", "&ntilde;", "&ograve;", "&oacute;", "&ocirc;", "&otilde;", "&ouml;","&oslash;","&ugrave;", "&uacute;", "&ucirc;", "&uuml;", "&yacute;", "&#156;", "&szlig;");

	function convertChar(str)
	{
		for(i = 0; i< charArr.length; i++)
		{
			textSearch = charArr[i];
			while(str.search(textSearch)>0)
			{
				str = str.replace(textSearch, escArr[i]);					
			}
		}

		return str
	}

//************ 	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.v<4.7 )
		this.nt = (navigator.appVersion.indexOf('NT')>0)
		this.ns4 = (this.b=="ns" && this.v>=4 && this.v < 5)
		this.ns5 = (navigator.appName == "Netscape" && navigator.appVersion.indexOf('5') == 0)? true:false
		this.ns6 = (document.getElementById)? 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)||(navigator.userAgent.indexOf('MSIE 6')>0)
		this.ie55 = (navigator.userAgent.indexOf('MSIE 5.5')>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()
	
	
	
//************ initLayers(objA, objB) ***************************	
	// This function initialises the two nav layers passed to it(objA and objB) as block and blockB in order to make them work across browsers
	function initLayers(objA)
	{
		if(objA)
		{
			
			//first child layer
   	  		if (is.ns4) block = eval('document.parent.document.'+objA)		
			if(is.ie4) block= eval(objA+'.style');
			if (is.ie && !is.ie4) block = objA.style;
					
			if (is.ns6) block = document.getElementById(objA).style;
			
		
			//parent layer
			if (is.ns4) mainLyr = document.parent
			if (is.ie4) mainLyr = document.all['parent'].style
			if (is.ie && !is.ie4) mainLyr = parent.style
			if (is.ns6) mainLyr = document.getElementById('parent').style
			
		
			//sets a variable to equal the Xposition of a layer
			block.ypos = parseInt(block.top)
			block.xpos = parseInt(block.left)
			
			//blockB.xpos = parseInt(blockB.left)
			//mainLyr.xpos = parseInt(mainLyr.left)
		
		
	
		//sets a variable to equal the width of the initialised layer
			if (is.ns4)
			{
				block.iHeight = parseInt(block.clip.height)
				block.iWidth = parseInt(block.clip.width)
				mainLyr.iWidth = parseInt(mainLyr.clip.width)
				mainLyr.iHeight = parseInt(mainLyr.clip.height)
			
			//	blockB.iHeight = parseInt(blockB.clip.height)
			//	mainLyr.iHeight = parseInt(mainLyr.clip.height)				
			}
			if (is.ie||is.ns6)
			{				
				block.iHeight = parseInt(block.height)
				block.iWidth = parseInt(block.width)
				mainLyr.iWidth = parseInt(mainLyr.width)
				mainLyr.iHeight = parseInt(mainLyr.height)
				
			//	blockB.iHeight = parseInt(blockB.height)
			//	mainLyr.iHeight = parseInt(mainLyr.height)
			}
			block.gap = parseInt(block.iWidth-mainLyr.iWidth)
			block.gapHeight = parseInt(block.iHeight-mainLyr.iHeight)
			//sets a boolean variable to turn on and off the movement functions (false is off)
			block.loop = false
							
			//sets a boolean variable to turn on and off the inertia function (false is off)
			block.slowdown = false
			//sets block to false as default if whole page not yet loaded
			}
		else
		{
			block = false;
		}
	}
	
//**************** 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");
			if(!is.ns5) document.images[imgName].blur();
		}
		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');
			}
		}		
	}	
//********************	 scrLeft(spd) ***********************************
	// This is the function to scroll a layer to the right. It is declared in a <a> tag as an onmouseover, using the boolean value block.loop as a switch.
	// the argument spd is an integer value representing the speed at which the layer moves, this can be adjusted in the function call.
	function scrLeft(spd)
	{
	    decrement = 0.1//speed at which layer slows before hitting the end of an ima
		if(screen.availWidth <= 1024 || is.nt) 
		{
		speed = spd-1
		time = 30

		}
		else
		{
			speed = spd 
			time=10
		}
			
		if(block.loop && block.xpos < 0)// the swicth. Set to true on mouseover...false onmouseout. Defaults to false
		{			
			block.xpos += speed //increments movement by spd*px/loop		
			block.left = block.xpos;	//moves the layer
			eval('setTimeout("scrLeft('+spd+')", '+time+')')//sets the speed of the loop
		}
		else
		{
			block.slowdown=true;// this occurs when the switch is set to false, only after it has been set to true
			slowdownLeft(speed,time);// calls the inertia function and passes the original variable spd to it.
			return false;
		}		
	}
		
//**************************scrRight(spd) ********************************************
	function scrRight(spd)// works exactly the same as scrLeft(spd) only scrolling the other way
	{
		decrement = 0.1
		if(screen.availWidth <=1024 || is.nt){
		 speed = spd-1
		 time=30
		 
		}
		else
		{
			speed = spd
			time=10
		}
		
		if(block.loop && block.xpos >= (0-block.gap))
		{
			block.xpos -= speed
			
			
			block.left = block.xpos;						
			eval('setTimeout("scrRight('+spd+')", '+time+')')
		}
		else
		{
			block.loop=false
			block.slowdown=true;
			slowdownRight(speed,time);
			return false;
		}
	}

//******************* 	slowdownLeft(speed) *************************
// Slowdown inertia functions	
	function slowdownLeft(speed,time)
	{
		
		if (block.slowdown && speed > 0 && !block.loop && block.xpos < 0) //Only runs the function if all these things are true (ie the slowdown sitch is set to true, the loop switch is set to false)
		{
			
			speed -= decrement;// this reduces the speed of the movement by the decrement variable declared earlier				
			iPos = Math.floor(block.xpos)// Converts the decimal value of the first layers position to an integer to makle it easier to track
			
		
			block.xpos += speed
			
			block.left = block.xpos
		
		
			eval('setTimeout("slowdownLeft('+speed+','+time+')", '+time+')')
		}				
		
		else
		{
			block.slowdown = false;
		}
	}
/*	if (picLayer.ypos  >= topPos)
			{
				picLayer.ypos=topPos;
				changeImage(null,'scrollerdown','down','off');
		
			}
*/
//************************ slowdownRight(speed) ***************************
	function slowdownRight(speed,time)
	{
		
		if (block.slowdown && speed > 0 && !block.loop && block.xpos >= (0-block.gap))
		{	
			
			speed -= decrement;
			iPos = Math.floor(block.xpos)
		
			
			block.xpos -= speed
			
			block.left = block.xpos
									
			eval('setTimeout("slowdownRight('+speed+','+time+')", '+time+')')
		}
		
		else
		{
			block.slowdown = false;
		}
		
	}
	

//**************************scrUp(spd) ********************************************
	function scrUp(spd)// works exactly the same as scrLeft(spd) only scrolling the other way
	{
		
		decrement = 0.1
		if(screen.availWidth <=1024 || is.nt){
		 speed = spd-1
		 time=30
		 
		}
		else
		{
			speed = spd
			time=10
		}
		
		if(block.loop && block.ypos >= (0-block.gapHeight))
		{
			block.ypos -= speed
			
			
			block.top = block.ypos;						
			eval('setTimeout("scrUp('+spd+')", '+time+')')
		}
		else
		{
			block.loop=false
			block.slowdown=true;
			slowdownUp(speed,time);
			return false;
		}
	}

//************************ slowdownUp(speed) ***************************
	function slowdownUp(speed,time)
	{
		
		if (block.slowdown && speed > 0 && !block.loop && block.ypos >= (0-block.gapHeight))
		{	
			
			speed -= decrement;
			iPos = Math.floor(block.ypos)
		
			
			block.ypos -= speed
			
			block.top = block.ypos
									
			eval('setTimeout("slowdownUp('+speed+','+time+')", '+time+')')
		}
		
		else
		{
			block.slowdown = false;
		}
		
	}
	
//********************	 scrDown(spd) ***********************************
	// This is the function to scroll a layer to the right. It is declared in a <a> tag as an onmouseover, using the boolean value block.loop as a switch.
	// the argument spd is an integer value representing the speed at which the layer moves, this can be adjusted in the function call.
	function scrDown(spd)
	{
		   decrement = 0.1//speed at which layer slows before hitting the end of an ima
		if(screen.availWidth <= 1024 || is.nt) 
		{
		speed = spd-1
		time = 30

		}
		else
		{
			speed = spd 
			time=10
		}
			
		if(block.loop && block.ypos < 0)// the swicth. Set to true on mouseover...false onmouseout. Defaults to false
		{			
			block.ypos += speed //increments movement by spd*px/loop		
			block.top = block.ypos;	//moves the layer
			eval('setTimeout("scrDown('+spd+')", '+time+')')//sets the speed of the loop
		}
		else
		{
			block.slowdown=true;// this occurs when the switch is set to false, only after it has been set to true
			slowdownDown(speed,time);// calls the inertia function and passes the original variable spd to it.
			return false;
		}		
	}

//******************* 	slowdownDown(speed) *************************
// Slowdown inertia functions	
	function slowdownDown(speed,time)
	{
		
		if (block.slowdown && speed > 0 && !block.loop && block.ypos < 0) //Only runs the function if all these things are true (ie the slowdown sitch is set to true, the loop switch is set to false)
		{
			speed -= decrement;// this reduces the speed of the movement by the decrement variable declared earlier				
			iPos = Math.floor(block.ypos)// Converts the decimal value of the first layers position to an integer to makle it easier to track
			
		
			block.ypos += speed			
			block.top = block.ypos
		
		
			eval('setTimeout("slowdownDown('+speed+','+time+')", '+time+')')
		}				
		
		else
		{
			block.slowdown = false;
		}
	}

	function initLayer2(lyr)
	{
		if (is.ns4) obj = eval("document."+lyr);		
		if (is.ie4 && !is.mac) obj = eval(lyr+'.style');
		if (is.ie4 && is.mac) obj = eval(lyr+'.style') ;
		if (is.ie5) obj = lyr.style;			
		if (is.ns6) obj = document.getElementById(lyr).style;
	}
//*******************   showhideLayer(lyr) **********************************//
	function showhideLayer(lyr, dowhat)
	{
		initLayer2(lyr);		
		if(dowhat == 'hide')
		{
			obj.visibility = 'hidden';
		}
		if(dowhat == 'show')
		{
			obj.visibility = 'visible';			
		}
	}
//**************************************************************************//
//************************ initSize ***************************************//
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.mac) onresize = function() {location.reload();}
	   
	
	
	
	