/*
	Utility functions.
*/
/* 
/ Javascript function for dynamically rewriting a layer's (DIV) content.
/ function WriteLayer(ID, parentID, sText)
/ 
/ ID: the ID of the DIV tag to rewrite
/ parentID: null if the target DIV is not nested inside other DIVs - or - the ID of the parent DIV of the target DIV if nested
/ sText: the new contents for the layer
/ 
/ Compatibility: Netscape 4+, IE 4+
*/
function WriteLayer(ID, parentID, sText) 
{
	if (document.layers) 
	{
		var oLayer;
		if(parentID)
		{
			oLayer = eval('document.' + parentID + '.document.' + ID + '.document');
		}
		else
		{
			oLayer = document.layers[ID].document;
		}
		oLayer.open();
		oLayer.write(sText);
		oLayer.close();
	}
    else if (parseInt(navigator.appVersion) >= 5 && navigator.appName == "Netscape") 
    {
		document.getElementById(ID).innerHTML = sText;
	}
    else if (document.all) 
    {
		document.all[ID].innerHTML = sText;
	}
}

function GetAspNetForm()
{
	var theForm = document.forms['aspnetForm'];
	if (!theForm) {   theForm = document.aspnetForm;}
	return theForm;
}

function getHttpRequest(url) 
{
    var ret		= ""; 
    var xmlhttp = null;
    
    if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } // Mozilla
    else if (window.ActiveXObject) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } // IE

	if(xmlhttp!=null)
	{  
		var timeout;
		
		xmlhttp.open("GET", url, true);
		xmlhttp.onreadystatechange = function() 
		{
			
			if(xmlhttp.readyState != 4) 
			{
				ret = "Loading...";
				timeout=window.setTimeout("alert('Timeout while reading '"+url+");", 20000);
			}
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) 
			{
				ret = xmlhttp.responseText;
				window.clearTimeout(timeout);
			}
		}
		xmlhttp.send(null);
		
    }
    else
		ret="Browser does not support Javascript HTTP Requests.";
		
	return ret;
} 
