﻿// JScript File

function getElementById(divID,oDoc)
{
	if (document.getElementById)
		return document.getElementById(divID);
	if (document.all)
		return document.all[divID];
	if (!oDoc)
		oDoc = document;
	if (document.layers)
	{
		if (oDoc.layers[divID])
			return oDoc.layers[divID];
		else
		{
			//repeatedly run through all child layers
			for (var x = 0, y; !y && x < oDoc.layers.length; x++)
			{
				//on success, return that layer, else return nothing
				y = getRefToDiv(divID,oDoc.layers[x].document);
			}
			return y;
		}
	}
	return false;
}

function changeCssRule(rule, property, newValue)
{
	var cssRules;
	if (document.all)
		cssRules = "rules";
	else
	if (document.getElementById)
		cssRules = "cssRules";
			
	for (var sheetIndex = 0; sheetIndex < document.styleSheets.length; sheetIndex ++)
	{
		var styleSheet = document.styleSheets[sheetIndex];			
		for (var ruleIndex = 0; ruleIndex < styleSheet[cssRules].length; ruleIndex ++)
		{
			var styleSheetRule = styleSheet[cssRules][ruleIndex];
			if (styleSheetRule.selectorText == rule)
			{
				if (styleSheetRule.style)
					styleSheetRule.style[property] = newValue;
				else
					styleSheetRule[property] = newValue;
			}
		}
	}
}

function swapImage(imgElement, newImageUrl)
{
	if (imgElement.src)
	{
		imgElement.src = newImageUrl;
	}
}