var topchannel = "#taskindex";
var focus_pic_count=1;
var focus_pic_autochange;
var newtask_list_scroll;

function newtask_list_up(){
	$("#newtask_list").animate({top:"-25px"},1000,function(){
		$(this).find("li:first").appendTo(this)
		$(this).css({top:0});
	});
}

$(document).ready(function(){

$(".tablist .task_tab li").hover(function(){
	$(".task_list ul").hide().eq($(".task_tab li").removeClass("task_tab_on").index($(this).addClass("task_tab_on"))).show();
},function(){});
$(".employer .tab li").hover(function(){
	$(".employer .tab_list .tl").hide().eq($(".employer .tab li").removeClass("curr").index($(this).addClass("curr"))).show();
},function(){});
$(".worker .title a").hover(function(){
	$(".worker .worker_list").hide().eq($(".worker .title a").index(this)).show();
},function(){});

var costlist = $(".employer .cost_list").length-1;
var costlist_i = 0;
$(".employer .cost_list:first").show();
$(".employer .larr").click(function(){
	if (costlist_i > 0){
		$(".employer .cost_list").hide();
		$(".employer .cost_list").eq(costlist_i-1).show();
		costlist_i--;
	}
});
$(".employer .rarr").click(function(){
	if (costlist_i < costlist){
		$(".employer .cost_list").hide();
		$(".employer .cost_list").eq(costlist_i+1).show();
		costlist_i++;
	}	
});

//$("#focus_pic_list").append("<a href=\"http://www.taskcn.com/w-71557.html\" target=\"_blank\" ><img src=\"http://www.taskcn.com/images/task/cygs.jpg\" /></a>").append("<a href=\"http://my.taskcn.com/employer\" target=\"_blank\" ><img src=\"http://image.taskcn.com/images/www_index_0090429/focus_pic_02.jpg\" /></a>");
$("#focus_pic_list").append("<a href=\"http://www.taskcn.com/w-72943.html\" target=\"_blank\" ><img src=\"http://www.taskcn.com/images/task/yhzj12.jpg\" /></a>").append("<a href=\"http://my.taskcn.com/employer\" target=\"_blank\" ><img src=\"http://image.taskcn.com/images/www_index_0090429/focus_pic_02.jpg\" /></a>");

$("#focus_pic_change_box").show();
$("#focus_pic_change_count").html("<strong>"+focus_pic_count+"</strong> / "+$("#focus_pic_list img").length);

$("#focus_pic_change_prev,#focus_pic_change_next").hover(function(){
	$(this).addClass("active");
},function(){
	$(this).removeClass("active");
}).click(function(){
	$("#focus_pic_list").stop(true,true);
	if(this.id=="focus_pic_change_prev"){
		$("#focus_pic_list").animate({marginLeft:0},500,function(){
			$(this).css("margin-left","-637px").find("a:last").prependTo(this);
			$("#focus_pic_change_count").html("<strong>"+(focus_pic_count==1?focus_pic_count=3:--focus_pic_count)+"</strong> / "+$("#focus_pic_list img").length);
		});
	}else{
		$("#focus_pic_list").animate({marginLeft:"-1274px"},500,function(){
			$(this).css("margin-left","-637px").find("a:first").appendTo(this);
			$("#focus_pic_change_count").html("<strong>"+(focus_pic_count==3?focus_pic_count=1:++focus_pic_count)+"</strong> / "+$("#focus_pic_list img").length);
		});
	}
});

$("#focus_pic_box").hover(function(){
	clearInterval(focus_pic_autochange);
},function(e){
	var focus_space=$(this);
	if((e.pageX<focus_space.offset().left||e.pageX>=(focus_space.offset().left+focus_space.outerWidth())||e.pageY<focus_space.offset().top||e.pageY>=(focus_space.offset().top+focus_space.outerHeight()))){
		focus_pic_autochange=window.setInterval('$("#focus_pic_change_next").click()',10000);	
	}
});

focus_pic_autochange=window.setInterval('$("#focus_pic_change_next").click()',10000);
newtask_list_scroll=window.setInterval('newtask_list_up()',2000);

$("#newtask_list").hover(function(){
	clearInterval(newtask_list_scroll);
},function(){
	newtask_list_scroll=window.setInterval('newtask_list_up()',2000);
});

//$(".open_class_list").click(function(){
//	$(".open_class_list").show();
//	$(".task_class_list").hide();
//	$(".class_name").removeClass("open_list");
//	$(this).hide().parents(".class_name:first").addClass("open_list").next(".task_class_list").show();
//	if($(this).parents(".class_name:first").attr("id")=="class_name_rencai"){
//		$("#task_class_foot").addClass("active");
//	}else{
//		$("#task_class_foot").removeClass("active");
//	}
//	document.documentElement.scrollTop=$("#task_class_anchor").offset().top;
//});
var index_left_big_adv=Math.random();
/*if(index_left_big_adv>0.8){
		$("#www_big_banner").html("<a href=\"http://act.taskcn.com/yongchun/\" ><img src=\"http://image.taskcn.com/images/update/yongchun.jpg\" alt=\"永春白鹤拳形象设计大赛\" title=\"永春白鹤拳形象设计大赛\" /></a>");
if(index_left_big_adv>0.75){
	$("#www_big_banner").html("<a href=\"http://weike.taskcn.com/act/spread\" ><img src=\"http://www.taskcn.com/images/update/aolin-2.jpg\" alt=\"邀请好友加入任务中国得现金\" title=\"邀请好友加入任务中国得现金\" /></a>");
}else if(index_left_big_adv>0.5){
	$("#www_top_banner").html("<a href=\"http://act.taskcn.com/xzuan\" ><img src=\"http://image.taskcn.com/images/update/xzuan-2.jpg\" alt=\"任务中国携手新钻网\" title=\"任务中国携手新钻网\" /></a>");}
}else */
/*
if(index_left_big_adv>0.25){
	$("#www_big_banner").html("<a href=\"http://www.taskcn.com/w-53199.html\" ><img src=\"http://www.taskcn.com/images/update/cw.jpg\" title=\"前往超威电源有限公司LOGO设计\" /></a>");
}*/
});
