$(function() {
    
    Cufon.replace(".floatedBox h1, .sFloatedBox h1, .messageBox h1", { fontFamily: "Haettenschweiler" });
    Cufon.replace(".esemenyekFakeBox ul li, #esemenyek ul li",{ fontFamily: "Journal" });
    
    $(document).click(function() {
        $(".csbody ul").hide();
    });
    
    $("#logoFrame").click( function() { window.location.href = HTTPROOT; } );
    
    $(".menu").hover(function() {
        var idx = $(".menu").index($(this));
        $(".menuMaterial").eq(idx).hide();
        $(".menuMaterial").eq(idx).show();
    }, function() {
        $(".menuMaterial").hide();
    });
    
    $(".esemenyekFakeBox").mouseover(function() {
        $(".menuMaterial#esemenyek").show();   
    });
    
    $(".menuMaterial#esemenyek").mouseout(function() {
        $(".menuMaterial#esemenyek").hide();
    });
    
    $(".noteszFakeBox").mouseover(function() {
        $(".menuMaterial#esemenyek2").show();   
    });
    
    $(".menuMaterial#esemenyek2").mouseout(function() {
        $(".menuMaterial#esemenyek2").hide();
    });
    
    $(".csbody").each(function(i, item) {
        $(item).toggle(function() {
            $(".csbody ul").hide();
            $(item).children("ul").show();
        }, function(/*e*/) {
            $(".csbody ul").hide();
            //$(item).children("ul").hide();
        });
    });
    
    $(".csbody ul li").click(function() {
        $(this).parents(".csbody").children(".cstext").text($(this).text());
        var val = $(this).text();
        $(this).parents(".csbody").children(".csval").val(val);
        $(this).parents(".csbody ul").hide();
        
        //selected item change
        $(this).trigger("csChange", [val]);
    }).hover(function() {
        $(this).css("background-color", "#ccc");    
    }, function() {
        $(this).css("background-color", "#FFF");    
    });
    
    $("div.fotoVideoBox a.picture").fancybox({
        overlayShow : false    
    });
    
    $("div.fotoVideoBox a.video").each(function(i, item) {
        $(item).fancybox({
            overlayShow : false,
            href        : $(item).attr("href").replace(new RegExp("watch\\?v=", "i"), "v/"),
            type        : "swf",
            swf         : {
                wmode               : "transparent",
                allowfullscreen     : true
            }
        });
    });
       
});
