﻿function switchTab(a, b, c, d, e) {
    try {
        for (i = 0; i < c; i++) {
            var f = document.getElementById("Tab_" + a + "_" + i),
            g = document.getElementById("List_" + a + "_" + i);
            if (i != b) {
                f.className = e;
                g.style.display = "none"
            }
        }
        try {
            for (ind = 0; ind < CachePic[a][b].length; ind++) document.getElementById(a + "_pic_" + b + "_" + ind).src = CachePic[a][b][ind]
        } catch(h) {}
        document.getElementById("Tab_" + a + "_" + b).className = d;
        document.getElementById("List_" + a + "_" + b).style.display = ""
    } catch(j) {}
}


function show(){
    document.getElementById("List_top_1").style.display = "block";
}


function hide(){
    document.getElementById("List_top_1").style.display = "none";
}

function openMsg(_id,_title,_html)
{
     var dg = new $.dialog({ id:_id,
     page:'/gbook/gbook.html?s='+Math.random(),
     autoSize:true,
     btnBar:false,
     maxBtn:false,
     title:_title,
     iconTitle:false,
     cover:true,
     bgcolor:'#000',
     opacity:0.2,lockScroll:true,
     rang:true,
     dgOnLoad:function(){ 
            $('#Text',dg.dgDoc).html(_html); 
            $('#sendID',dg.dgDoc).val(_id); 
        }
     }); 
     dg.ShowDialog(); 
}


