/*-- Cross-browser DHTML Scripting Core --*/
/*-- Author: Steve Gallagher - Greenfield / Belser LTD

/*-- preload images (global) --*/
/*-- example image pre load --
var nav_home = new Image();
	nav_home.src = 'images/zt_navigation/zt_nav_home.gif';
var nav_home_over = new Image();
	nav_home_over.src = 'images/zt_navigation/zt_nav_home_over.gif';
*/

/*****************************************************************************
 ** DISABLING JAVASCRIPT
 *****************************************************************************
var page = '';
var titleName = '';
var scrollReady = false;


// --browser Detection --
function browserDetect()  {
	ns4 = (document.layers)&&(navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)==4) ? 'ns4' : false;
	ie4 = (document.all)&&(navigator.appName.indexOf("Microsoft") > -1)&&(parseInt(navigator.appVersion)==4) ? 'ie4' : false;
	ie5 = (document.getElementById)&&(navigator.appName.indexOf("Microsoft") > -1) ? 'ie5' : false;
	ok = (document.getElementById) ? 'ok' : false;
	//alert(ns4 || ie5 || ie4 || ok);

	return (ns4 || ie5 || ie4 || ok);
}
var browser = browserDetect();

if (browser == false)  {
  //document.location = '';  Degredation Page
}


// -- Cross-browser Layer Access Function --
function myDOM(id)	{
	if (browser == 'ns4')  {return ns4ElementById(id);}
	if (browser == 'ie4')  {return eval('document.all.'+ id);}
	if (browser == 'ie5')  {return document.getElementById(id);}
	if (browser == 'ok')  {return document.getElementById(id);}
	return false;
}

// -- Search Layers Array by ID [Netscape 4 Work-Around] --
function ns4ElementById(layerId,me)	{
	var foundIt = false;
	var whereAmI = (me) ? me : document.layers;
	if (whereAmI[layerId])  {return whereAmI[layerId];}
	for (var i=0; i<whereAmI.length; i++)  {
	  if (whereAmI[i].document.layers)  {foundIt = ns4ElementById(layerId,whereAmI[i].document.layers);}
	  if (foundIt)  {return foundIt;}
	}
}

// -- [End] Cross-browser DHTML Scripting Core --

// -- Image Access Function -- Syntax: getImage(layer's ID).images[image's name attribute] --
function getImage(id)  {
	if (browser == 'ns4')  {return myDOM(id).document;}
	else  {return document;}
}

// -- Form Access Function -- Syntax: getForm(layer's ID).forms[form's name attribute] --
function getForm(id)  {
	if (browser == 'ns4')  {return myDOM(id).document;}
	else  {return document;}
}

// -- Style Access Function -- Syntax: getStyle(layer's ID).CSS attribute -- Support for CSS attributes varies depending on the browser --
function getStyle(id)  {
//alert(id);
	if (browser == 'ns4')  {return myDOM(id);}
	else  {return myDOM(id).style;}
}

// -- Get a Layer's Height --
function getHeight(id)  {
	if (browser == 'ns4')  {return myDOM(id).document.height;}
	else {return myDOM(id).offsetHeight;}
}

// -- Get a Layer's Width --
function getWidth(id)  {
	if (browser == 'ns4')  {return myDOM(id).document.width;}
	else {
	//alert(myDOM(id).offsetWidth);
	return myDOM(id).offsetWidth;}
}

// -- Show or Hide a Div --
function showHideDiv(divName, state) {
//alert('showHideDiv:myDOM('+divName+')-> ' + myDOM(divName));
	(state) ? getStyle(divName).visibility = 'visible' : getStyle(divName).visibility = 'hidden';
}

// -- Scrolling Function --
var dir = 0;
var scrollTimer = 0;
var maxHeight;
var maxWidth;
var currentLayer = '';
var orientation = '';

function moveContainerVert(inc)  {
	if (browser=='ns4')  {
		newTop = parseInt(getStyle(currentLayer).top) + inc;
		getStyle(currentLayer).top = ((newTop <= 3) && (newTop >= maxHeight-10)) ? newTop : getStyle(currentLayer).top;
	}
	else  {
		currentTop = parseInt(getStyle(currentLayer).top);
		newTop = currentTop + inc;
		getStyle(currentLayer).top = ((newTop <= 3) && (newTop >= maxHeight-10)) ? newTop +'px': parseInt(getStyle(currentLayer).top);
	}
}

function moveContainerHorz(inc)  {
	if (browser=='ns4')  {
		newLeft = parseInt(getStyle(currentLayer).left) + inc;
		getStyle(currentLayer).left = ((newLeft <= 3) && (newLeft >= maxWidth-10)) ? newLeft : getStyle(currentLayer).left;
	}
	else  {
		currentLeft = parseInt(getStyle(currentLayer).left);
		newLeft = currentLeft + inc;
		//alert(maxWidth);
		getStyle(currentLayer).left = ((newLeft <= 3) && (newLeft >= maxWidth-10)) ? newLeft +'px' : parseInt(getStyle(currentLayer).left);
	}
}

function setDir()  {
	if (arguments.length > 0)  {dir = arguments[0];}
	else {return dir;}
}

function animateContainer(temp)  {
//alert('animateContainer');
	clearTimeout(scrollTimer);
	dir = setDir();
	if (dir != 0)  {
		if (orientation == 'vert' && scrollReady)  {moveContainerVert(5 * dir);}
    	if (orientation == 'horz' && scrollReady)  {moveContainerHorz(5 * dir);}

		scrollTimer=setTimeout("animateContainer("+ dir +")", 10);
	}
	else {return false}
}

function scrollContainer(temp, news)  {
//alert('scrollContainer');
	dir = temp;
  	orientation = news;
  	animateContainer(dir);
}

function initScroll(scrollBox, clipBox)  {
	currentLayer = scrollBox;
	getStyle(currentLayer).visibility = 'visible';
	//getStyle(currentLayer).top = 0;
	//containerHeight = getHeight(currentLayer);
  	//containerWidth = getWidth(currentLayer);

	//if (browser == 'ns4')  {
    //	boxHeight = getStyle(clipBox).clip.height;
    //	boxWidth = getStyle(clipBox).clip.width;
  	//}
	//else  {
   //		boxHeight = getHeight(clipBox);
   // 	boxWidth = getWidth(clipBox);
  	//}
  //	maxHeight = boxHeight - containerHeight;
  //	maxWidth = boxWidth - containerWidth;
  	scrollReady = true;
}

function initScrollImage(scrollBox, clipBox)  {
  	currentLayer = scrollBox;
	containerHeight = getHeight(currentLayer);
 	containerWidth = getWidth(currentLayer);

	if (browser == 'ns4')  {
    	boxHeight = getStyle(clipBox).clip.height;
    	boxWidth = getStyle(clipBox).clip.width;
  }
	else  {
    boxHeight = getHeight(clipBox);
    boxWidth = getWidth(clipBox);
  }
  	//alert('box: ' + boxWidth + ' | container: ' + containerWidth);

  getStyle(currentLayer).top = (containerHeight > boxHeight) ? 0 - ((containerHeight - boxHeight) / 2) : 0;
  getStyle(currentLayer).left = (containerWidth > boxWidth) ? 0 - ((containerWidth - boxWidth) / 2) : 0;
  getStyle(currentLayer).visibility = 'visible';
  maxHeight = boxHeight - containerHeight;
  maxWidth = boxWidth - containerWidth;
  scrollReady = true;
}
// -- End Scrolling Function --

function GetFlashHeight() {
//alert('GetFlashHeight');
	if (parseInt(navigator.appVersion)>3) {
 		if (navigator.appName=="Netscape") {
  			winH = window.innerHeight;
 		}
 		if (navigator.appName.indexOf("Microsoft")!=-1) {
  			winH = document.body.offsetHeight;
 		}
	}
		//winH = (myDOM('mainContent').scrollHeight);
		winPos = (myDOM('mainContent').scrollTop);
	//	alert(winH);
//		alert(winPos);
		getStyle('flashDiv').height = winH + "px";
		getStyle('flashDiv').top = "0px";
		//alert('flashDiv height: ' +getStyle('flashDiv').height);
}

function showContentDiv() {
	if (myDOM('mainContent')) {
		//reloadImg();
		getStyle('mainContent').visibility = 'visible';
	}
	else {
		setTimeout('showContentDiv()',1000);
	}
}

function hideFlashDiv() {
	if (myDOM('mainContent')) {
		getStyle('flashDiv').visibility = 'hidden';
	}
	else {
		setTimeout('showContentDiv()',1000);
	}
	showContentDiv();
}

function reloadImg() {
	IMGlen = document.getElementsByTagName('IMG').length;
	for (x=0; x<IMGlen; x++) {
		document.images[x].src = document.images[x].src;
	}	
	return false;
	
}

*****************************************************************************
** DISABLING JAVASCRIPT
*****************************************************************************/

function showList(id)
{
	var className = document.getElementById(id).className;

	if(className == 'Hide')
		document.getElementById(id).className = 'Show';
	else if(className == 'Show')
		document.getElementById(id).className = 'Hide';
}
