//  standard.js 
//  version 1.12
//  5/30/2000
//  author: Wesley S. Rast, GE Power Systems
//================begin browser detection
if (document.layers)
{
	var isNS4=true;
	var isNS5=false;
	var isIE4=false;
	var isIE5=false;
	var layerRef='document.layers.';
	var styleRef='';
}
if (document.all && navigator.appVersion.indexOf["MSIE 4"] != -1)
{
	var isNS4=false;
	var isNS5=false;
	var isIE4=true;
	var isIE5=false;
	var layerRef='document.all.';
	var styleRef='.style';
}
if (navigator.appName=="Netscape" && parseInt(navigator.appVersion)==5)
{
	var isNS4=false;
	var isNS5=true;
	var isIE4=false;
	var isIE5=false;
}
if (navigator.appVersion.indexOf("MSIE 5") != -1) 
{
	var isNS4=false;
	var isNS5=false;
	var isIE4=false;
	var isIE5=true;
}
//================end browser detection


//================begin misc functions
function doNothing(){/*for making null links*/}

function debugObject(objectToDebug)
{
//str objectToDebug; -- cycles and alerts through all subobject names in an object.
	eval('var tempObj='+objectToDebug);
	var counter=1;
	var alertString='';
	for (x in tempObj)
	{
		alertString+='Object '+counter+' inside the object '+objectToDebug+' is: '+x+'\n';
		counter++;
		if (counter%50==0)
		{
			alert(alertString);
			alertString='';
		}
	}
	alert(alertString);
}
//================end misc functions

//================begin dynamic layer functions

function changeBgColor(thisLayerName,newColor)
{
//changes a layer's background color
	if (isNS4) eval(layerRef+thisLayerName+styleRef+'.bgColor=newColor');
	else if (isIE4) eval(layerRef+thisLayerName+styleRef+'.backgroundColor=newColor');
	else if (isIE5 || isNS5)
	{
		document.getElementById(thisLayerName).style.backgroundColor=newColor;
	}
}

function changeClip(thisLayerName,newTop,newRight,newBottom,newLeft)
{
//changes all 4 layer clipping values
	if (isNS4)
	{
		eval(layerRef+thisLayerName+'.clip.top=newTop');
		eval(layerRef+thisLayerName+'.clip.right=newRight');
		eval(layerRef+thisLayerName+'.clip.bottom=newBottom');
		eval(layerRef+thisLayerName+'.clip.left=newLeft');
	}
	else if (isIE4)
	{
		eval(layerRef+thisLayerName+styleRef+'.clip="rect('+newTop+'px '+newRight+'px '+newBottom+'px '+newLeft+'px)"');
	}
	else if (isNS5 || isIE5)
	{
//error: ns5 clip format is unknown.
		document.getElementById(thisLayerName).style.clip="rect("+newTop+"px "+newRight+"px "+newBottom+"px "+newLeft+"px)";
	}
}

function changeLayerHTML(thisLayerName,newHTMLString)
{
//str thisLayerName; str newHTMLString; -- rewrites the HTML contents of a layer
	if (isNS4)
	{
		eval('document.'+thisLayerName+'.document.write(newHTMLString)');
		eval('document.'+thisLayerName+'.document.close()');
	}
	else if (isIE4)
	{
		eval('document.all.'+thisLayerName+'.innerHTML=newHTMLString');
	}
	else if (isIE5)
	{
		document.getElementById(thisLayerName).innerHTML=newHTMLString;
	}
	else if (isNS5)
	{
//error: ns5 crashes when page is reloaded after running this script.
		var tempNode=document.createTextNode(newHTMLString);
		eraseChildren(thisLayerName);
		document.getElementById(thisLayerName).appendChild(tempNode);
	}
}

function changeVisible(layerName,toWhat)
{
//takes a string: "layerName", and a boolean: "toWhat", and makes the associated layer visible or hidden
	var visibilityString;
	(toWhat)?visibilityString='visible':visibilityString='hidden';
	if (isNS4 || isIE4)
	{
		eval(layerRef+layerName+styleRef+'.visibility="'+visibilityString+'"');
	}
	else if (isNS5 || isIE5)
	{
		document.getElementById(layerName).style.visibility=visibilityString;
	}
}

