/*
	Athene Common functions
*/
function getX(obj)
{
	if (obj)
		return( obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft+getX(obj.offsetParent) );
}

function getY(obj)
{
	if (obj)
 		return( obj.offsetParent==null ? obj.offsetTop : obj.offsetTop+getY(obj.offsetParent) );
}

function blur(object)
{	
	if (object)
	{
		object.blur();
		document.body.focus();
	}
}

/*
	Create an email with the specified location
*/
function emailLocation()
{
	var url = "http://" + window.location.hostname + window.location.pathname;
	url += '?lat=' + getLat() + '&lng=' + getLng() + '&zoom=' + getZoom();
	
	window.location = 'mailto:?subject=' + EMAIL_SUBJECT + '&body=' + escape(url);
}


/*
	Create an url with the specified location
*/
function linkLocation()
{
	var url = "http://" + window.location.hostname + window.location.pathname;
	url += '?lat=' + getLat() + '&lng=' + getLng() + '&zoom=' + getZoom();
	
	window.open(url);
}


/*
	Redirect to a page with a map and remember location
*/
function redirectRemember(page)
{
	if (window.getLat)
	{
		var url = "http://" + window.location.hostname + "/" + page;
		url += '?lat=' + getLat() + '&lng=' + getLng() + '&zoom=' + getZoom();
	}
	else
	{
		url = "http://" + window.location.hostname + "/" + page;
	}
	window.location = url;
}

/*
	Open the map in a new window (popup)
*/
function openPopupMap()
{
	// Open a new window with the map, use same zoom and same location
	var url = 'popup.map.php';	
	url += '?lat=' + getLat() + '&lng=' + getLng() + '&zoom=' + getZoom();
	
	var popupMap = window.open(url, 'map', 'height=' + (screen.height * 0.8) + ',width=' + (screen.width * 0.8) + ',scrollbars=no,menubar=no,toolbar=no,location=no,resizable=yes,status=no');
}