function $E(id){
	return document.getElementById(id);
};
String.prototype.trim=function(){
	if(this){
		return this.replace(/(^\s*)|(\s*$)/g, "");
	}
	else{
		return this;
	}
};
function StringBuilder(value){
	this.strings = new Array("");
	if(value){		
		this.append(value);
	}
};
StringBuilder.prototype.append = function(value){
	if (value){
		this.strings.push(value);
	}
};
StringBuilder.prototype.clear = function (){
	this.strings.length = 1;
};
StringBuilder.prototype.toString = function (){
	return this.strings.join("");
};
window.baidu={};
window.baidu.result=null;
window.baidu.sug=function(v){
window.baidu.result=v;
};
var Juest={
  	submit:function(newwindow){
		try{
			var wd=$E("wd").value.trim();
			if(wd!=""){
				wd=encodeURIComponent(wd);
				if(newwindow){					
					window.open("/search/?wd=TITLE%7C%7C%7C"+wd);					
				}
				else{
				    window.location.href = ("/search/?wd=TITLE%7C%7C%7C"+wd);
				}
			}
			else{
				if(newwindow){
					window.open("/");
				}
				else{
					window.location.href=("/");
				}
			}
		}catch(e){}
		return false
	},
	Load:{
	    JsUri:function(jsobjid,uri,Charset,fun){
			try{
				new this.JsUri2(jsobjid,uri,Charset,fun);
			}catch(e){}
		},
		JsUri2:function(jsobjid,uri,Charset,fun){
			try{
				var S=$E(jsobjid);
				if(S){
					S.parentNode.removeChild(S);
				}
				S=$E(jsobjid);
				S = document.createElement('script');		
				S.setAttribute("id",jsobjid)
				S.setAttribute('language', 'javascript');
				S.setAttribute('type', 'text/javascript'); 
				if(Charset){
					S.setAttribute('charset', Charset);
				}					
				if(document.all && typeof(fun)=="function"){
					S.onreadystatechange = function(){
						if(this.readyState == 4 || this.readyState == 'complete' || this.readyState == 'loaded'){
							if(S.getAttribute("src")!=""){
								S.onreadystatechange =null;
							}
							try{fun();}catch(e){}
						}
					}
				}
				else if(typeof(fun)=="function"){
					S.onload = function() {
						if(S.getAttribute("src")!=""){
							S.onload=null;
						}
						try{fun();}catch(e){}
					}
				}
				S.setAttribute('src', uri);		
				document.getElementsByTagName("head")[0].appendChild(S);	
			}catch(ex){}
		}
	  },
     getkey2:function(eve){
		eve = eve?eve:window.event;
		var evn=eve.keyCode?eve.keyCode:eve.which;
		var str = $E("wd").value.trim();
		var video=$E('suggest');
		if(video.className!="none" && (evn==40|evn==38) && (str!="") && this.allNum>=0){
			if(evn==38){
				this.g38();
			}
			else if(evn==40){
				this.g40();
			}
			$E("wd").focus();
		}
	},
	getkey:function(eve){
		try{			
			eve = eve?eve:window.event;
			var evn=eve.keyCode?eve.keyCode:eve.which;
			var str=$E("wd").value.trim();
			var video=$E('suggest');
			if (evn!=38&evn!=40&evn!=13&evn!=37&evn!=39&str!=""){
				this.Text=str;
				this.getIDgetword(str);
			}
			else if ((evn==38||evn==40) && str!="" && video.innerHTML==""){
				this.Text=str;
				this.getIDgetword(str);
			}
			else if(video.className=="none" && (evn==40|evn==38) && (str!="") && this.allNum>=0) {
				video.className="";
			}
			else if(str==""){
				video.className="none";
				this.Text="";
			}
		}catch(e){}
	},
	setSearch:function(a){
		try{
			$E("wd").value = $E("suggest_af"+a).innerHTML;
			$E("suggest").className="none";
			this.Text=$E("wd").value; 
			this.thisNum=a;
			this.cache(1);
		}catch(e){}		
	},
	getIDgetword:function(value){
		if(value.trim()==""){return}
		Juest.Load.JsUri("baidumini","http://nssug.baidu.com/su?wd="+encodeURIComponent(value)+"&prod=video&t=" + Math.random(),"gb2312", function(){
			Juest.returnbaidu()
		});
	},
	baidu:null,
	returnbaidu:function(){
		try{
			var u=window.baidu.result.s;
			u=u?u:null;
			if((typeof(u))=="object"){				
				var video=$E("suggest");
				video.innerHTML = "";
				if (u.length>0){
					if(video.className="none"){
						video.className="";
					}
					var str=new StringBuilder();
					for (var i=0;i<u.length;i++){
						str.append("<div id=\"suggest_bf"+i+"\" onmouseover=\"Juest.g2("+i+");\"");
						str.append(" onclick=\"Juest.setSearch('"+i+"');\"");
						str.append(" class=\"suggest_link\"><div class=\"l\" id=\"suggest_af"+i+"\">" + u[i] + "<\/div><\/div>");
					}
					str.append("<div class=\"suggest_close\"><div class=\"l\">关键词自动补全取自百度视频<\/div><div class=\"r\"><a href=\"javascript:void(0);\" target=\"_self\">关闭<\/a><\/div><\/div>"); 
					video.innerHTML=str.toString();
					Juest.allNum=i-1; 
					Juest.thisNum=10; 
				}
				else{
					video.className="none";
					Juest.allNum=-1;
				}
			}
		}catch(e){}
	},
	allNum:0,
	thisNum:10,
	Text:"",
	g38:function(){
		if (this.thisNum==0){
			$E("suggest_bf0").className= "suggest_link";
			this.thisNum=10; 
			$E("wd").value=this.Text; 
		}
		else if(this.thisNum==10){
			this.thisNum=this.allNum; 
		}
		else{
			this.thisNum=this.thisNum-1; 
		}
		if(this.thisNum!=10){
			this.g1(this.thisNum,2);
		}
	},
	g1:function(a,x){
		if(x==2){
			$E("wd").value = $E("suggest_af"+a).innerHTML;
		}
		if(this.allNum>=0&this.allNum<=10){
			for (var i=0;i<=this.allNum;i++){
				if(a==i){
					$E("suggest_bf"+i).className = "suggest_link_over";
				}
				else{
					$E("suggest_bf"+i).className = "suggest_link";
				}
			}
		}
	},
	g2:function(a){
		this.g1(a,1);
		this.thisNum=a;
		$E("wd").focus(); 
	},
	g40:function(){
		if (this.thisNum==10){
			this.thisNum=0;
		}
		else if(this.thisNum==this.allNum){
			$E("suggest_bf"+this.allNum).className= "suggest_link";
			this.thisNum=10;
			$E("wd").value=this.Text;
		}
		else{
			this.thisNum=this.thisNum+1;
		}
		if(this.thisNum!=10){
			this.g1(this.thisNum,2);
		}
	},
	cache:function(v){
		if(v==1){
			Juest.submit(Juest.NewWindow);
		}
	},
	closeclass_c:true,
	clicktimer:null,
	dclick:function(){
		try{
			obj=$E("suggest")
			if(obj){
				obj.className="none";
			}
		}catch(e){}
		this.closeclass_c=true;
	}	
};
var Rol={
    Speed:10,          //速度(毫秒)
    Space:5,           //每次移动(px)
    PageWidth:170,     //翻页宽度
    fill:0,            //整体移位
    MoveLock:false,
    MoveTimeObj:null,
    Comp:0,
    AutoPlayObj:null,
    exist:function(id){
       var s=document.getElementById(id);
       if(s){
          return true
       }else{
          return false
       }
    },
    GetObj:function(objName){
       if(document.getElementById){
           return eval('document.getElementById("'+objName+'")')
       }else{
           return eval('document.all.'+objName)
       }
    },
    AutoPlay:function(){
       //自动滚动
       clearInterval(Rol.AutoPlayObj);
       Rol.AutoPlayObj = setInterval('Rol.ISL_GoDown();Rol.ISL_StopDown();',3000); //间隔时间 
    }, 
    ISL_GoUp:function(){
       //上翻开始
       if(Rol.MoveLock) return;
       clearInterval(Rol.AutoPlayObj);
       Rol.MoveLock = true;
       Rol.MoveTimeObj = setInterval('Rol.ISL_ScrUp();',Rol.Speed);
    },
    ISL_StopUp:function(){
       //上翻停止
       clearInterval(Rol.MoveTimeObj);
       if(Rol.GetObj('ISL_Cont').scrollLeft % Rol.PageWidth - Rol.fill != 0){
          Rol.Comp = Rol.fill - (Rol.GetObj('ISL_Cont').scrollLeft % Rol.PageWidth);
          Rol.CompScr();
       }else{
          Rol.MoveLock = false;
       }
       Rol.AutoPlay();
    },
    ISL_ScrUp:function(){
       //上翻动作
       if(Rol.GetObj('ISL_Cont').scrollLeft <= 0){
          Rol.GetObj('ISL_Cont').scrollLeft = Rol.GetObj('ISL_Cont').scrollLeft + Rol.GetObj('List1').offsetWidth;
          }
       Rol.GetObj('ISL_Cont').scrollLeft -= Rol.Space;
    },
    ISL_GoDown:function(){
       //下翻
       clearInterval(Rol.MoveTimeObj);
       if(Rol.MoveLock) return;
       clearInterval(Rol.AutoPlayObj);
       Rol.MoveLock = true;
       Rol.ISL_ScrDown();
       Rol.MoveTimeObj = setInterval('Rol.ISL_ScrDown()',Rol.Speed);
    },
    ISL_StopDown:function(){
       //下翻停止
       clearInterval(Rol.MoveTimeObj);
       if(Rol.GetObj('ISL_Cont').scrollLeft % Rol.PageWidth - Rol.fill != 0 ){
          Rol.Comp = Rol.PageWidth - Rol.GetObj('ISL_Cont').scrollLeft % Rol.PageWidth + Rol.fill;
          Rol.CompScr();
       }else{
          Rol.MoveLock = false;
       }
       Rol.AutoPlay();
    },
    ISL_ScrDown:function(){
       //下翻动作
       if(Rol.GetObj('ISL_Cont').scrollLeft >= Rol.GetObj('List1').scrollWidth){
          Rol.GetObj('ISL_Cont').scrollLeft = Rol.GetObj('ISL_Cont').scrollLeft - Rol.GetObj('List1').scrollWidth;
          }
       Rol.GetObj('ISL_Cont').scrollLeft += Rol.Space;
    },
    CompScr:function(){
       var num;
       if(Rol.Comp == 0){Rol.MoveLock = false;return;}
       if(Rol.Comp < 0){ //上翻
          if(Rol.Comp < -Rol.Space){
             Rol.Comp += Rol.Space;
             num = Rol.Space;
          }else{
             num = -Rol.Comp;
             Rol.Comp = 0;
          }
          Rol.GetObj('ISL_Cont').scrollLeft -= num;
          setTimeout('Rol.CompScr()',Rol.Speed);
       }else{ //下翻
          if(Rol.Comp > Rol.Space){
             Rol.Comp -= Rol.Space;
             num = Rol.Space;
          }else{
             num = Rol.Comp;
             Rol.Comp = 0;
          }
       Rol.GetObj('ISL_Cont').scrollLeft += num;
       setTimeout('Rol.CompScr()',Rol.Speed);
       }
    }
};
document.onclick=function(){
	try{
		if(Juest.closeclass_c){
			window.clearTimeout(Juest.clicktimer);
			Juest.clicktimer=window.setTimeout(function(){
			Juest.dclick();},200);
		}
		else{
			Juest.closeclass_c=true;
		}
	}catch(e){}
}

