// JavaScript Document
$(document).ready(function(){
	$("#ChkAll").click(function(){
		if($(this).attr("checked")==true){
			$("input[id='S_ID']").each(function(){
				$(this).attr("checked",true);									 
			})							
		}else{
			$("input[id='S_ID']").each(function(){
				$(this).attr("checked",false);									 
			})							
		}
	})
		
   $("#search").click(function(){
		var keyword=$("#keyword")[0].value;
		var types=$("#types")[0].value;
		if(keyword==''){
			$("#keyword").css("border","1px solid red");
			return false;	
		}else{
			if(types==1){
			$("#form1").attr("action",'admin_videotopic.php?action=listbysc&keyword='+ keyword);}
			else{
			$("#form1").attr("action",'admin_articletopic.php?action=listbysc&keyword='+ keyword);}
			$("#form1").submit();
		}
	})
		
})


function ShowStar(level,ids){
		   var htmlStr=""
			if(level==0){level=0}
			if (level>0){htmlStr+="<img src='images/starno.gif' border='0' style='cursor:pointer;margin-left:2px;' title='取消推荐' onclick='EditReco("+ids+",0)'/>"}
			for(i=1;i<=level;i++){
			htmlStr+= "<img src='images/star0.gif' border='0' style='cursor:pointer;margin-left:2px;'  title='推荐为"+i+"星级' id='star"+ids+"_"+i+"' onclick='EditReco("+ids+","+i+")' />"}
			for(j=level+1;j<=5;j++){
			htmlStr+= "<img src='images/star1.gif' border='0' style='cursor:pointer;margin-left:2px;'  title='推荐为"+j+"星级' id='star"+ids+"_"+j+"' onclick='EditReco("+ids+","+j+")' />"
	}
		   $("#S_Reco"+ids).html(htmlStr);
		   }
		   
function EditReco(ids,level){
  $.get(
	  "js/ajaxfun.php?id="+ids+"&types=2&level="+level+"&action=editreco", 
	  function(obj){
		  if(obj=='ok'){
			  ShowStar(level,ids);
		  }else{
			  $("#S_Reco"+ids).html("<font color='red'>Error!</font>");		
		  }
	  }
  );
}