//google.load("jquery","1");
google.load("jqueryui", "1.8.4");
//google.load("swfobject", "2.2");

function initialize() {
        

    
    $('.module.window,#accordion > div')
        .wrapInner("<div class='center' />")
        .prepend("<div class='top' />")
        .append("<div class='bottom' />");
        
    $('.module h1,.module h3,button')
        .wrapInner("<div class='title' />")
        .prepend("<div class='leftRound' />")
        .append("<div class='rightRound' />");
    
    $('.module h1,.module h3').each(function(){
        if($.browser.msie) {
            $(this).parent().filter(".window .center").width($(this).parent().filter(".window .center").width()+20+"px");
        }
        $(".title",this).width($(this).width()-12);
    });
    if($.browser.msie) {
        $('button').each(function(){
            $(this).width($('.title').width()+33);
        });
    }
    /* NEWS BEGIN*/
    $('.news>div:gt(3)').addClass("archived");
    $('.news>div:not(.archived)').wrapAll("<div id='news' />");
    $("div.archived:odd").addClass("odd");
    
    $("#news").prepend("<ul />");
    $("#news > div").each(function(){
        $(this).attr("id","tab-"+$(this).index());
        $("#news ul").append("<li><a href='#tab-"+$(this).index()+"'>"+$(this).index()+"</a></li>");
        $(".shortcut",this).wrapInner("<div class='description' />");
        $('.shortcut',this).prepend("<a href='"+$('h1 a',this).attr("href")+"' title='"+$('h1 a',this).text()+" czytaj więcej'></a>");
        //$('.description',this).prepend("<a href='"+$('h1 a',this).attr("href")+"' title='"+$('h1 a',this).text()+" - Kliknij aby przeczytaÄ‡ caĹ‚oĹ›Ä‡'>"+$('h1 a',this).text()+"</a>")
        $('.shortcut',this).css({
            'background-image':'url('+$('img',this).attr("src")+')'
        })
        // style='background-image:url("+$('img',this).attr("src")+")'
        $('img',this).remove();
        
    });
    
    $('#news > div h1')
        .wrapInner("<div class='title' />")
        .prepend("<div class='leftRound' />")
        .append("<div class='rightRound' />");
        
    $(".title","#news > div h1").width($("#news > div h1").width()-12-30);
    
     if($.browser.msie) {
        $(".title","#news > div h1").width($("#news > div h1").width()-12);
     }
    $("#news").tabs().tabs( "rotate" , 4000 , true );
    /* NEWS END*/
    $(".news .archived img")
        .wrap("<div class='imageWrapper' />");
        
    $(".news .archived img").each(function() {
        $(this).cjObjectScaler({
            destElem: $(".imageWrapper"),
            method: "fill"
        });
    });
    
    
    /*
    $("#mainFrame").sortable({
        items: ".section"
    });
    */
    
    
    if ($.browser.msie) {
        $("#search input:radio").css({
            "marginTop":parseInt($("#search #internet").css('margin-top'))-4+"px"
        });
        $("#query input").css({
            "marginLeft":parseInt($("#query input").css('margin-left'))-10+"px"
        });
        
       

    }
  
}

google.setOnLoadCallback(initialize);

