var element = $( "#centerBody" );
element.addClass( "center" );
//element.css( "margin-left", -element.width() *0.5 );
//element.css( "margin-top", -element.height()*0.5 );

/*$(function(){    
    jQuery('.ContentContainer2').jScrollPane({showArrows:true, reinitialiseOnImageLoad: true});
});*/

function setPadding(){
    if($(this).attr('align')=="right"){
        $(this).css('margin','5px 5px 5px 5px');
    }else if($(this).attr('align')=="left"){
        $(this).css('margin','5px 5px 5px 0px');
    }
}

function AjaxLink(){
	var link = $(this).attr("href");
    $(this).click(function(){
        $.ajax({
            type: "GET",
            beforeSend: function(msg){
                $("#ajaxContent").empty().append('<br /><br /><br /><br /><br /><br /><img src="/themes/restavrator/images/ajax-loader.gif" border="0" align="absmiddle" style="border:0px;"/> Загрузка...');
            },
            data: ({ajaxDebug: 1, id: $(this).attr("need")}),
            url: $(this).attr("href"),
            success: function(msg){
                $("#ajaxContent").empty().append(msg);                
                $("#ajaxContent .resultInAjax").each(AjaxLink);                
            },
            complete: function(){
                if($("#Breadcrumbs2").html()!=$("#Breadcrumbs").html()){                    
                    //$("#Breadcrumbs").empty().append($("#Breadcrumbs2").html());
                }
                imgDefault();
                jQuery('.ContentContainer2').jScrollPane({showArrows:true, reinitialiseOnImageLoad: true});
				yaCounter1160659.hit(link, $("#Breadcrumbs").html().replace(/<.*?>/g, ''));
            },
        });
        //flush: 1,
        //$("#ajaxContent").load("/news-2009-08-06/",{ "ajaxDebug": 1 });
        return false;
    });
}

function imgDefault() {
    $("#ajaxContent img").each(function(){
        $(this).fadeTo("fast", 0.50);
    });

    $("#ajaxContent img").each(function(){
        $(this).mouseover(function(){
            $(this).fadeTo("fast", 1);
        }).mouseout(function(){
            $(this).fadeTo("fast", 0.50);
        });
    });
}

    window.yandex_metrika_callback = function() {
        window.yaCounter1160659 = new Ya.Metrika(1160659);
    }

jQuery().ready(function(){    

    $("img[align=right]").each(setPadding);
    $("img[align=left]").each(setPadding);

    $(document).pngFix();

    $("#accordion").accordion({
		event: "mouseover",
        icons: {
    		header: "ui-icon-circle-arrow-e",
            headerSelected: "ui-icon-circle-arrow-s"
		},
        autoHeight: false,
        active: false,
        header: 'h6'
    });

    //$(".resultInAjax").each(AjaxLink);

    $(function() {    	
    	$('#gallery a img').each(function(){$(this).parent().attr("rel","lightbox[]");});
    	//$('a[rel=lightbox[]]').each(function(){alert($(this).parent().html());});
        $('.typography a[rel=lightbox[]]').lightbox();
        //$('#gallery a img').lightbox({fixedNavigation:true});
    });

    imgDefault();
	
        var s = document.createElement('script');
        s.type = 'text/javascript';
        s.src = ((document.location.protocol=='https:')?'https:':'http:') + '//mc.yandex.ru/metrika/watch.js';
        s.setAttribute('async', 'true');		
        document.body.appendChild(s);    	
});


    
    

