function EditInfo(theform,sid) {
    var v = [];
    var checkCount = 0;
    var ids = document.getElementsByName("CD_ID[]");

    for(i=0; i<ids.length; i ++) {
        if (ids[i].checked) {
            checkCount ++;
            v.push(ids[i].value);
        }
    }
    if (checkCount == 0) {
        alert("请选中要进行操作的数据!");
        return false;

    } else {
        var idss=v.join(',')
        window.location=''+sid+'?id='+idss;
    }
}
function Plugup(theform,title,url,width,height,top) {
    var v = [];
    var checkCount = 0;
    var ids = document.getElementsByName("CD_ID[]");

    for(i=0; i<ids.length; i ++) {
        if (ids[i].checked) {
            checkCount ++;
            v.push(ids[i].value);
        }
    }
    if (checkCount == 0) {
        alert("请选中要进行操作的数据!");
        return false;

    } else {
        var idss=v.join(',')
        pop.up(title,url+idss,width,height,top);
    }
}
function CheckAll(form)  {
  for (var i=0;i<form.elements.length;i++)    {
    var e = form.elements[i];
    if (e.name != 'chkall')       
	e.checked = form.chkall.checked; 
   }
}		

function createXMLHttpRequest(){
       	if (window.XMLHttpRequest) {
		XMLHttpReq=new XMLHttpRequest();
	}else if (window.ActiveXObject) {//IE 浏览器
	     try {
			    XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
	     } catch (e) {
		        try{
					XMLHttpReq=new ActiveXObject("Micrsost.XMLHTTP");
				} catch(e){}
	     }
        }
}

var cache = new Array();
function getHttpObject() {
    var objType = false;
    try {
        objType = new ActiveXObject('Msxml2.XMLHTTP');
    } catch(e) {
        try {
            objType = new ActiveXObject('Microsoft.XMLHTTP');
        } catch(e) {
            objType = new XMLHttpRequest();
        }
    }
    return objType;
}

function showad(_id){
	var theHttpRequest = getHttpObject();
	theHttpRequest.onreadystatechange = function() {processAJAX();};
	theHttpRequest.open("GET", "inc/ajaxs.php?action=showad&id="+_id, true);
	theHttpRequest.send(null);
	function processAJAX(){
		if (theHttpRequest.readyState == 4) {
			if (theHttpRequest.status == 200) {
				document.getElementById("ad").innerHTML = unescape(theHttpRequest.responseText);
			} else {
				document.getElementById("ad").innerHTML = "载入失败";
			}
		}
	}
}

function showcount(){
	var theHttpRequest = getHttpObject();
	theHttpRequest.onreadystatechange = function() {processAJAX();};
	theHttpRequest.open("GET", "inc/ajaxs.php?action=showcount", true);
	theHttpRequest.send(null);
	function processAJAX(){
		if (theHttpRequest.readyState == 4) {
			if (theHttpRequest.status == 200) {
				document.getElementById("showcount").innerHTML = unescape(theHttpRequest.responseText);
			} else {
				document.getElementById("showcount").innerHTML = "载入失败";
			}
		}
	}
}

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='EditIsBest("+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='EditIsBest("+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='EditIsBest("+ids+","+j+")' />"
	}
        document.getElementById("CD_IsBest"+ids).innerHTML = htmlStr;
}

function EditIsBest(_id,_l){
	 createXMLHttpRequest();
	 XMLHttpReq.open("GET", "inc/ajaxs.php?action=videoeditisbest&id="+ _id +"&l="+ _l,true);
	 XMLHttpReq.onreadystatechange= function(){
		if(XMLHttpReq.readyState == 4){
			if(XMLHttpReq.status == 200){
				if(XMLHttpReq.responseText==1){
					ShowStar(_l,_id);
				}else{
					document.getElementById("CD_IsBest"+_id).innerHTML = "<font color='red'>提交失败</font>";		
				}
			}else alert("网络链接失败");
		}
	}
	XMLHttpReq.send(null);
}
