function SetMapCoord(coords)
{
	document.getElementById('mapCoords').value = coords;

	hideElement('google_select');
	showElement('google_clear');
}
function openGoogleSelector()
{
	var w = window.open('google_popup.php','google_popup','width=850,height=690,scrollbars=0');
	w.focus();

	return false;
}
function clearLocation()
{
	SetMapCoord('');
	showElement('google_select');
	hideElement('google_clear');
}
function toggleElement(buttonName, bHide)
{
if (bHide == '1')
{
	document.getElementById(buttonName).style.visibility = 'hidden';
	document.getElementById(buttonName).style.display = 'none';
}
else
{
	document.getElementById(buttonName).style.visibility = 'visible';
	document.getElementById(buttonName).style.display = 'inline';
}

}
function showElement(elementName)
{
	toggleElement(elementName, '0');
}
function hideElement(elementName)
{
	toggleElement(elementName, '1');
}
function changeGPSSelect(value)
{
	switch(value)
	{
		case 1:
		 	showElement('google_select');
			hideElement('mapCoords');
		  	break;    
		case 2:
			clearLocation();
			hideElement('google_select');
			hideElement('google_clear');
			showElement('mapCoords');
		  	break;
		default:
			clearLocation();
		  	hideElement('google_select');
			hideElement('google_clear');
			hideElement('mapCoords');
	}
}
function setPreviousValue(sGPSCoords)
{
	if (sGPSCoords.length > 0)
	{
		sGPSCoords = sGPSCoords.replace(/&amp;/g,"&");

		document.getElementById('mapCoords').value = sGPSCoords;

		if (sGPSCoords.indexOf('x=') > -1 && sGPSCoords.indexOf('y=') > -1)
		{
			document.getElementById('gps_select').options[1].selected = true;
			showElement('google_clear');		
		}
		else
		{
			document.getElementById('gps_select').options[2].selected = true;
			showElement('mapCoords');
		}
		
	}


}



