var browserSupportsGL;
$(function(){
    $('li.info-action').live('mouseover', function(){
        $(this).addClass("ui-state-hover");
    }).live('mouseout', function(){
        $(this).removeClass("ui-state-hover");
        $(this).removeClass("ui-state-active");
    }).live('mousedown', function(){
        $(this).addClass("ui-state-active");
    }).live('mouseup', function(){
        $(this).removeClass("ui-state-active");
    });

    $("div.ajax-loader").ajaxSend(function(){
        $(this).show();
        $('#search_bar ul li.search-icon').removeClass('search-icon-static').addClass('search-icon-ajax');
    });    

    $("div.ajax-loader").ajaxStop(function(){
        $(this).hide();
        $('#search_bar ul li.search-icon').removeClass('search-icon-ajax').addClass('search-icon-static');
    })
    $.fn.myautolocate = function(geolocateSuccesscallback, geolocateErrorcallback, timeout){
        //check for geolocation feature; only supported by Firefox 3.5 as of now
        if(navigator.geolocation){
            browserSupportsGL = true;
            navigator.geolocation.getCurrentPosition(geolocateSuccesscallback, geolocateErrorcallback, {
                timeout: timeout
            })
        }else{
            //check for google gears; default by installed in Google Chrome
            if(google.gears){
                browserSupportsGL = true;
                //google gears is installed
                googleGear = google.gears.factory.create('beta.geolocation');
                googleGear.getCurrentPosition(geolocateSuccesscallback, geolocateErrorcallback, {
                    timeout: timeout
                })
            }else{
                browserSupportsGL = false;                
                geolocateErrorcallback();
            }
        }
    }

    $('#guide_dialog').dialog({
        width: 400,
        height:330,
        modal: true,
        autoOpen: false,
        buttons: {
            'Cool!': function(){
                $(this).dialog('close');

            }
        }
    })

    $('#guide_anchor').bind('click', function(){
        $('#guide_dialog').dialog('open');

    });
    if($('input[name=display_guide]').val()=='true'){
        $('#guide_anchor').trigger('click');
    }

    $('li.main-map-tab').live('mouseover', function(){
                $(this).addClass("toggle-hover");
            }).live('mouseout', function(){
                $(this).removeClass("toggle-hover");
            });       

})


