function doGlobalLoad(sender)
{
	//alert('globalloadnew');
	sender.setformfocus();
	if (window.doLocalLoad)
		doLocalLoad();
	if (window.opener && !window.opener.closed)
	{
		if (document.getElementById("closebtn"))
			document.getElementById("closebtn").style.display='block';
		if (document.getElementById("returnbtn"))
			document.getElementById("returnbtn").style.display='none';
	}
	else
	{
		if (document.getElementById("returnbtn"))
			document.getElementById("returnbtn").style.display='block';
		if (document.getElementById("closebtn"))
			document.getElementById("closebtn").style.display='none';
	}
	if (window.xHeight) // does the x_library exist?
	{
		xAddEventListener(window, "resize", adjustLayout, false);
		adjustLayout();
	}
}

function setformfocus()
{
	//if (document.forms.length>0) document.forms[0].elements[0].focus();
	var username=document.getElementById('username');
	var firstname=document.getElementById('firstname');
	if (username)
	{
		username.focus();
	}
	else if (firstname)
	{
		firstname.focus();
	}
}
// math functions
function numFormat(num, decplaces)
{
	var str=""+Math.round(eval(num) * Math.pow(10,decplaces));
	while (str.length <=decplaces)
	{
		str = "0" + str;
	}
	var decpoint = str.length - decplaces;
	return str.substring(0,decpoint) + "." + str.substring(decpoint, str.length);
}
function fmtMoney(num)
{
	return numFormat(num, 2);
}

//Pop-Up MapServer Window
function popUpMap_latlon(lat, lon, name, usewin)
{
	var wnam='LocationMapLatLon';
	var title=name;
	if (!title)
	{
		title='Here!';
	}
	var attr='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=540,height=700';
	var scale='100000';
	// maptech:
	if (lon>0)
	{
		lon=lon*-1;
	}
	var loca='http://mapserver.maptech.com/bp/mapserver/index.cfm?lat='+lat+'&lon='+lon+'&type=1&scale='+scale+'&icon=AnimArrowsIn_red_64_64_-32_-32|'+lat+'|'+lon+'|^'+title;
	if (lat!='' && lon!='')
	{
		//alert("lat/lon"+lat+"/"+lon);
		if (usewin)
		{
			location=loca;
		}
		else
			window.open(loca, wnam, attr);
	}
	else alert("No Map is available.");
}
