/*--------------------------------------------------------------------------*/
/*  Loki Javascript API
 *  Ryan Sarver <rsarver@skyhookwireless.com>
 *
 *  *Modified 2007 by joeldg (Joel De Gan) for use on http://socialight.com
 *
 *  This is a helper script to help you detect and gracefully handle
 *  users with Loki installed
 *
/*--------------------------------------------------------------------------*/

var lokiTry = {
	these: function() {
		var returnValue;

		for (var i = 0; i < arguments.length; i++) {
			var lambda = arguments[i];
			try {
				returnValue = lambda();
				break;
			} catch (e) {}
		}
		return returnValue;
	}
}

function LokiAPI(){
	return lokiTry.these(
		function() {return new ActiveXObject("Loki.LocationFinder.1")},
		function() {return new Loki()}
	) || false;
}

function lokionSuccess(location) {
	$('setlocation_latitude').value=location.latitude;
	$('setlocation_longitude').value=location.longitude;
	if($('meneartop')){
		$('meneartop').innerHTML = location.city + ", " + location.region_code;
	}
	if($('youarenear')){
		$('youarenear').innerHTML = location.city + ", " + location.region_code;
	}
	setlatitude = location.latitude;
	setlongitude = location.longitude;
	reversegeo = location.city + ", " + location.region_code;
}

function lokionFailure(error) {
	return false;
}

/*--------------------------------------------------------------------------*/
/*
        end loki
*/
/*--------------------------------------------------------------------------*/