function changeZIndex(thisLayerName,toWhat)
{
//changes the z-index. duh. :P
//note: negative values seem to not work in NS4
	if (isNS4 || isIE4)
	{
		eval(layerRef+thisLayerName+styleRef+'.zIndex='+toWhat);
	}
	else if (isNS5 || isIE5)
	{
		document.getElementById(thisLayerName).style.zIndex=toWhat;
	}
}

function createCSS()
{
//loops through the parameter list, writing style sheet id's for each parameter
	document.write('<style>');
	for (x=0;x<createCSS.arguments.length;x++)
	{
		createLayerCSS(createCSS.arguments[x]);
	}
	document.write('</style>');
}

function createLayerCSS(thisLayerName)
{
//writes necessary stylesheet info in the header section of the html document
	document.write('\n#'+thisLayerName+' {position:absolute;visibility:hidden;}');
}


var htmlBin="";
function createLayerHTML(thisLayerName,contentString)
{
//writes necessary html in the body of the html document.
	document.write('<div id="'+thisLayerName+'">\n'+contentString+'\n</div>\n');
	htmlBin+='<div id="'+thisLayerName+'">\n'+contentString+'\n</div>\n';
//htmlBin var is for alert debugging of dynamically written html. Simply use alert(htmlBin); wherever required.
}

function eraseChildren(objectToErase)
{
//erases all children of a particular Node. Only works in W3C DOM level 1-capable browsers
//error: seems to not erase some of the invisible content nodes, as evidenced by NS5's tendency to leave the line breaks in the test page. HTML tags?
	var timesToLoop=document.getElementById(objectToErase).childNodes.length;
	for (x=0;x<timesToLoop;x++)
	{
		if (document.getElementById(objectToErase).childNodes[x])
		{
			document.getElementById(objectToErase).removeChild(document.getElementById(objectToErase).childNodes[x]);
		}
	}
}

function getAll(thisLayerName)
{
	var tempString='Layer '+thisLayerName+' values are:\n';
	if (isIE4)
	{
		tempString+='background color is: '+document.all[thisLayerName].style.backgroundColor+'\n';
		tempString+='z Index is: '+document.all[thisLayerName].style.zIndex+'\n';
		tempString+='top position is: '+document.all[thisLayerName].style.top+'\n';
		tempString+='left position is: '+document.all[thisLayerName].style.left+'\n';
		tempString+='width is: '+document.all[thisLayerName].style.width+'\n';
		tempString+='height is: '+document.all[thisLayerName].style.height+'\n';
		tempString+='clip is: '+document.all[thisLayerName].style.clip+'\n';
		tempString+='visibility is: '+document.all[thisLayerName].style.visibility+'\n';
	}
	else if (isNS4)
	{
		tempString+='bgColor is: '+document.layers[thisLayerName].bgColor+'\n';
		tempString+='z-Index is: '+document.layers[thisLayerName].zIndex+'\n';
		tempString+='top position is: '+document.layers[thisLayerName].top+'\n';
		tempString+='left position is: '+document.layers[thisLayerName].left+'\n';
		tempString+='width is: '+document.layers[thisLayerName].width+'\n';
		tempString+='height is: '+document.layers[thisLayerName].height+'\n';
		tempString+='top clip is: '+document.layers[thisLayerName].clip.top+'\n';
		tempString+='right clip is: '+document.layers[thisLayerName].clip.right+'\n';
		tempString+='bottom clip is: '+document.layers[thisLayerName].clip.bottom+'\n';
		tempString+='left clip is: '+document.layers[thisLayerName].clip.left+'\n';
		tempString+='visibility is: '+document.layers[thisLayerName].visibility+'\n';
	}
	if (isNS5 || isIE5)
	{
		tempString+='background color is: '+document.getElementById(thisLayerName).style.backgroundColor+'\n';
		tempString+='z Index is: '+document.getElementById(thisLayerName).style.zIndex+'\n';
		tempString+='top position is: '+document.getElementById(thisLayerName).style.top+'\n';
		tempString+='left position is: '+document.getElementById(thisLayerName).style.left+'\n';
		tempString+='width is: '+document.getElementById(thisLayerName).style.width+'\n';
		tempString+='height is: '+document.getElementById(thisLayerName).style.height+'\n';
		tempString+='clip is: '+document.getElementById(thisLayerName).style.clip+'\n';
		tempString+='visibility is: '+document.getElementById(thisLayerName).style.visibility+'\n';
	}
	alert(tempString);
}

