// determine what browser is being used
var IE5 = (document.all) ? true : false;
var N6 = (document.getElementById && !document.all) ? true : false;
function getVariable(strId)
{
	var retVal;
	if(N6)
	{
		retVal = document.getElementById(strId);
		/*
		if(retVal == null)
		{
			var items = document.getElementsByName(strId);
			if(items.length > 0)
				retVal = items[0];
		}
		*/
	}
	else if(IE5)
		retVal = document.all[strId];
	else 
		retVal = document.all[strId];
	
	return retVal;
}

function randRange(maxVal)
{
	return Math.round(maxVal * Math.random());
}

var currentBlinker = null;
function doBlink(obj, type)
{
	currentBlinker = setInterval("blinkText('" + obj + "', '" + type + "')", 500);
}

function blinkText(obj, type)
{
	if(type == "solid")
	{
		if(getVariable(obj).style.visibility == "hidden")
			getVariable(obj).style.visibility = "visible";
		else
			getVariable(obj).style.visibility = "hidden";
	}
}

function checkLength(length)
{
	if(window.event.srcElement.value.length  >= length)
	{
		alert("You have reached the maximum length of " + length + " characters permitted here.");
		return false;
	}
}

function href_stripQueryString(href)
{
	var retVal = href;
	if(href.indexOf('?') >= 0)
		retVal = href.substring(0, href.indexOf('?'));
	return retVal;
}

function href_appendQueryString(href, varName, varValue)
{
	if(href.indexOf('?') >= 0)
		href += "&" + varName + "=" + varValue;
	else
		href += "?" + varName + "=" + varValue;
	return href;
}

function href_goto(href)
{
	if(href.length > 0)
		window.open(href);
}


function highlightBox(id, doHighlight)
{
	if(typeof(getVariable(id).highlight_origColor) == "undefined")
		getVariable(id).highlight_origColor = getVariable(id).style.backgroundColor;
	
	getVariable(id).style.backgroundColor = doHighlight ? "white" : getVariable(id).highlight_origColor;
}

function dummy(){}


/*
	Programatically jumps to an anchor on the page
*/
function jumpToAnchor(anchorName) 
{
	window.location = String(window.location).replace(/\#.*$/, "") + "#" + anchorName;
}

if(typeof(HTMLElement) != "undefined")
{
	HTMLElement.prototype.click = function() 
	{
		var evt = this.ownerDocument.createEvent('MouseEvents');
		evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
		this.dispatchEvent(evt);
	}
}
function jumpToAnchor_fromLink(theLink)
{
	var hyperlink = document.getElementById(theLink);
	hyperlink.click();
}


var iframe_counter = 1;
function iframe_request()
{
	var iframe_loader = document.createElement("iframe");
	var iframe_id = "iframe_loader_" + iframe_counter++;
	iframe_loader.id = iframe_id;
	iframe_loader.name = iframe_id;
	//iframe_loader.style.position = "absolute";
	iframe_loader.style.left = 0;
	iframe_loader.style.top = 0;
	iframe_loader.style.border = "0px";
	iframe_loader.style.width = "500px";
	iframe_loader.style.height = "300px";
	iframe_loader.style.display = "none";
	
	document.body.appendChild(iframe_loader);
	return iframe_id;
}

function getFrame(id)
{
	return getVariable(id).contentWindow;
}

function aniScroll(scrollId, contentId, destHeight, increment, speed, onDone)
{
	var obj = document.getElementById(scrollId);
	var height = obj.clientHeight + increment;
	
	// expand
	if(increment > 0)
	{
		if(height >= destHeight)
		{
			obj.style.height = destHeight + "px";
			document.getElementById(contentId).style.display = "";
			setTimeout(onDone, 0);
		}
		else
		{
			obj.style.height = height + "px";
			setTimeout("aniScroll('" + scrollId + "', '" + contentId + "', " + destHeight + ", " + increment + ", " + speed + ", '" + onDone + "')", speed);
		}
	}
	
	// contract
	else
	{
		
		if(height < 0)
		{
			obj.style.height = "0px";
			setTimeout(onDone, 0);
		}
		else
		{
			document.getElementById(contentId).style.display = "none";
			obj.style.height = height + "px";
			setTimeout("aniScroll('" + scrollId + "', '" + contentId + "', " + destHeight + ", " + increment + ", " + speed + ", '" + onDone + "')", speed);
		}
	}
}

/*
	Programatically jumps to an anchor on the page
*/
function jumpToAnchor(anchorName) 
{
	window.location = String(window.location).replace(/\#.*$/, "") + "#" + anchorName;
}