//toogle menu
function toggMenu(name)
{
    $("#"+name).slideToggle('slow');
    if ($("#"+name).hasClass("sub_open"))
        $("#"+name).removeClass("sub_open");
}

//hirek animate
function animate_bg(ele, from, to) {
    ele.css("background-color", "rgba(255, 255, 255, " + (from += from > to ? -1 : 1) / 30 + ")");
    if(from != to)
        setTimeout(function() {
            animate_bg(ele, from, to)
        }, 20);
}

//change ogyei logo
function changelogo()
{
    logo=$("#felsologo");
    if (logo)
    {
        if (logo.attr("src").match("logo.png"))
            logo.attr("src",logo.attr("src").replace("logo.png","logo2.png"));else
            logo.attr("src",logo.attr("src").replace("logo2.png","logo.png"));

        setTimeout(changelogo,8000);
    }
}
    
$().ready(function(){

    // replace text with canvas text
    Cufon.replace('#kapcsolat', {
        fontFamily: 'GeosansLight' ,
        fontWeight:'bold'
    });
    Cufon.replace('#kapcsolatleiras', {
        fontFamily: 'GeosansLight' ,
        fontWeight:'bold'
    });
    Cufon.replace('#closepop', {
        fontFamily: 'GeosansLight'
    });
    Cufon.replace('div.news_more', {
        fontFamily: 'GeosansLight'
    });

    //activate popup
    $(".popup a").hover(function() {
        $("#realpop").stop(true, true).animate({
            opacity: "show",
            top: "40"
        }, "slow");
    }, function() {});

    $("#closepop").bind('click', function(){
        $(this).parent().animate({
            opacity: "hide",
            top: "20"
        }, "fast");
    });

    $("div.news").each(function (index){
        $(this).hover(
            function() {
                return animate_bg($(this), 0, 15)
            },
            function() {
                return animate_bg($(this), 15, 0)
            }
            );
    });

    //timeout for logo
    setTimeout(changelogo,8000);
});
