function setElementHtml(id, html) {
    var obj = getElement(id);
    if (obj != null) {
        obj.innerHTML = html;
    }
}

function getElementHtml(id) {
    var obj = getElement(id);
    return (obj != null ) ? obj.innerHTML : "";
} 

function getElement( id )
{
	var obj = null;
	
	if ( document.getElementById )
	{
		obj = document.getElementById( id );
	}
	else
	{
		obj = document.all[id];
	}

	return obj;
}

function MonthToString(m)
{
	var s=new String();
	
	switch (m) {
		case( 0): s = "Jan"; break;
		case( 1): s = "Feb"; break;
		case( 2): s = "Mar"; break;
		case( 3): s = "Apr"; break;
		case( 4): s = "May"; break;
		case( 5): s = "Jun"; break;
		case( 6): s = "Jul"; break;
		case( 7): s = "Aug"; break;
		case( 8): s = "Sep"; break;
		case( 9): s = "Oct"; break;
		case(10): s = "Nov"; break;
		case(11): s = "Dec"; break;
		default: s="?";
	}
	
	return s;
}

function PadLeft(i,iRequiredLen,sPad)
{
	var s=new String();
	var j;

	s = i.toString();
	for (j=s.length; j<iRequiredLen; j++)
		s = sPad + s;
		 	
	return s;
}

function PadRight(s,iRequiredLen,sPad)
{
	var sRet=new String();
	var j;

	sRet = s;
	for (j=s.length; j<iRequiredLen; j++)
		sRet = sRet + sPad;
		 	
	return sRet;
}

function DateToString(dt)
{	
	var s=new String();
	
	s = PadLeft(dt.getDate().toString(),2,"0") + " " + MonthToString(dt.getMonth()) + " " + dt.getYear().toString();
	s = s + ", " + PadLeft(dt.getHours(),2,"0") + ":" + PadLeft(dt.getMinutes(),2,"0") + ":" + PadLeft(dt.getSeconds(),2,"0");
	return s;
}

function ShowHTMLDialog( strLocation, varArguments, strFeatures )
{
	var strFeatures2 = new String();
	//alert(strFeatures);
	if (strFeatures == null)
		strFeatures2 = "center: yes; dialogWidth: 700px";
	else
		strFeatures2 = strFeatures;

	var returnValue = window.showModalDialog( strLocation, varArguments, strFeatures2 )
	return returnValue;
}

function ShowHTMLForm( strLocation, strName, strFeatures )
{
	var strFeatures2 = new String();
	if (strFeatures == null)
	{
		var intHeight = (window.screen.availHeight - 60);
		var intWidth = (window.screen.availWidth - 30);

		var intLeft = (window.screen.availWidth - intWidth) / 2 - 10;
		var intTop = 0;
		
//		alert(
//			"availHeight = " + window.screen.availHeight + 
//			"availWidth = " + window.screen.availWidth );
		strFeatures2 = "left=" + intLeft + ", top=" + intTop + ", height=" + intHeight + ", width=" + intWidth + ", resizable=yes, status=yes,  menubar=no, directories=no, fullscreen=no, toolbar=no";
//		alert( strFeatures2 );
	}
	else
		strFeatures2 = strFeatures;
	var handle = window.open( strLocation, strName, strFeatures2 )
	return handle;
}

function ShowPage( strURL, strName, intHeight, intWidth, intTop, intLeft )
{
	var top = 0;
	var left = 0;
	var height = (window.screen.availHeight - 60);
	var	width = (window.screen.availWidth - 30);

	if (intHeight != null)
		height = intHeight;
	
	if (intWidth != null)
		width = intWidth;

	if (intTop == null)
		top = (window.screen.availHeight - height) / 2 - 10;
	else
		top = intTop;

	if (intLeft == null)
		left = (window.screen.availWidth - width) / 2 - 10;
	else
		left = intLeft;		

	var strFeatures = new String("resizable=yes, status=yes, menubar=no, directories=no, fullscreen=no, toolbar=no, left=" + left + ", top=" + top + ", height=" + height + ", width=" + width);
//	alert( strFeatures );

	return window.open( strURL, strName, strFeatures );
} // ShowPage

function ShowPageCentered( strURL, strName, intHeight, intWidth )
{
	return ShowPage( strURL, strName, intHeight, intWidth );
}

