/**
 * simple_locator minified
 * http://roman.tao.at
 *
 * Copyright (c) 2010, Roman Weinberger
 * Licensed under the MIT License.
 */
var simple_locator=function(d)
{
    var a={
        threshold:25,
        google_geocoding:false,
        running_callback:false,
        finished_callback:false,
        error_callback:false,
        unknown_location_string:"unknown location",        
        set_from:function(f){for(var e in f){this[e]=f[e]}}};
        a.set_from(d);
        
    var b=function(g,e,f,city , street , number,postal_code)
        {        
        if(a.threshold > g.accuracy)
        {        
                a.finished_callback(g,e, city , street , numer, postal_code);
                navigator.geolocation.clearWatch(f)
        }
        else
        {
            a.running_callback(g,e,city , street , number ,postal_code)
        }
};

    var c=function()
    {    
        var e=navigator.geolocation.watchPosition(function(f){if(a.google_geocoding)
        {
            (new google.maps.Geocoder()).geocode(
                {
                    latLng:new google.maps.LatLng(f.coords.latitude,f.coords.longitude)
                },
                
                function(i,g){
                
                var h=a.unknown_location_string;       
                var city ;  
                var street; 
                var number;
                var postal_code;
                                                                                                      
                if(g==google.maps.GeocoderStatus.OK)
                {
                    if(typeof i[0]!="undefined")
                    {
                        var h = i[0].formatted_address;                                                                                                                                                                                                                                           
                        for (nCount = 0; nCount < i[0].address_components.length;nCount++) 
					    {					      
                            var component = i[0].address_components[nCount];                                                                                                                                                                                                                           
                            if (component.types[0] == "locality")
                               city = component.long_name;
                            if (component.types[0] == "route")
                               street = component.long_name;
                            if (component.types[0] == "street_number")
                               number = component.long_name;                            
                            if(component.types[0] == "postal_code")
                                postal_code = component.long_name;                                                           
                         }	                                                                                                                   
                    }
                }                       
                        b(f.coords,h,e,city, street , number,postal_code)
                    }
                 )
                }
                    else
                {
                
                    b(f.coords,a.unknown_location_string,e,'','','','')}},
                
                    function(f)
                    {
                        if(a.error_callback)
                        {
                            a.error_callback(f)
                        }
                    }
                )
          };
                    
                    if(typeof navigator.geolocation!="undefined"){c();
                        return true
                }                    
                    else                    
                    {return false}
};