var delayhide='';
		
var its;
var browserName;
var browserNameLong;
var browserNew;
var preloadFlag = false;
var Macintosh = navigator.userAgent.indexOf('Mac')>0;

var isMinNS4 	= (document.layers) ? 1 : 0;
var isMinIE4 	= (document.all) ? 1 : 0;
var isNS6 		= (document.getElementById && !document.all) ? 1 : 0;
var isMac 		= (navigator.userAgent.indexOf("Mac") > 0) ? 1 : 0;
var winHeight, winWidth;
		
function its() 
{
	var n = navigator;
	var ua = ' ' + n.userAgent.toLowerCase();
	var pl = n.platform.toLowerCase();
	var an = n.appName.toLowerCase();

	// browser version
	this.version = n.appVersion;
	this.nn = ua.indexOf('mozilla') > 0;

	// 'compatible' versions of mozilla aren't navigator
	if(ua.indexOf('compatible') > 0) 
	{
		this.nn = false;
	}
	
	this.opera = ua.indexOf('opera') > 0;
	this.ie = ua.indexOf('msie') > 0;
	this.major = parseInt( this.version );
	this.minor = parseFloat( this.version );

	// platform
	this.mac = ua.indexOf('mac') > 0;
	this.win = ua.indexOf('win') > 0;

	// workaround for IE5 which reports itself as version 4.0
	if(this.ie) 
	{
		if(ua.indexOf("msie 5") > 1) 
		{
			var msieIndex = navigator.appVersion.indexOf("MSIE") + 5;
			this.major = parseFloat(navigator.appVersion.substr(msieIndex,3));
		}
	}

	return this;
}

function checkBrowser() 
{
	its = new its();
	
	// is it a DOM-enabled browser?
	if (!document.getElementById) 
	{
		browserNew = false;
	}
	else 
	{
		browserNew = true;
	}

	// need the name, too
	if (its.opera) 
	{
		browserName = "Opera";
	}
	else if (its.ie) 
	{
		browserName = "IE";
	}
	else 
	{
		browserName = "NS";
	}

	// and the number
	browserNameLong = browserName + its.major;

}

function UI_reloadPage(init) 
{
	if (init==true) with (navigator)
	{
		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) 
		{
			document.UI_pgW=innerWidth; 
			document.UI_pgH=innerHeight; 
			onresize=UI_reloadPage; 
		}
	}
	else if (innerWidth!=document.UI_pgW || innerHeight!=document.UI_pgH)
	{
		location.reload();
	}
}

UI_reloadPage(true);

function unBlur() {
		this.blur();
	}

function noBorder() {
		if ((browserNew) || (browserName == "IE")) {
			if (browserNew) {
				links = document.getElementsByTagName("a");
			}
			else {
				links = document.all.tags("a");
			}
			for(i=0; i<links.length; i++) {
				links[i].onfocus = unblur
			}
		}
		if (browserName == "IE") {
			if (browserNew) {
				drops = document.getElementsByTagName("select");
			}
			else {
				drops = document.all.tags("select");
			}
			for(i=0; i<drops.length; i++) {
				drops[i].onfocus = unblur
			}
		}
	}
	
function preloadImage(imgObj,imgSrc) 
{
	if (document.images) 
	{
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
	}
}

function changeImage(layer,imgName,imgObj) 
{
	if (document.images) 
	{
		if (document.layers && layer!=null)
		{
			eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src');
			alert(layer);
			alert(imgName);
			alert(imgObj);
		}
		else
		{
			document.images[imgName].src = eval(imgObj+".src");
		}
	}
}

function showLayer(layID,value)
{
	document.getElementById(layID).style.visibility = value;
}

function popUp(desktopURL,windowName,width,height,scroll) 
{
		if (Macintosh) 
		{
			if (browserNameLong == "IE4") 
			{
				newheight = parseInt(height + 17);
			
			}
			else if (browserNameLong == "IE4.5") 
			{
				newheight = parseInt(height + 17);
			}
			else 
			{
				newheight = height;
			}
		}
		else 
		{ 
			newheight = height; 
		}
		
		if (scroll == '') 
		{ 
			scroll = 'no'; 
		}
		
		window.open(desktopURL, windowName, "toolbar=no,location=no,status=yes,menubar=no,scrollbars="+scroll+",width="+width+",height="+newheight+",resizable=no" );
}

