var stopGeoLocation = false;

function processLocation(position) {

    $(".coordinatesX").val(position.coords.latitude);
    $(".coordinatesY").val(position.coords.longitude);

    if(stopGeoLocation==false){
        document.forms[0].submit();
    }
    else{
        raiseError();
    } 
}
function raiseError(error){
    overlay=document.getElementById("loadingOverlay");
     overlayMessage=document.getElementById("loadingMessage");

    if(overlay!=null && overlayMessage != null){
            overlay.style.display="none";
            overlayMessage.style.display="none";
        }
}

function getPosition(){
    if (navigator.geolocation) {

        overlay=document.getElementById("loadingOverlay");
        overlayMessage=document.getElementById("loadingMessage");

        if(overlay!=null && overlayMessage != null){
            overlay.style.display="block";
            overlayMessage.style.display="block";
        }
		try{
        navigator.geolocation.getCurrentPosition(processLocation, raiseError);
		}
		catch(error){
                    raiseError();
                }
    }
}

function stopLoadingLocation(){
        stopGeoLocation = true;
        raiseError();
}






