var como = como || {};

function replaceAll(txt, replace, with_this) {
    return txt.replace(new RegExp(replace, 'g'), with_this);
}

como.setColumnHeight = function() {
    var content = $("#maincontent");
    var sidebar = $("#imagecontent");

    var sidebarHeight = sidebar.height();
    var contentHeight = content.height();
    if (sidebarHeight > contentHeight) {
        content.height(sidebarHeight);
    } else {
        sidebar.height(contentHeight);
    }
};

como.resizeWrapper = function() {
    var wr = $("#wrapper");
    var win = $(window);
    wr.width(win.width());

    wr.height("auto");
    if (wr.height() < win.height()) {
        wr.height(win.height());
    }
};


$(document).ready(function() {
    //same height for both columns
    // como.setColumnHeight();

    //setup print link
    $("#entry_print").show().click(function() {
        window.print();
    });
    
    $("#mainmenubackground li span").css({opacity:0});

    var pagePos = $("#page").offset();
    $("#secondarymenu").css({display:"block",left:pagePos.left + 15 + $("#page").width(), top:14});
    $("#mainmenu li").each(function(index) {
        var entry = $(this);

        entry.hover(function() {
            if (!entry.hasClass("active")) {
                var selector = "#mainmenubackground li." + entry.attr("class") + " span";
                var el = $(selector);
                el.animate({opacity:1}, 500, "easeInOutCubic");
            }
        }, function() {
            if (!entry.hasClass("active")) {
                var selector = "#mainmenubackground li." + entry.attr("class") + " span";
                var el = $(selector);
                el.animate({opacity:0}, 500, "easeInOutCubic");
            }
        });


    });


});
