// Various utilities ----------------------------------------------------------

// Browser Window Size and Position -------------------------------------------
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} 
function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} 

function osPos(lat,lng)
{
	// Convert from a WGS84 lat,lng pair to an OSGB MapPoint
	var lonlat = new OpenLayers.LonLat( lng, lat );
	return gridProj.getMapPointFromLonLat(lonlat);
}

//function gPos(mp)
//{
//	// Convert from an OSGB Map Point to a WGS84 lat lng
//	var oll = gridProj.getLonLatFromMapPoint(mp);
//	return oll;
//}

// Generic open Window function -----------------------------------------------
function openWin(name)
{
	document.getElementById(name).style.visibility = "visible";
}

// Generic close Window function ----------------------------------------------
function closeWin(name)
{
	document.getElementById(name).style.visibility = "hidden";
}

// Cross browser XML HTTP request object --------------------------------------
function createXMLHttpRequest() {
   if (window.XMLHttpRequest) {
     return new XMLHttpRequest();
   } else if (window.ActiveXObject) {
     return new ActiveXObject('Microsoft.XMLHTTP')
   } else {
     _error("Could not create XMLHttpRequest on this browser");
     return null;
   }
 }
