/*
* Locus v0.8 - A Geolocation Javascript Library
*
* Copyright (c) 2009 Larry Myers (larry@larrymyers.com)
* 
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
(function(){var d,c=function(){return(typeof navigator.geolocation!="undefined")},e=function(g,h,i){var j=function(k){a(k);locus.lastPosition=k;g(k)};navigator.geolocation.getCurrentPosition(j,h,i)},b=function(){return(d)?true:false},f=function(g,h,j){var k=function(l){a(l);locus.lastPosition=l;g(l)};var i=function(l){h(l.message)};d.getCurrentPosition(k,i)},a=function(g){if(!g.coords&&g.latitude&&g.longitude){g.coords={latitude:g.latitude,longitude:g.longitude}}if(!g.latitude&&!g.longitude&&g.coords){g.latitude=g.coords.latitude;g.longitude=g.coords.longitude}return g};if(typeof window.google!="undefined"){d=google.gears.factory.create("beta.geolocation")}window.locus={lastPosition:null,check:function(h){var g=false;if(!h||(typeof h!="string")){return g}switch(h.toLowerCase()){case"w3c":g=c();break;case"gears":g=b();break}return g},loadGears:function(h){if(!h){h="http://code.google.com/apis/gears/gears_init.js"}var g=document.createElement("script");g.type="text/javascript";g.src=h;g.onload=function(){d=google.gears.factory.create("beta.geolocation")};document.body.appendChild(g)},getCurrentPosition:function(l,g,h){if(typeof h=="undefined"){h={}}var k,j=0;if(h.serviceList){k=h.serviceList}else{k=["gears","w3c"]}for(;j<k.length;j++){if(k[j]=="w3c"&&c()){e(l,g,h);return}else{if(k[j]=="gears"&&b()){f(l,g,h);return}}}g("No location services were found.")}}})();