var path = 'http://nawigo.eu/bookmarks/';
function pageHeight(){
    jQuery("#bookmarks-page").css('height', window.innerHeight - parseInt(jQuery(".bookmarks-top").css("height")));
}

function setBookmark(obj){
    jQuery("#bookmarks li a.active").removeClass('active');
    jQuery(obj).addClass('active');
    background = jQuery(obj).attr('bg');
    jQuery(".bookmarks-content").css("background", "url(" + path + "backgrounds/page/" + background + ") repeat-x");
    try {
        if(backgrounds[background]['logo']!='')
            jQuery(".bookmarks-logo").html('<img src="' + path + backgrounds[background]['logo'] + '" width="' + backgrounds[background]['width'] + '" height="' + backgrounds[background]['height'] + '" />')
            .css('marginTop', (147 - backgrounds[background]['height']) / 2);
        else jQuery(".bookmarks-logo").html('');
        if(backgrounds[background]['inc']!='')
        {
            jQuery(".bookmarks-inc").html(backgrounds[background]['inc'])
            .css('width', parseInt(jQuery("body").css("width")) - parseInt(jQuery(".bookmarks-logo").css("width")));
        }
        else jQuery(".bookmarks-inc").html('');
    } catch(err) {}
}
jQuery().ready(function(){
    jQuery('a.out').click(function(){
        setBookmark(this);
        if(jQuery(".bookmarks-top").next().is("iframe")){
            jQuery("#bookmarks-page").next().remove();
            jQuery(".bookmarks-top").next().attr("src", jQuery(this).attr("href"));
        } else {
            jQuery(".bookmarks-body").remove();
            jQuery(".bookmarks-top").after('<iframe src="' + jQuery(this).attr("href") + '" id="bookmarks-page" name="page" width="100%" frameborder="0" scrolling="auto"></iframe>');
            pageHeight();
            jQuery(window).resize(function(){
                pageHeight();
            });
        }
        return false;
    });
});