function position(o){
	var p={Top:0,Left:0};
	while(!!o){
		p.Top+=o.offsetTop;
		p.Left+=o.offsetLeft;
		o=o.offsetParent;
	}	
	/*if(p.Left>=1000){
		p.Left-=220;
	}else{
		p.Left+=130;
	}*/
	var chk_width=document.body.offsetWidth;
	if((p.Left+126+221)<document.body.offsetWidth){
		p.Left=p.Left+120;
	}else{
		p.Left=p.Left-207;
	}
	/*if(chk_width<(p.Left+211+126)){
		p.Left-=(211-126);
	}*/
	return p;
}
function show_movie_info(img_id,type,title,rating,rating_people_num,area,actors,director,year,play_diqu){	
	var img_obj=document.getElementById(img_id);
	if(img_obj){
		var pos=position(img_obj);		
	}
	var actors_text='主演';
    var director_text='导演';
	if(type=='zy'){
		actors_text='嘉宾';
		director_text='主持人';
	}
	var inner_html='<div class="bg_tm"></div>';
	inner_html+='<div class="win_content" id="div_tip_detail"><dl><dd>';
	inner_html+='<dt>'+title+'</dt>';
	var star_level=Math.floor(rating/2);
	inner_html+='<p class="p_1"><span class="star star'+star_level+'"><strong>'+rating+'</strong></span><em>['+rating_people_num+'评]</em></p>';
	
	inner_html+='<p>标签：<span>'+area+'</span></p>';
	
    inner_html+='<p>'+actors_text+'：<span>'+(actors==''?'--':actors)+'</span></p>';
	inner_html+='<p>'+director_text+'：<span>'+(director==''?'--':director)+'</span></p>';
	
	inner_html+='<p>年份：<span>'+(year==''?'':year)+'</span></p>';
	inner_html+='<p>地区：<span>'+play_diqu+'</span></p>';
	inner_html+='</dd></dl></div>';
	try{
		var obj=document.getElementById('movie_info');
		if(obj){
			obj.innerHTML=inner_html;			
			obj.style.top=pos.Top+"px";
			obj.style.left=pos.Left+"px";
			obj.style.display='block';
		}
	}catch(e){}
}
function hide_movie_info(){
	try{
		var obj=document.getElementById('movie_info');
		if(obj){
			obj.style.display='none';
		}
	}catch(e){}
}
function serchClick(name)
	{
		var box=document.getElementById(name);
		if(searchTextTimer!=null||box.value=='输入影片名或主演名')
		{box.value=''};
		stopSearchTextTimer();
		box.style.color='#000';
	}
