$(document).ready(function(){


    //Panoramio images
    panoramio_cookies();

    // Accordion
    $("#accordion").accordion({
        header: "h3"
    });


    // GeoSubmit
    $("#geosubmit").click(function (){
        var address = $("#direction").val();
        showInfo("Buscando dirección: <strong>"+address+"</strong>");

        if (geocoder) {
            geocoder.geocode( {
                'address': address
            }, function(results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                    map.setCenter(results[0].geometry.location);
                    loadPoint();
                } else {
                    showInfo("Error al buscar la dirección: <strong>" + status+"</strong>");
                }
            });
        }
        else {
            showInfo("<strong>Error al buscar la dirección.</strong>");
        }
    });

    $('#controles').tabSlideOut({
        tabHandle: '.handle',                              //class of the element that will be your tab
        pathToTabImage: 'img/informacionbt.png',          //path to the image for the tab (optionaly can be set using css)
        imageHeight: '150px',                               //height of tab image
        imageWidth: '40px',                               //width of tab image
        tabLocation: 'left',                               //side of screen where tab lives, top, right, bottom, or left
        speed: 300,                                        //speed of animation
        action: 'click',                                   //options: 'click' or 'hover', action to trigger animation
        topPos: '250px',                                   //position from the top
        fixedPosition: true                               //options: true makes it stick(fixed position) on scroll
    });
    
    $('#ciudad').tabSlideOut({
        tabHandle: '.handleciudad',                              //class of the element that will be your tab
        pathToTabImage: 'img/ciudad.png',          //path to the image for the tab (optionaly can be set using css)
        imageHeight: '150px',                               //height of tab image
        imageWidth: '40px',                               //width of tab image
        tabLocation: 'left',                               //side of screen where tab lives, top, right, bottom, or left
        speed: 300,                                        //speed of animation
        action: 'click',                                   //options: 'click' or 'hover', action to trigger animation
        topPos: '500px',                                   //position from the top
        fixedPosition: true                               //options: true makes it stick(fixed position) on scroll
    });



    $("#bt-panoramio").click(function () {
        var value_button = $("#bt-panoramio").val();

        if(value_button == "activar") {
            $.cookie("bp_panoramioshow","on");
            $("#bt-panoramio").val("desactivar");
        }
        else if(value_button == "desactivar") {
            $("#bt-panoramio").val("activar");
            $.cookie("bp_panoramioshow","off");
        }
        else {
            $.cookie("bp_panoramioshow","on");
        }

    });

    $("#selectcity").change(function(){
        if($(this).val() == 1) {
            showInMap(-36.827115203703386,-73.05024147033691);
        }
        else if($(this) == 2) {
            showInMap();
        }
    });

});
