function getLocation() {
	try {
		if (navigator.geolocation) {
		        // Get location no more than 10 minutes old. 600000 ms = 10 minutes.
			showPlzWait();
		        var res = navigator.geolocation.getCurrentPosition(showLocation, showError,{enableHighAccuracy:true,maximumAge:600000,timeout:10000});
		} else if(window.google && window.google.gears) {
			showPlzWait();
			var geo = google.gears.factory.create('beta.geolocation');
			geo.getCurrentPosition(showGearsLocation, showError, {enableHighAccuracy:true,maximumAge:600000,timeout:10000});
		} else {
			noGeoLocation();
       		}
	} catch(ex) {
		noGeoLocation();
	}
}

function showPlzWait() {
        var div=document.getElementById('stationList');
        if(div) div.style.display='none';

	var div=document.getElementById('waitPlz');
	if(div)div.style.display='inline';
}

function showStationList() {
        var div=document.getElementById('waitPlz');
        if(div) div.style.display='none';

        var div=document.getElementById('stationList');
        if(div) div.style.display='block';
}

function showError(error) {
	showStationList();
}

function noGeoLocation() {
	showStationList();
}

function postLocation(lat,lon) {
	var frm=document.forms['frm1'];
	frm.lat.value=lat;
	frm.lon.value=lon;
	frm.submit();
}

function showLocation(position) {
	try {
		postLocation(position.coords.latitude,position.coords.longitude);
		//location.href="/"+position.coords.latitude+","+position.coords.longitude;
	} catch(ex) {
		alert(ex);
	}
}

function showGearsLocation(position) {
	postLocation(position.latitude,position.longitude);
//	location.href="/"+position.latitude+","+position.longitude;
}

