// Flexobazeny web interface
var FB = {

    /**
     * Init functions
     */         
    init: function () {
        if($.browser.msie){
            FB.fixIE6flicker(true);
        }
        FB.print();
        FB.location();
    },
    
    /**
     * Google map
     */         
    location: function () {
        if (!$('#map').length) {
            return;
        }

        if (GBrowserIsCompatible()) {
            var map = new GMap2(document.getElementById("map"));
            map.setCenter(new GLatLng(48.143596, 17.175107), 15);
            map.addControl(new GLargeMapControl());
            map.addControl(new GMapTypeControl());
            var point = new GLatLng(48.143596, 17.175107);
            map.addOverlay(new GMarker(point));
        }
    },
   
    /**
     * Print page
     */         
    print: function () {
        $("#print").bind("click", function () {
            window.print();
            return false;
        });
    },     

    /**
     * Fix background image flicker in IE6
     */         
    fixIE6flicker: function (fix) {
        try {
            document.execCommand("BackgroundImageCache", false, fix);
        } catch(err) { }
    },   
    
    /**
     * Preload images
     * @param {Array} images array with names of images   
     */               
    preloadImages: function (images) {
        for (var i = 0; i < images.length; i++) {
            var image = new Image();
            image.src = images[i];
        }
    }         
}

$(document).ready(function () {
    FB.init();
});
