$(document).ready(function(){

    $("div.ddiv").css("display","none");
    $("a.ddiv").bind('click', function(event) {
        event.preventDefault();
        if ($.browser.opera) target = 'html'; else target = 'html,body';
        if( $(this).parent().next().hasClass('collapsed') ) {
            $(this).parent().parent().find('div.ddiv').slideUp({ duration: 500 });
            $(this).parent().parent().find('div.ddiv').removeClass('expanded').addClass('collapsed');
            $(this).parent().next().slideDown({ duration: 500, complete: function() { $(target).animate({scrollTop: $(this).prev().children('a').offset().top}, 1000);}});
            $(this).parent().next().find('img').each(function(){
                if($(this).width()>$("#content_middle_box").width())
                {
                    $("#page").width($("#page").width()+$(this).width()-$("#content_middle_box").width()+20);
                }
                else
                {
                    $("#page").width("47%");
                }
            });
            $(this).parent().next().removeClass('collapsed').addClass('expanded');
        } else {
            $(this).parent().next().slideUp({ duration: 500 });
            $("#page").width("47%");
            $(this).parent().next().removeClass('expanded').addClass('collapsed');
        }
    });

    $('#sponsors_carousel').jCarouselLite({
        auto: 3000,
        vertical: false,
        circular: true,
        scroll: 1,
        visible: 2,
        speed: 1000
    });

    $("a[rel^='prettyPhoto']").prettyPhoto();

});