How to run JavaScript in Menu app

Hi - I just seem to be able to get this to work. Please can someone help.
The objective is to run the browser navigator each time the menu loads.
Here the code I have.

[SIZE=12px]var watchID;[/SIZE]
[SIZE=12px]var geoLoc;[/SIZE]
[SIZE=12px]getLocationUpdate(); [/SIZE]
[SIZE=12px]function showLocation(position) {[/SIZE]
[SIZE=12px]var latX = position.coords.latitude;[/SIZE]
[SIZE=12px]var lngY = position.coords.longitude;[/SIZE]
[SIZE=12px]var accuracy = position.coords.accuracy;[/SIZE]
[SIZE=12px]var heading = position.heading;[/SIZE]
[SIZE=12px]var speed = position.speed;[/SIZE]
[SIZE=12px]jQuery.ajax({[/SIZE]
[SIZE=12px]type: “POST”, [/SIZE]
[SIZE=12px]url: "https://secure.XXXXXXXXXXX?&latX="+latX+"&lngY="+lngY+"&accuracy="+accuracy+"&heading="+heading+"&speed="+speed+" ",[/SIZE]
[SIZE=12px]cache: false[/SIZE]
[SIZE=12px]});[/SIZE]
[SIZE=12px]}[/SIZE]

[SIZE=12px]function errorHandler(err) {[/SIZE]
[SIZE=12px]var msg = "Can’t get your location. Error = ";[/SIZE]
[SIZE=12px]if (err.code == 1)[/SIZE]
[SIZE=12px]msg += “PERMISSION_DENIED”;[/SIZE]
[SIZE=12px]else if (err.code == 2)[/SIZE]
[SIZE=12px]msg += “POSITION_UNAVAILABLE”;[/SIZE]
[SIZE=12px]else if (err.code == 3)[/SIZE]
[SIZE=12px]msg += “TIMEOUT”;[/SIZE]
[SIZE=12px]msg += ", msg = "+error.message;[/SIZE]
[SIZE=12px]alert(msg);[/SIZE]
[SIZE=12px]}[/SIZE]

[SIZE=12px]function getLocationUpdate(){[/SIZE]
[SIZE=12px]if(navigator.geolocation){[/SIZE]
[SIZE=12px]var options = { enableHighAccuracy: true, timeout: 2000, maximumAge: 0};[/SIZE]
[SIZE=12px]geoLoc = navigator.geolocation;[/SIZE]
[SIZE=12px]watchID = geoLoc.watchPosition(showLocation, errorHandler, options);[/SIZE]
[SIZE=12px]}[/SIZE]
[SIZE=12px]else{[/SIZE]
[SIZE=12px]alert(“Sorry, browser does not support geolocation!”);[/SIZE]
[SIZE=12px]}[/SIZE]
[SIZE=12px]}[/SIZE]