function pageLoad() {
	winHeight 	= getWindowHeight();
	winWidth 	= getWindowWidth();
}

function reloadIt() {
	if (winHeight != getWindowHeight() || winWidth != getWindowWidth())
		document.location.replace(document.location);
}


function getWindowWidth() {
	if (isMinNS4) { 
		return window.innerWidth;
	} else if (isMinIE4 || isNS6 ) {
		return document.body.clientWidth;
	}
	return -1;
}

function getWindowHeight() {
	if (isMinNS4) { 
		return window.innerHeight;
	} else if (isMinIE4 || isNS6 ) {
		return document.body.clientHeight;
	}
	return -1;
}

function getImage(name) {
	if (isMinNS4) {
		return findImage(name, document);
	} else if (isMinIE4) {
		return eval('document.all.' + name);
	} else if (isNS6) {
		return document.getElementById(name);
	}
	return null;
}

function findImage(name, doc) {
	var i, img;
	for (i = 0; i < doc.images.length; i++) {
		if (doc.images[i].name == name) {
			return doc.images[i];
		}
	}
	for (i = 0; i < doc.layers.length; i++) {
		if ((img = findImage(name, doc.layers[i].document)) != null) {
			img.container = doc.layers[i];
			return img;
		}
	}
	return null;
}

function getImagePageLeft(img) {
	var x, obj;
	if (isMinNS4) {
		if (img.container != null) {
			return img.container.pageX + img.x;
		} else {
			return img.x;
		}
	} else if (isMinIE4 || isNS6 ) {
		x = 0;
		obj = img;
		if (obj != null) {
			do {
				x += obj.offsetLeft;
				obj = obj.offsetParent;
			} while (obj != null);
		}
		return x;
	}
	return -1;
}

function getImagePageTop(img) {
	var y, obj;
	if (isMinNS4) {
		if (img.container != null) {
			return img.container.pageY + img.y;
		} else {
			return img.y;
		}
	} else if (isMinIE4 || isNS6 ) {
		y = 0;
		obj = img;
		if (obj != null) {
			do {
				y += obj.offsetTop;
				obj = obj.offsetParent;
			} while (obj != null);
		}
		return y;
	}
	return -1;
}

function showMenu(layer) {
	document.getElementById(layer).style.visibility = 'visible';
}

function hideMenu(layer, pre, num) {
	for (i=1; i<=num; i++) {
		if (layer != '') {
			if (layer != pre+i) {
				document.getElementById(pre+i).style.visibility = 'hidden';
			}
		} else {
			document.getElementById(pre+i).style.visibility = 'hidden';
		}
	}
}

function delayhideMenu(layer, pre, num){
	delayhide=setTimeout("hideMenu('"+layer+"', '"+pre+"', "+num+")", 500);
}

function clearhideMenu(){
	clearTimeout(delayhide);
}

preloadImage('nav1','inc/images/navigation/nav1.gif');
preloadImage('nav1over','inc/images/navigation/nav1_over.gif');
preloadImage('nav3','inc/images/navigation/nav3.gif');
preloadImage('nav3over','inc/images/navigation/nav3_over.gif');
preloadImage('nav5','inc/images/navigation/nav5.gif');
preloadImage('nav5over','inc/images/navigation/nav5_over.gif');
preloadImage('nav7','inc/images/navigation/nav7.gif');
preloadImage('nav7over','inc/images/navigation/nav7_over.gif');
preloadImage('nav9','inc/images/navigation/nav9.gif');
preloadImage('nav9over','inc/images/navigation/nav9_over.gif');
preloadImage('nav10','inc/images/navigation/nav10.gif');
preloadImage('nav10over','inc/images/navigation/nav10_over.gif');