// ------------------------- div#leftcon -------------------------------------------------------
$("ul.assort").not("#show").hide().prev().css("background-image","url(/img/title2.jpg)");
$("ul.assort li").not(":has(ul)").css("backgroundImage", "none")
$("h2.title").click(function(){
							   $("ul.assort:visible").hide().prev().css("background","url(/img/title2.jpg) no-repeat");
							   $(this).css("background","url(/img/title1.jpg) no-repeat").next().show();
							   });
// -------------------------- index div#right div.ranking:last-child ------------------------------------------
for(var i=1;i<11;i++){
	var num = "url(/img/"+ i +".gif) no-repeat 0 50%";
	$("div.ranking ol li").eq(i-1).css({"background":num,"padding-left":"20px"});
	$("div.ranking ol li").eq(i+9).css({"background":num,"padding-left":"20px"});
}
if ( $("div.wtp") && i>5){
	$("div.wtp").prev().find("li").slice(5, 10).css({"width":"70px","position":"relative","left":"90px","top":"-140px"});
}
$("div.wtp").prev().children("ol").css({"height":"140px","background-position":"0 -180px"});

// -------------------------- New books pic loop -------------------------------------------------------------
$("ol.picloop li:not(:first) a").hide().removeClass("active");
$("ol.picloop li:first-child a").next().addClass("active");
var AutoPlayObj = null;
function pic(){
	var a = $("ol.picloop a:visible").parent()
	if(a.is(":last-child")){
		a.children("a").hide().next().removeClass("active"); 
		a.parent().children(":first").children("a").show().next().addClass("active"); 
		}
	else{
		a.children("a").hide().next().removeClass("active");
		a.next().children("a").show().next().addClass("active");
	}
}
function AutoPlay(){
	 clearInterval(AutoPlayObj);
	 AutoPlayObj = setInterval(pic,3000); 
}
$("ol.picloop span").click(
	function(){
		$("ol.picloop a:visible").hide().next().removeClass("active");
		$(this).prev().show().next().addClass("active");
		},function(){});
$("ol.picloop img,ol.picloop span").hover(
  function(){clearInterval(AutoPlayObj);},AutoPlay
); 
AutoPlay();	
	
//NEWS text loop
var a = $("div.news ol").children("li").size();
var ol = 0;
var apText = null
a=(a<=5)?a:5;
for(var i=0;i<a;i++) {
	ol+= $("div.news ol").children("li").eq(i).width();
	ol -=20;
}
$("div.news ol").clone(true).insertAfter("div.news ol");
$("div.news").width(ol*2).children("ol").width(ol);
$("div.news ol").next().hide();
function text(){
	$("div.news ol:hidden").css("left","225px");
	if (parseInt($("div.news ol:visible").css("left")) <= -ol+225) {
		$("div.news ol:hidden").show();
	}
	$("div.news ol:visible").each(function() {
										   left = parseInt($(this).css("left"));
										   left -=1;
										   $(this).css("left",left+"px");
										   if (parseInt($(this).css("left")) <= -ol) {
											   $(this).hide();
										   }
	}).hover(
  function(){clearInterval(apText);},AutoPlayT
			);
}
function AutoPlayT(){
	 clearInterval(apText);
	 apText = setInterval(text,50); 
}
AutoPlayT();
