var options = {                  // {Object} options available to calls for position
    	enableHighAccuracy: false, // {Boolean} Whether or not to use more resources to get a more accurate position
    	maximumAge: 0,             // {Number|Infinity} The maximum number of milliseconds since the last check.
    	timeout: null              // {Number|null} The maximum number of milliseconds to wait for a fix
    },
    watchId,                     // {Number} an ID to a watch timeout
    Geo = navigator.geolocation; // {Object|null} a shortcut to the geolocation static class   

function onError(error) {
	var message = error.message,
	    code    = error.code;
	
	switch(error.code) {
	case error.UNKNOWN_ERROR:
		break;
	case error.PERMISSION_DENIED:
		break;
	case error.POSITION_UNAVAILABLE:
		break;
    case error.TIMEOUT:
		break;
	}
}

function onPosition (position) {
	var timestamp        = position.timestamp,      // {Date}   
	    coords           = position.coords,         // {Object} placeholder
	    latitude         = coords.latitude,         // {Number} decimal degrees
	    longitude        = coords.longitude,        // {Number} decimal degrees
	    accuracy         = coords.accuracy,         // {Number} meters
	    altitudeAccuracy = coords.altitudeAccuracy, // {Number|null} meters
	    heading          = coords.heading,          // {Number|null} degrees relative to true north
	    speed            = coords.speed;            // {Number|null} meters per second
	coords               = null;
}

if ( ! Geo ) { throw new Error("geolocation not available."); }

// Gets the current position once
Geo.getCurrentPosition(onPosition, onError, options);

// Returns the current position, then watches for change in position
watchId = Geo.watchPosition(onPosition, onError, options);

// Stops watching for position changes
Geo.clearWatch(watchId);