/*	This JavaScript File Contains Code
	That Controls The Slideshow and Image
	Rollover Behaviours

	These Scripts Are Adapted From Those
	Downloaded From www.dynamicdrive.com.
	For Complete Original Scripts Please
	Visit DynamicDrive.com.  This Site (and
	This Developer) Is Not Liable For Any
	Damages Or Repercussions Pertaining To
	The Copy/Paste/Implementation Of This
	Modified Script.

	Thanks.
				Sgt. Doug Kelly
				Highview Fire District */

	// BEGIN: Slideshow / News Ticker Script
	var ie=document.all
	var dom=document.getElementById

	if (slideimages.length>1)
	i=2
	else
	i=0

	function move3(whichdiv){
		tdiv=eval(whichdiv)
		if (parseInt(tdiv.style.left)>0&&parseInt(tdiv.style.left)<=5){
			tdiv.style.left=0+"px"
			setTimeout("move3(tdiv)",pausebetweenimages)
			setTimeout("move4(scrollerdiv2)",pausebetweenimages)
			return
		}
		if (parseInt(tdiv.style.left)>=tdiv.offsetWidth*-1){
			tdiv.style.left=parseInt(tdiv.style.left)-5+"px"
			setTimeout("move3(tdiv)",slideframerate)
		}
		else{
			tdiv.style.left=scolleroffsetwidth
			tdiv.innerHTML=slideimages[i]
			if (i==slideimages.length-1)
			i=0
			else
			i++
		}
	}

	function move4(whichdiv){
		tdiv2=eval(whichdiv)
		if (parseInt(tdiv2.style.left)>0&&parseInt(tdiv2.style.left)<=5){
			tdiv2.style.left=0+"px"
			setTimeout("move4(tdiv2)",pausebetweenimages)
			setTimeout("move3(scrollerdiv1)",pausebetweenimages)
			return
		}
		if (parseInt(tdiv2.style.left)>=tdiv2.offsetWidth*-1){
			tdiv2.style.left=parseInt(tdiv2.style.left)-5+"px"
			setTimeout("move4(scrollerdiv2)",slideframerate)
		}
		else{
			tdiv2.style.left=scolleroffsetwidth
			tdiv2.innerHTML=slideimages[i]
			if (i==slideimages.length-1)
			i=0
			else
			i++
		}
	}

	function startscroll(){
		if (ie||dom){
			scrollerdiv1=ie? first2 : document.getElementById("first2")
			scrollerdiv2=ie? second2 : document.getElementById("second2")
			move3(scrollerdiv1)
			scrollerdiv2.style.left=scrollerwidth
		}
		else if (document.layers){
			document.main.visibility='show'
			move1(document.main.document.first)
			document.main.document.second.left=parseInt(scrollerwidth)+5
			document.main.document.second.visibility='show'
		}
	}
	// END: Slideshow / News Ticker Script

	// BEGIN: Custom DIV-Based Image Rollover Control
	var varRolloverAry = new Array('','','','','','','','','','','','','','','','','','','','');
	function SwapImage(varImageName, varOver)
	{
		//	Build Dynamic List of All Rolled Over Images
		var i = 0;
		while(varRolloverAry[i] != '')
		{
			if(varRolloverAry[i] == varImageName) {
				i = 99;
				break;
			}
			i++;
		}
		if(i <= 20) varRolloverAry[i] = varImageName;

		//	Hide All Rollover Images To Prevent Simultaneous Rollover
		for(i=0; i<varRolloverAry.length; i++)
		{
			if(varRolloverAry[i] != '')
			{
				document.getElementById(varRolloverAry[i] + 'Over').style.left = '-500px';
			}
		}

		//	Perform Rollover Swap
		if(varOver==1)
		{
			document.getElementById(varImageName + 'Over').style.left = '1px';
		} else {
			document.getElementById(varImageName + 'Over').style.left = '-500px';
		}
	}
	// END: Custom DIV-Based Image Rollover Control
	
	//	BEGIN: Help Popup Box Code
	var offsetxpoint=5 //Customize x offset of tooltip
	var offsetypoint=15 //Customize y offset of tooltip
	var ns6=document.getElementById && !document.all
	var enabletip=false
	if (ie||ns6)
	tipobj = null;
//	var tipobj=document.all? document.all["helptextbox"] : document.getElementById? document.getElementById("helptextbox") : ""

	function getTipboxDIV() {
		return document.all? document.all["HelpPopupBox"] : document.getElementById? document.getElementById("HelpPopupBox") : ""
	}

	function ietruebody(){
		return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

	function showHelpTextBox(varTextMsg)
	{
		if(tipobj == null) tipobj = getTipboxDIV();

		if((ns6||ie)&&(varTextMsg!=''))
		{
			tipobj.innerHTML = varTextMsg;
			enabletip=true;

			return false;
		}
	}

	function hideHelpTextBox()
	{
		if(tipobj == null) tipobj = getTipboxDIV();

		if (ns6||ie){
			enabletip=false
			tipobj.style.visibility="hidden"
			tipobj.style.left="-1000px"
		}
	}

	function positiontip(e){
		if(tipobj == null) tipobj = getTipboxDIV();

		if (enabletip){
			var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft;
			var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop;
			//Find out how close the mouse is to the corner of the window
			var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
			var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

			var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

			//if the horizontal distance isn't enough to accomodate the width of the context menu
			if (rightedge<tipobj.offsetWidth)
				//move the horizontal position of the menu to the left by it's width
				tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
			else if (curX<leftedge)
				tipobj.style.left="5px"
			else
				//position the horizontal position of the menu where the mouse is positioned
				tipobj.style.left=curX+offsetxpoint+"px"

			//same concept with the vertical position
			if (bottomedge<tipobj.offsetHeight)
				tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
			else
				tipobj.style.top=curY+offsetypoint+"px"

			tipobj.style.visibility="visible"
		}
	}

	document.onmousemove=positiontip
	//	BEGIN: Help Popup Box Code