$(function() {
	
	$("#Notice").fadeOut(20000);
	function scroll_bar_text(){
		$('#cat_names').children('td').remove();
		$('.scroll-content-item h2').each(function(){
	 		$('#cat_names').append('<td><a href="#"><span>●</span>'+$(this).text()+'</a></td>');
		});
	};
	
	function hover_move(){
		var index = $('#cat_names a').index(this)+1;
		var num = $("#CenterBox .scroll-content-item").length;
		var scrollContent = $("#CenterBox");
		var hidden_len = parseInt((num-6)*($(".scroll-content-item").width()+4));
		if (index==1) index =0;
		pp = hidden_len/num*(index);
		scrollContent.animate({
			marginLeft:-pp
		});
	};
	function none_(){
	};
	

	
	function names_hover(){
		
		$('#cat_names a').hoverIntent({
			sensitivity:3,
			interval:200,
			over:hover_move,
			out:none_
		});
	};
	setCenterBoxWidth();
	function setCenterBoxWidth(){
		var total_width=0;
		var each_length = $(".scroll-content-item").width()+4;
		var num = $("#CenterBox .scroll-content-item").length;
		total_width = each_length * num;
		$("#CenterBox").width(total_width);
		
	}
	
	$("#CenterBox").sortable({
		axis:'x',
		handle:'h2',
		stop:function(e,ui){
			scroll_bar_text();
			names_hover();
		}
	});
//	$(".url-item").sortable({
//				connectWith : ['.url-item']
//			});
		
	$("#login_").click(function(){
		$("#login").dialog("open");
	});
	$("#cancer").click(function(){
		$("#login").dialog("close");
	});
	
	$("#login").dialog({
		autoOpen : false,
		width : 300,
		modal : true,
		opacity : 0.5
	});
	//选择背景
	$("#Themes a").click(function(){
		var theme_id=$(this).attr('class');
		$('body').attr('id',theme_id);
		$("#Themes a img").removeClass();
		$(this).find('img').addClass('Current');
	})
});

function changeTab(str) {
	if (str == null || str == "") {
		  str = "Baidu";
	  }
	  document.getElementById("BaiduLi").className="";
	  document.getElementById("GoogleLi").className="";
	  document.getElementById("TaobaoLi").className="";
	  document.getElementById("YoudaoLi").className="";
	  document.getElementById("Baidu").style.display="none";
	  document.getElementById("Google").style.display="none";
	  document.getElementById("Taobao").style.display="none";
	  document.getElementById("Youdao").style.display="none";
	  document.getElementById(str+"Li").className="Current";
	  document.getElementById(str).style.display="";
}