jQuery(function($) {
/*
    $("li.widget").click(function() {
        window.location = $(this).find("h3 a").attr("href");
        return false;
    });
*/
    $("body").addClass("js-on");
    $("div#slideshow").cycle({timeout: 5000});

    //Add pdf icons
    $('a[href$=".pdf"]').css({
        'background': "url('/images/pdf.png') no-repeat left 50%",
        'padding': '2px 0 2px 20px ',
        'border': 'none!important',
        'text-decoration': 'underline'
    });

    var wb = $('#container .main');
    if (wb.length == 1) {

        wb.css({margin:0,top:0});
        
        var height = wb.height()+(parseInt(wb.css('padding-top'))+parseInt(wb.css('padding-bottom'))+3);

        wb.css({
            'top':'50%',
            'margin-top':(-height/2)
        });
    }

    $('#wrapper').find('#header').css('padding-top',0);
    if ($(window).height() > $('#wrapper').height()) {
        $('#wrapper').center();
    }
    $(window).resize(function(){
        if ($(window).height() > $('#wrapper').height()) {
            $('#wrapper').center();
        }
    })

});


jQuery.fn.center = function(o){
    var o = jQuery.extend({
            position : 'absolute'
        },o),
        w = jQuery(window),
        top = (w.height()-this.height())/2,
        left = (w.width()-this.width())/2;
         
    switch(o.position){
        case 'fixed':break;
        default:
            top += w.scrollTop();
            left += w.scrollLeft();
            o.position = 'absolute';
            break;
    }
    this.css({
        "top"       : top,
        "left"      : left,
        'position'  : o.position
    });
    return this;
}