function serchClick1(name)
	{
		var box=document.getElementById(name);
		if(searchTextTimer!=null||box.value=='输入影片名或主演名')
		{box.value=''};
		stopSearchTextTimer();
		box.style.color='#0c91c2';
	}
var lastpage = 1;//评论后转到最后页;

function GetComment($Page){
	$.ajax({
		url:"/content/Comment.aspx?action=get&id="+$SCOPE.mInfo.programId+"&page="+$Page+"&time"+new Date().toString(),
		type:'GET',
		success:function(){
			$('#comment').html(arguments[0].split('#$#')[0]);
			lastpage = arguments[0].split('#$#')[1];
		}
	});
}
function StopButton(){
	document.getElementById(arguments[0]).disabled=true;
	//document.getElementById(arguments[0]).value="稍等("+arguments[1]+")";
	if(--arguments[1]>0){
		window.setTimeout("StopButton('"+arguments[0]+"',"+arguments[1]+")",1000);
	}
	if(arguments[1]<=0){
		//document.getElementById(arguments[0]).value='发表评论';
		document.getElementById(arguments[0]).disabled=false;
	}
}

function Getpingfen(){
	$.ajax({
		url:"/content/ajax.aspx?id="+$SCOPE.mInfo.programId+"&time"+new Date().toString(),
		type:'GET',
		success:function(){
			$('#pingfen').html(arguments[0]);
		}
	});
}

