function init_menu()
{

    $("#mainMenu IMG.menu").hover(
        function () {
            var obj = $(this);
            obj.attr("src", obj.attr("src").replace(/\.jpg$/, "_on.jpg"));
        }, 
        function () {
            var obj = $(this);
            obj.attr("src", obj.attr("src").replace(/_on\.jpg$/, ".jpg"));
        }
    );

}

var pager = null;

function _pager(page_id, page_num, lang_code) {

    this.pageId     = page_id;
    this.pageNum    = page_num;
    this.i          = 1;

    this.next       = function() {
        if (this.i < this.pageNum) {
            this.prevButton.show();
            ++this.i;
            this.content.load(this.url + this.i);
            if (this.i == this.pageNum) {
                this.nextButton.hide();
            }
        }
    };

    this.prev       = function() {
        if (this.i > 1) {
            this.nextButton.show();
            --this.i;
            this.content.load(this.url + this.i);
            if (this.i == 1) {
                this.prevButton.hide();
            }
        }
    };

    this.content    = $("#tartalom");
    this.url        = "/ajax/page.php?ie=" +new Date().getTime()+ "&lang_code=" +lang_code+ "&id=" +this.pageId+ "&n=";
    this.nextButton = $("#tovabb");
    this.prevButton = $("#vissza");

    this.nextButton.click(function () { 
        pager.next();
    });

    this.prevButton.click(function () { 
        pager.prev();
    });

    if (this.pageNum > 1) {
        this.nextButton.show();
    }

}

var gallery = null;
var gallerySelected = null;
var galleryImage = null;
var galleryText = null;

var largeImage = null;

function init_gallery(_move)
{

    $("div.scrollable").scrollable();
    gallery = $("div.scrollable").scrollable();

    galleryImage    = $(".kep div");
    galleryText     = $(".kep span");

    $(".fotok A").click(function () {
        if (gallerySelected) {
            gallerySelected.fadeTo("fast", 0.50);
            gallerySelected.removeClass("sel");
        }
        var obj = $(this);
        galleryImage.css("background-image", "url('" + obj.attr("href") + "')");
        galleryText.text(obj.find("span").text());
        largeImage = obj.find("div").text();
        gallerySelected = obj.find("IMG");
        gallerySelected.fadeTo("fast", 1);
        gallerySelected.addClass("sel");
    });

    $(".fotok A").hover(
        function () {
            var obj = $(this).find('IMG');
            if (!obj.hasClass('sel')) {
                obj.fadeTo("fast", 1);
            }
        }, 
        function () {
            var obj = $(this).find('IMG');
            if (!obj.hasClass('sel')) {
                obj.fadeTo("fast", 0.50);
            }
        }
    );

    $("#galeria_kijelolt").click();
    gallery.move(_move);

    galleryImage.click(function () {
        if (largeImage) {
            palmahaz_popup("/gallery_large.php?img=" +largeImage, 800, 600, 'gallery_large');
        }
    });

}

function palmahaz_popup(url, w, h, name)
{

    var win_left   = (screen.width - w) / 2;
    var win_up     = (screen.height - h) / 2;
    var win_prop    = 'width=' +w+ ',height=' +h+ ',left=' +win_left+ ',top='+win_up+',scrollbars=0';
    window.open(url, name, win_prop);

}
