//
// ESTABLISH BROWSER AND PLATFORM
// ADAPTED FROM NETSCAPE WITH PERMISSION
//

var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

var is_nav    = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1));
var is_nav4   = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_nav5   = (is_nav && (is_major == 5));
var is_nav5up = (is_nav && (is_major >= 5));

var is_ie    = (agt.indexOf("msie") != -1);
var is_ie4   = (is_ie && (is_major == 4) && (agt.indexOf("msie 5")==-1) );
var is_ie4up = (is_ie && (is_major >= 4));
var is_ie5   = (is_ie && (is_major == 4) && (agt.indexOf("msie 5")!=-1) );
var is_ie5up = (is_ie && !is_ie4);

var is_aol   = (agt.indexOf("aol") != -1);
var is_aol4  = (is_aol && is_ie4);

var is_opera = (agt.indexOf("opera") != -1);
var is_webtv = (agt.indexOf("webtv") != -1);

var is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_mac = (agt.indexOf("mac")!=-1);

var nscp4 = is_nav4
var ie4   = is_ie4
var dom1  = (is_nav5up || is_ie5up)

if (is_mac && is_ie5)
{	dom1 = false
}



var x1 = 0;
var y1 = 0;
var bgLg;
var imgout;

//
// CREATE APPROPRIATE OBJECT
//

var res;
var feat;
var intpg;

tnv1on = new Image();
tnv2on = new Image();
tnv3on = new Image(); 
tnv4on = new Image(); 
tnv5on = new Image();
tnv1off = new Image();
tnv2off = new Image();
tnv3off = new Image(); 
tnv4off = new Image(); 
tnv5off = new Image(); 

function imageLoad()
{
	if (document.images)
		{
			tnv1on.src = "../images/topnav/our_co_on.gif"
			tnv2on.src = "../images/topnav/res_dev_on.gif" 
			tnv3on.src = "../images/topnav/sol_srv_on.gif"
			tnv4on.src = "../images/topnav/all_on.gif"
			tnv5on.src = "../images/topnav/new_evnt_on.gif" 
		}	
			tnv1off.src = "../images/topnav/our_co_off.gif"
			tnv2off.src = "../images/topnav/res_dev_off.gif" 
			tnv3off.src = "../images/topnav/sol_srv_off.gif"
			tnv4off.src = "../images/topnav/all_off.gif"
			tnv5off.src = "../images/topnav/new_evnt_off.gif" 
	
	
}

function imageLoadInt()
{
	if (document.images)
		{
			tnv1on.src = "../../images/topnav/our_co_on.gif"
			tnv2on.src = "../../images/topnav/res_dev_on.gif" 
			tnv3on.src = "../../images/topnav/sol_srv_on.gif"
			tnv4on.src = "../../images/topnav/all_on.gif"
			tnv5on.src = "../../images/topnav/new_evnt_on.gif" 
		}	
			tnv1off.src = "../../images/topnav/our_co_off.gif"
			tnv2off.src = "../../images/topnav/res_dev_off.gif" 
			tnv3off.src = "../../images/topnav/sol_srv_off.gif"
			tnv4off.src = "../../images/topnav/all_off.gif"
			tnv5off.src = "../../images/topnav/new_evnt_off.gif" 
	
	
}


function homeImageLoad()
{if (document.images)
		{
			tnv1on.src = "images/topnav/our_co_on.gif"
			tnv2on.src = "images/topnav/res_dev_on.gif" 
			tnv3on.src = "images/topnav/sol_srv_on.gif"
			tnv4on.src = "images/topnav/all_on.gif"
			tnv5on.src = "images/topnav/new_evnt_on.gif" 
		}	
			tnv1off.src = "images/topnav/our_co_off.gif"
			tnv2off.src = "images/topnav/res_dev_off.gif" 
			tnv3off.src = "images/topnav/sol_srv_off.gif"
			tnv4off.src = "images/topnav/all_off.gif"
			tnv5off.src = "images/topnav/new_evnt_off.gif" 
	
	
}


function handleResize()
{	
	if(res != browserWidth())
	{
	location.reload()
	}
	
	return false
}


function imgOn(layerName,imgName)
{	if (nscp4)
	{	
		eval("document." + layerName + ".document[imgName].src = " + imgName + "on.src");
	}
	else if(dom1)
	{	
		document.getElementById(imgName).src = eval(imgName + "on.src");
	}
	else 
	{
		document [imgName].src = eval(imgName + "on.src");
	}
}

function imgOff(layerName,imgName)
{	if (nscp4)
	{	
		eval("document." + layerName + ".document[imgName].src = " + imgName + "off.src");
	}
	else if(dom1)
	{	
		document.getElementById(imgName).src = eval(imgName + "off.src");
	}
	else 
	{
		//alert("on ie");
		document [imgName].src = eval(imgName + "off.src");
	}
}

function getObj(obj)
{	if (dom1)
	{	compLayr = document.getElementById(obj).style
	}
	else if (nscp4)
	{	compLayr = document.layers[obj]
	}
	else
	{	compLayr = document.all[obj].style
	}
	return compLayr
}

//
// CUSTOM APIs
//


function setTop(layr,num)
{	obj = getObj(layr)
	obj.top = num
}

function setLeft(layr,num)
{	obj = getObj(layr)
	obj.left = num
}

function getTop(layr)
{	obj = getObj(layr)
	if (dom1)
	{	return (document.getElementById(layr).offsetTop)
	}
	else if (nscp4)
	{	return (obj.top)
	}
	else
	{	return (obj.posTop)
	}
}