function rand(e){
	$.ajax({
		url:"/rand/"+e+"/",
		type:'GET',
		success:function(){
			$('#rand_'+e).html(arguments[0]);
		}
	});
}

function SetKey(){
	$.ajax({
		url:"/content/keyword.aspx?wd="+encodeURIComponent(wd)+"&time"+new Date().toString(),
		type:'GET',
		success:function(){
		}
	});
}


function SendComment(){	
		var $CommentParentID	=$SCOPE.mInfo.programId;
		var $CommentUser		=$('#CommentUser').val();
		var $CommentText		=$('#CommentText').val();
		var $CommentValidate	=$('#CommentValidate').val();
		if ($.trim($CommentUser)=='')
		{
			alert('请您填写昵称！');
			$('#CommentUser').focus();
			return false;
		}	
		if ($.trim($CommentText)=='')
		{
			alert('请您填写回复内容！');
			$('#CommentText').focus();
			return false;
		}
		if ($CommentText.length<5||$CommentText.length>300||$CommentText=='健康上网 文明发言！')
		{
			alert('内容必须在5-300字之间！');
			return false;
		}
		if ($.trim($CommentValidate)=='')
		{
			alert('请您填写验证码！');
			$('#CommentValidate').focus();
			return false;
		}
		StopButton('CommentSubmit',10);
	$.ajax({
		url:"/content/Comment.aspx?action=send&id="+$CommentParentID+"&user="+escape($CommentUser)+"&text="+escape($CommentText)+"&validate="+escape($CommentValidate)+"&time="+new Date().toString(),
		type:'GET',
		error:function(){
		   alert('含有限制内容，请修改后再提交！');
		},
		success:function(){
			if (arguments[0]=='ERROR')
			{
				alert('验证码出错！');
			}else{
				GetComment(lastpage);
				//alert(arguments[0]);
				$("#CommentText").val("");
					//验证成功时，刷新验证码图片
				$("#CommentValidateImages").attr("src","/Utility/VerifyImg.aspx?s="+Math.random());
			}
			$("#CommentValidate").val("");
		}
	});
}







