
var map = null;
var geocoder = null;

function kontakt(){
    $('#zakladka5').click();
}

function initialize() {
    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        //map.setCenter(new GLatLng(37.4419, -122.1419), 20);
        geocoder = new GClientGeocoder();
    }
}

function showAddress(address,address2) {
    if (geocoder) {
        geocoder.getLatLng(
            address,
            function(point) {
                if (!point) {

                    showAddress(address2,'');
                    
                } else {
                    map.setCenter(point, 15);
                    var marker = new GMarker(point);
                    map.addOverlay(marker);
                    marker.openInfoWindowHtml(address);
                }
            }
            );
    } 
}

window.onload = function(){



    $("#q").click(function() {
        $(this).val('');
    });
 
    $('#q').autocomplete('../result_list',{
        selectFirst:0
    });
    $('.product').corners("5px");
    $('li a').corners("top");


    $("ul").idTabs(function(id,list,set){ 
        $("a",set).removeClass("selected")
        .filter("[@href='"+id+"']",set).addClass("selected");
        for(i in list)
            $(list[i]).hide();
        $(id).fadeIn();
        return false;
    });


    $('li').each(function(i) {
        $(this).hide();
        $(this).animate({
            opacity: 1.0
        }, i*300).fadeIn();
    });

    $('a:contains(Gallery)').click(function() {
        $('#tab2 li').each(function(i) {
            $(this).hide();
            $(this).animate({
                opacity: 1.0
            }, i*500).fadeIn("slow");
        });
    });

    initialize();
    showAddress(address,address2);

    var p=1;

    if($('#mapka:visible').length>0) {
        $('#mapka').click(function() {
            if(p==1) {
                $('#map').css("width","500px");
                $('#map').css("height","500px");
                $(this).html('Pomniejsz mapk\u0119');
            } else {
                $('#map').css("width","300px");
                $('#map').css("height","300px");
                $(this).html('Powi\u0119ksz mapk\u0119');
            }
            p=p*-1;
        });
    }

};