function getClipValue(thisObjectName,thisClip)
{
//returns a single layer clipping value--top, right, bottom or left.
	if (isNS4 || isIE4)
	{
		var thisObject=eval(layerRef+thisObjectName+styleRef);
	}
	else if (isNS5 || isIE5)
	{
		var thisObject=document.getElementById(thisObjectName).style;
	}
	if (isNS4) {
		if (thisClip=='t') return thisObject.clip.top;
		if (thisClip=='r') return thisObject.clip.right;
		if (thisClip=='b') return thisObject.clip.bottom;
		if (thisClip=='l') return thisObject.clip.left;
	}
	else if (isIE4 || isIE5)
	{
		var clipArray = thisObject.clip.match(/\d+/g);
		if (thisClip=='t') return parseInt(clipArray[0]);
		if (thisClip=='r') return parseInt(clipArray[1]);
		if (thisClip=='b') return parseInt(clipArray[2]);
		if (thisClip=='l') return parseInt(clipArray[3]);
	}
	else if (isNS5)
	{
//error: format of clip values for NS5 to be determined
	}
}

function getHeight(thisLayerName)
{
//returns the width of the layer
	if (isNS4 || isIE4)
	{
		var tempHeight=eval(layerRef+thisLayerName+styleRef+'.height');
		if (isIE4)
		{
			var tempArray=tempHeight.match(/\d+/);
			tempHeight=parseInt(tempArray[0]);
		}
		else
		{
			var tempArray=new Array(tempHeight);
		}
	}
	if (isNS5 || isIE5)
	{
		var tempHeight=document.getElementById(thisLayerName).style.height;
		var tempArray=tempHeight.match(/\d+/);
		tempHeight=parseInt(tempArray[0]);
	}
	return tempHeight;
}

function getPositionLeft(thisLayerName)
{
//returns an integer equalling the x coordinate of the upper-left corner of the layer
	var tempPositionLeft;
	var matchArray;
	var thisLayerObj=layerRef+thisLayerName+styleRef;
	if (isNS4)
	{
		tempPositionLeft=eval(thisLayerObj+'.left');
	}
	else if (isIE4)
	{
		tempPositionLeft=eval(thisLayerObj+'.left');
		matchArray=tempPositionLeft.match(/\d+/);
		tempPositionLeft=parseInt(matchArray[0]);
	}
	else if (isNS5 || isIE5)
	{
		tempPositionLeft=document.getElementById(thisLayerName).style.left;
		matchArray=tempPositionLeft.match(/\d+/);
		tempPositionLeft=parseInt(matchArray[0]);
	}
	return tempPositionLeft;
}

function getPositionTop(thisLayerName)
{
//returns an integer equalling the y coordinate of the upper-left corner of the layer
	var tempPositionTop;
	var matchArray;
	var thisLayerObj=layerRef+thisLayerName+styleRef;
	if (isNS4)
	{
		tempPositionTop=eval(thisLayerObj+'.top');
	}
	else if (isIE4)
	{
		tempPositionTop=eval(thisLayerObj+'.top');
		matchArray=tempPositionTop.match(/\d+/);
		tempPositionTop=parseInt(matchArray[0]);
	}
	else if (isNS5 || isIE5)
	{
		tempPositionTop=document.getElementById(thisLayerName).style.top;
		matchArray=tempPositionTop.match(/\d+/);
		tempPositionTop=parseInt(matchArray[0]);
	}
	return tempPositionTop;
}

function getWidth(thisLayerName)
{
//returns the width of the layer
	if (isNS4 || isIE4)
	{
		var tempWidth=eval(layerRef+thisLayerName+styleRef+'.width');
		if (isIE4)
		{
			var tempArray=tempWidth.match(/\d+/);
			tempWidth=parseInt(tempArray[0]);
		}
		else
		{
			var tempArray=new Array(tempWidth);
		}
	}
	if (isNS5 || isIE5)
	{
		var tempWidth=document.getElementById(thisLayerName).style.width;
		var tempArray=tempWidth.match(/\d+/);
		tempWidth=parseInt(tempArray[0]);
	}
	return tempWidth;
}

