// This script is Copyrighted 2001-2004 by www.dvdesign.com /
// All part of this Java Script is Copyrighted. Do not use without permission. /

Agent = window.navigator.userAgent;
Version = parseInt(Agent.charAt(Agent.indexOf("/")+1),10);
var visLayers = new Array();
var lastSubLayer = null;
var numVisLayers = -1;
var retrunSrcImage = null;
var retrunNameImage = null;
var timerName = null;
var CSIImg=false;
var CSDInit=false;
var CSIsW3CDOM = ((document.getElementById) && !(IsIE()&&Version<6)) ? true : false;

preloadImages ();

/*********************************/
function IsIE()			{ return Agent.indexOf("MSIE") > 0;			}
function IEStyl(s)		{ return document.all.tags("div")[s].style; }
function NSStyl(s)		{
	if (CSIsW3CDOM)
		return document.getElementById(s).style;
	else
		return FindElement(s,0);  
}

function CSGetImage(n) {if(document.images) {return ((!IsIE()&&Version<5)?FindElement(n,0):document.images[n]);} else {return null;}}
/*********************************/
function CSIDOM() {
	if (CSDInit)	
		return;
	CSDInit=true;
	if(document.getElementsByTagName) {
		var n = document.getElementsByTagName('DIV');
		for (var i=0;i<n.length;i++) {
			CSICSS2Prop(n[i].id);
		}
	}
}

/*********************************/
function CSICSS2Prop(id) {
	var n = document.getElementsByTagName('STYLE');
	for (var i=0;i<n.length;i++) {
		var cn = n[i].childNodes;
		for (var j=0;j<cn.length;j++) {
			CSSetCSS2Props(CSFetchStyle(cn[j].data, id),id);
		}
	}
}

/*********************************/
function CSGetStyleAttrValue (si, id) {
	var s=si.toUpperCase();
	var myID=id.toUpperCase()+":";
	var id1=s.indexOf(myID);
	if (id1==-1) return "";
	s=s.substring(id1+myID.length+1,si.length);
	var id2=s.indexOf(";");
	return ((id2==-1)?s:s.substring(0,id2));
}

/*********************************/
function CSSetCSS2Props(si, id) {
	var el=document.getElementById(id);
	if (el==null) return;
	var style=document.getElementById(id).style;
	if (style) {
		if (style.left=="") style.left=CSGetStyleAttrValue(si,"left");
		if (style.top=="") style.top=CSGetStyleAttrValue(si,"top");
		if (style.width=="") style.width=CSGetStyleAttrValue(si,"width");
		if (style.height=="") style.height=CSGetStyleAttrValue(si,"height");
		if (style.visibility=="") style.visibility=CSGetStyleAttrValue(si,"visibility");
		if (style.zIndex=="") style.zIndex=CSGetStyleAttrValue(si,"z-index");
	}
}


/*********************************/
function cleanUpLayers ()
{
	if (numVisLayers == -1)
		return;
	if (retrunSrcImage != null)
	{
		SetImageURL (retrunNameImage, retrunSrcImage);
		retrunSrcImage = null;
		retrunNameImage = null;
	}
	for (i = 0; i <= numVisLayers; i ++)
	{
		var item = visLayers[i];
		SetStyleVis (item, 0);
		visLayers[i] = null;
	}
	numVisLayers = -1;
	lastSubLayer = null;
}

/*********************************/
function hideLastLayer ()
{
	temp = visLayers[numVisLayers];
	var item = null;
	SetStyleVis (temp, 0);
		
	visLayers[numVisLayers] = null;
	numVisLayers--;
	lastSubLayer = null;
}

/*********************************/
function showLayer(s, doClear, imageName, origPath, newPath)
{
	if (doClear == 1)
		cleanUpLayers ();

	SetStyleVis (s, 1);

	if (origPath != "") {
		SetImageURL(imageName, newPath);
		retrunSrcImage = origPath;
		retrunNameImage = imageName;
	}
	addToArray (s);
	stopTimeOut();
}

/*********************************/
function SetStyleVis(s,v) {
	if (CSIsW3CDOM){
		CSIDOM();
		document.getElementById(s).style.visibility=(v==0)?"hidden":"visible";
	}
	else if(IsIE())
		IEStyl(s).visibility=(v==0)?"hidden":"visible";
	else
		NSStyl(s).visibility=(v==0)?'hide':'show';
}

/*********************************/
function showSubLayer(s)
{
	if (lastSubLayer != null)
		hideLastLayer();
	var item = null;
	SetStyleVis (s, 1);

	addToArray (s);
	lastSubLayer = s;
}

/*********************************/
function addToArray (item)
{
	var found = false;
	if (numVisLayers == -1) {
		visLayers[++numVisLayers] = item;
		return;
	}
	for (i = 0; i <= numVisLayers; i ++) {
		if (visLayers[i] == item)
			found = true;
	}
	if (! found)
		visLayers[++numVisLayers] = item;
}

/*********************************/
function hideLayer(s) {
	SetStyleVis (s, 0);
}

/*********************************/
function button_over (name, path, classid )
{
	showLayer( classid , 0); 
	//SetImageURL (name, path);
	return true;
}

/*********************************/
function button_out(name, path, classid )
{
	hideLayer( classid ); 
	//SetImageURL (name, path);
	return true;
}

/*********************************/
function SetImageURL (name, path) {
	var img = null;
	if (document.images) {
		if(document.images) {
			img =  ((!IsIE()&&Version<5)?FindElement(name,0):document.images[name]);
		} else {
			img = null;
		}
		if (img !== null) {
			img.src = path;
		}
	}
}

/*********************************/
function startTimeOut() {
	timerName = setTimeout ("timeProc()", 200);
}

/*********************************/
function stopTimeOut() {
	if (timerName != null) {
		clearTimeout (timerName);
		timerName = null;
	}
}

/*********************************/
function timeProc () {
	cleanUpLayers();
	timerName = null;
}

function preloadImages () {
	if (document.images) {
		Image1 = new Image();
		Image2 = new Image();
		Image3 = new Image();
		Image4 = new Image();
		Image5 = new Image();
		Image6 = new Image();
		Image7 = new Image();
		Image8 = new Image();
		Image9 = new Image();
		Image1.src = 'images/nav/home2.gif';
		Image2.src = 'images/nav/shareperf2.gif';
		Image3.src = 'images/nav/contact2.gif';
		Image4.src = 'images/nav/new2.gif';
		Image5.src = 'images/nav/company2.gif';
		Image6.src = 'images/nav/operations2.gif';
		Image7.src = 'images/nav/investors2.gif';
		Image8.src = 'images/nav/pressroom2.gif';
		Image9.src = 'images/nav/respons2.gif';
	}
}
/*********************************/
function FindElement (n,ly)
{
	if (Version < 4)
		return document[n];
	if (CSIsW3CDOM) {
		CSInitImgID();
		return(document.getElementById(n));
	}

	var curDoc = ly ? ly.document : document;
	var elem = curDoc[n];
	if (!elem)
	{
		for (var i=0;i<curDoc.layers.length;i++)
		{
			elem = FindElement(n,curDoc.layers[i]);
			if (elem)
				return elem;
		}
	}
	return elem;
}

/*********************************/
function CSInitImgID() {
	if (!CSIImg && document.images) {
		for (var i=0; i<document.images.length; i++) {	
			if (!document.images[i].id)
				document.images[i].id=document.images[i].name;
		}
	CSIImg = true;
	}
}