function getLeft(layr)
{	obj = getObj(layr)
	if (dom1)
	{	return (document.getElementById(layr).offsetLeft)
	}
	else if (nscp4)
	{	return (obj.left)
	}
	else
	{	return (obj.posLeft)
	}
}

function incTop(layr,num)
{	obj = getObj(layr)
	obj.top = getTop(layr) + num
}

function incLeft(layr,num)
{	obj = getObj(layr)
	obj.left = getLeft(layr) + num
}

function setZindex(layr,num)
{	obj = getObj(layr)
	obj.zIndex = num
}

function show(layr)
{	obj = getObj(layr)
	obj.visibility = "visible"
}

function hide(layr)
{	obj = getObj(layr)
	obj.visibility = "hidden"
}

function layerWidth(layr)
{	if (dom1)
	{	return (document.getElementById(layr).offsetWidth)
	}
	else if (nscp4)
	{	return eval("document." + layr + ".document.width")
	}
	else
	{	return (document.all[layr].scrollWidth)
	}
}
	
function layerHeight(layr)
{	if (dom1)
	{	return (document.getElementById(layr).offsetHeight)
	}
	else if (nscp4)
	{	return eval("document." + layr + ".document.height")
	}
	else
	{	return (document.all[layr].scrollHeight)
	}
}

function layerClip(layr,topA,rightA,bottomA,leftA)
{	obj = getObj(layr)
	if (dom1 || (ie4 && !is_mac))
	{	obj.clip = "rect(" + topA + " " + rightA + " " + bottomA + " " + leftA + ")"
	}
	else if (nscp4)
	{	obj.clip.top = topA
		obj.clip.left = leftA
		obj.clip.bottom = bottomA
		obj.clip.right = rightA
	}
	else if (ie4 && is_mac)
	{	obj.clip = "rect(0 100% 100% 0)"
	}
}

function browserWidth()
{	if (is_nav)
	{	return (window.innerWidth)
	}
	else
	{	return (document.body.clientWidth)
	}
}

function browserHeight()
{	if (is_nav)
	{	return (window.innerHeight)
	}
	else
	{	return (document.body.clientHeight)
	}
}

function homeInit()
{
	var res = browserWidth();
	if (nscp4)
	{
		window.onresize = handleResize
	}
	homeImageLoad();
	trackMouse();
}
function init(pg)
{
	var res = browserWidth();
	if (nscp4)
	{
		window.onresize = handleResize
	}
	if(pg == 'int')
	{
		imageLoadInt();
	}
	else
	{
	imageLoad();
	}
	trackMouse();
}
 function openWin(url,x,y){
	if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=800;

    var xOffset = (xMax - x)/2, yOffset = (yMax - y)/2;
	window.open(url,'futureWin','width='+x+',height='+y+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',resizable=yes,status=yes,scrollbars,toolbar=yes');
}

function openWinMenuLess(url,x,y,resizable,status,scrollbars,toolbar,location,menubar){
	if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=800;

    var xOffset = (xMax - x)/2, yOffset = (yMax - y)/2;
	window.open(url,'futureWin','width='+x+',height='+y+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',resizable=no,status=no,scrollbars=no,toolbar=no,location=no,menubar=no');
}

function closeWin()
{
	window.close();
}

var imgourcoon;
var imgreson;
var imgsolon;

function showIt(lay)	
{
	if(lay == 1)
	{
		imgOn('topnv', 'tnv1'); 
		show('ourcoon');
		 hide('reson');
		imgourcoon = true;
	 }
	if(lay == 2)
	{
		imgOn('topnv', 'tnv2'); 
		show('reson');
		hide('ourcoon');
		imgreson = true;
	}
	if(lay == 3)
	{
		imgOn('topnv', 'tnv3'); 
		show('solon');
		imgsolon = true;
	}
}
var x1 = 0;
var y1 = 0;

function trackMouse()
{	if (nscp4)
	{	document.captureEvents(Event.MOUSEMOVE)
	}
	document.onmousemove = getCoordinates
	checkIt()
}

function getCoordinates(evt)
{	x1 = (is_nav) ? evt.pageX : event.clientX + document.body.scrollLeft
	y1 = (is_nav) ? evt.pageY : event.clientY + document.body.scrollTop
}

function checkIt()	
{	
	if(imgourcoon == true)
	{
		if (((x1 < 123) || (x1 > 251)) || ((y1 < 51) || (y1 > 176)))
		{
		   imgOff
		   ('topnv', 'tnv1'); 
		   hide('ourcoon');
		   imgourcoon = false;
		}
	}
	if(imgreson == true)
	{		
		if (((x1 < 229) || (x1 > 404)) || ((y1 < 51) || (y1 > 193)))
		{
		   imgOff('topnv', 'tnv2'); 
		   hide('reson');
		   imgreson = false;
		 }
	}
	if(imgsolon == true)
	{		
		if (((x1 < 403) || (x1 > 550)) || ((y1 < 51) || (y1 > 235)))
		{
		   imgOff('topnv', 'tnv3');
		   hide('solon'); 
		   imgsolon = false;
		 }
	}
	setTimeout("checkIt()",10)
}


function setBotNv(intLay,topcnt,ht)
{
	
	
	cntht = layerHeight(intLay);
	btnv = cntht + topcnt - ht;		
	if(cntht < 500)
	{
		setTop('copyrt',710);
		show('copyrt');
	}
	else
	{
	setTop('copyrt',btnv);
	show('copyrt');
	}
}