function getVisibility(thisLayerName)
{
//returns the visibility
	if (isNS4 || isIE4) return eval(layerRef+thisLayerName+styleRef+'.visibility');
	else if (isNS5 || isIE5) return document.getElementById(thisLayerName).style.visibility;
}

function getZIndex(thisLayerName)
{
//returns the z-index
	if (isNS4 || isIE4) return eval(layerRef+thisLayerName+styleRef+'.zIndex');
	else if (isNS5 || isIE5) return document.getElementById(thisLayerName).style.zIndex;
}

function initLayer(layerId,thisBgColor,thisZIndex,topPos,leftPos,thisWidth,thisHeight,clipTop,clipRight,clipBottom,clipLeft,thisVis)
{
	if (isNS4) prop=document.layers[layerId];
	else if (isIE4 || isIE5) prop=document.all[layerId].style;
	else if (isIE5 || isNS5) prop=document.getElementById(layerId).style;

	(isNS4)?prop.bgColor=thisBgColor:prop.backgroundColor=thisBgColor;
	prop.zIndex=thisZIndex;
	prop.left=leftPos;
	prop.top=topPos;
	prop.width=thisWidth;
	prop.height=thisHeight;
	if (isNS4)
	{
		prop.clip.top=clipTop;
		prop.clip.right=clipRight;
		prop.clip.bottom=clipBottom;
		prop.clip.left=clipLeft;
	}
	else
	{
		prop.clip="rect("+clipTop+"px "+clipRight+"px "+clipBottom+"px "+clipLeft+"px)";
	}
	prop.visibility=thisVis;
}

function moveLayerAbs(thisLayerName,newLeftPosition,newTopPosition)
{
//moves a layer based on the absolute coordinate system of the layer's parent.
	if (isNS4 || isIE4)
	{
		eval(layerRef+thisLayerName+styleRef+'.left='+newLeftPosition);
		eval(layerRef+thisLayerName+styleRef+'.top='+newTopPosition);
	}
	else if (isNS5 || isIE5)
	{
		document.getElementById(thisLayerName).style.left=newLeftPosition;
		document.getElementById(thisLayerName).style.top=newTopPosition;
	}
}

function moveLayerRel(thisLayerName2,leftModify,topModify)
{
//moves a layer relative to it's current position.
	var currentLeft;
	var currentTop;
	if (isNS4 || isIE4)
	{
		var thisLayerObj=layerRef+thisLayerName2+styleRef;
		(isNS4)?currentLeft=eval(thisLayerObj+'.left'):currentLeft=eval(thisLayerObj+'.pixelLeft');
		(isNS4)?currentTop=eval(thisLayerObj+'.top'):currentTop=eval(thisLayerObj+'.pixelTop');
		eval(thisLayerObj+'.left=(currentLeft+leftModify)');
		eval(thisLayerObj+'.top=(currentTop+topModify)');
	}
	else if (isNS5 || isIE5)
	{
		document.getElementById(thisLayerName2).style.left=getPositionLeft(thisLayerName2)+leftModify;
		document.getElementById(thisLayerName2).style.top=getPositionTop(thisLayerName2)+topModify;
	}
}

function slide(thisLayerName,leftMove,topMove,numberOfFrames,delay)
{
//slides a layer incrementally by x[leftmove] and y[topMove] over a certain number of times with a specified delay between each step
	if (numberOfFrames>0)
	{
		moveLayerRel(thisLayerName,leftMove,topMove);
		setTimeout('slide("'+thisLayerName+'",'+leftMove+','+topMove+','+(numberOfFrames-1)+','+delay+')',delay);
	}
}

function slideTo(thisLayerName,newLeft,newTop,numberOfSteps,timeDelay)
{
//same as slide(), but uses an absolute new position
	var stepXDistance=(newLeft-getPositionLeft(thisLayerName))/numberOfSteps;
	var stepYDistance=(newTop-getPositionTop(thisLayerName))/numberOfSteps;
	slide(thisLayerName,stepXDistance,stepYDistance,numberOfSteps,timeDelay);
}
//================end dynamic layer functions
  