function checkSearch(num){
    var vid= '';
    for(i = 0; i<3;i++){
        vid= 'search'+i;
         if(i==num){
            document.getElementById(vid).className="current";
            document.getElementById("type").value=i;
	   
         }else{
            document.getElementById(vid).className="";
         }
    }


}
function search(){
    var n =  document.getElementById("k").value;
    if(n!='看看有没有你想要的东西' && !checkStr(n)  ){
       return true;
    }else{
       alert("搜索字段不能为空！！");
       return false;
    }

}
function trim(text){
  if (typeof(text) == "string"){
    return text.replace(/^\s*|\s*$/, "");
   }
}
function checkStr(str){
   var t = trim(str);
   if(t.length>0){
     return false;
   }else{
     return true;
   }
}
function checkChannel(str){
    if(str=='movie'){
      document.getElementById("movie").checked=true;
      document.getElementById("tv").checked=false;
    }else{
      document.getElementById("tv").checked=true;
      document.getElementById("movie").checked=false;
    }
    checkSelect(str,'','','','');
}
function onselect(type,num){
	         for(i = 1 ;i<=10;i++){
	             idName = type+"_"+i;
	             if(num==i){
	                 document.getElementById(idName).className="";
	             }else{
	                 if(document.getElementById(idName)!=null){
	                    document.getElementById(idName).className="bg";
	                 }
	             }
	         }
	      }
function checkSelect(str,rvalue,svalue,yvalue,cvalue){
    var regionS = document.getElementById("region");
    var sortS=document.getElementById("sort");
    var yearS=document.getElementById("year");
    var charS=document.getElementById("char");
        regionS.disabled=false;
        sortS.disabled=false;
        yearS.disabled=false;
        charS.disabled=false;
    getSelectValues(regionS,str,'1',rvalue); 
    getSelectValues(sortS,str,'2',svalue);
    getSelectValues(yearS,str,'3',yvalue); 
    getSelectValues(charS,str,'4',cvalue);  
}
function getSelectValues(selectObj,channel,type,value){
     var optionValues;
     if(type==1){
        if(channel == 'movie')
            optionValues = movie_region.split(";");
          else
            optionValues = tv_region.split(";");
        loadSelect(selectObj,optionValues,type,value);
     }
     if(type==2){
        if(channel == 'movie')
            optionValues = movie_sort.split(";");
          else
            optionValues = tv_sort.split(";");
        loadSelect(selectObj,optionValues,type,value);
     }
      if(type==3){
        optionValues = maxYear;
        loadSelect(selectObj,optionValues,type,value);
     }
     if(type==4){
        optionValues = char_sort.split(";");
        loadSelect(selectObj,optionValues,type,value);
     }
}
function loadSelect(selectObj,optionValues,type,value){
    clearSelect(selectObj);
    selectObj.options.add(new Option("请选择", "0"));
    if( type == 1 || type == 2 || type == 4){
        for(i=0;i<optionValues.length;i++){
          if(value != '' && optionValues[i]==value){
			selectObj.options.add(new Option(optionValues[i],optionValues[i]));
			selectObj[i+1].selected = true;
		  }else{
			selectObj.options.add(new Option(optionValues[i],optionValues[i]));
		  }  
        }
    }else{
        for(i=0;i<10;i++){
            var year = optionValues-i;
            if(value != '' && year==value){
			   selectObj.options.add(new Option(year,year));
			   selectObj[i+1].selected = true;
		    }else{
			   selectObj.options.add(new Option(year,year));
		    } 
        }
    }
 }
function clearSelect(selectElement){
	selectElement.options.length=0;
}
function searchPages(pageNum){
    var formID =  document.getElementById("search");
    document.getElementById("pageNum").value=pageNum;
    formID.submit();
    }
function correctPNG()
{
   for(var i=0; i<document.images.length; i++)
   {
   var img = document.images[i]
   var imgName = img.src.toUpperCase()
   if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
   {
   var imgID = (img.id) ? "id='" + img.id + "' " : ""
   var imgClass = (img.className) ? "class='" + img.className + "' " : ""
   var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
   var imgStyle = "display:inline-block;" + img.style.cssText
   if (img.align == "left") imgStyle = "float:left;" + imgStyle
   if (img.align == "right") imgStyle = "float:right;" + imgStyle
   if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle 
   var strNewHTML = "<span " + imgID + imgClass + imgTitle
   + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
   + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
   + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
   img.outerHTML = strNewHTML
   i = i-1
   };
   };
};

if(navigator.userAgent.indexOf("MSIE")>-1)
{
window.attachEvent("onload", correctPNG);
};

