$(document).ready(function(){
    $('.toggle_sidebar').toggle(
        function () {
            $($(this).children()[0]).html('打开侧边栏'); 
            $(this).attr('title','打开侧边栏');
	    $('.SR').fadeOut("fast");  
	    $('.SC').animate({
		width:"930px"             
	    },1000);  
        },
        function () {
            $($(this).children()[0]).html('关闭侧边栏'); 
            $(this).attr('title','关闭侧边栏');
	    $('.SC').animate({
		width:"590px"           
	    },1000);                     
	    $('.SR').fadeIn(3000); 
        }
    );
});

function ShowTab(T){
	if(T<3){
		i = 0;
		while($('#tab' + i).html() != null&&i<3){
			$('#tab' + i).removeClass();
			i++;
		}
		getContent(T,0);
	}
	else{
		i = 3;
		while($('#tab' + i).html() != null){
			$('#tab' + i).removeClass();
			i++;
		}
		getContent(T,1);
	}
	
	$('#tab' + T).addClass('active');
}


function getContent(t,s){
	$.ajax({
		url: '/wp-content/themes/dilectio/my_ajax_sidebar_maker.php?act='+t+"&time="+Date(),	
		type: 'GET',
		dataType: 'html',
		timeout: 20000,
		error: function(){
			$('#div'+s).html('Load ERROR,Reload Please!!');
		},
		beforeSend: function(){
			var loading='<span class="aploading">Loading</span>';
			$('#div'+s).html(loading).show();
		},
		success: function(msg){
			$('#div'+s).html(msg).show();
		}
	})
}

