// JavaScript Document

	var $=document.getElementById;
	function rank(id){
		for(var i=1;i<=3;i++){
			if(i==id){
				$("rank_"+i).style.background='#ffffff';
				$("rank"+i).style.display='block';
				}else{
				$("rank_"+i).style.background='#EDEDED';
				$("rank"+i).style.display='none';
				}	
		}
	}
	
	//用户登录
	xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	

	function login(f){
			var username=f.username.value;
			
			var pw=f.pw.value;
			//var yzm=f.yzm.value;
			
			if(username.length==0){
				alert('用户名不能为空！');
				f.username.focus();
			}/*else if(pw.length<3){
				alert('密码不能小于三位！');
				f.pw.focus();	
			}else if(yzm.length<4){
				alert('验证码为四位！');
				f.yzm.focus();	*/
			else{
				var url="/webmedia/oemui/customer/user_chk.asp?u="+username+"&p="+MD5.Encode(pw)+"&rnd="+Math.random();
				//alert(url);
				xmlhttp.open("GET",url,true);
				xmlhttp.onreadystatechange=user_chk_back;
				xmlhttp.send(null);
				//return false;
				}
			//alert(MD5.Encode(username));
			return false;
		}

function chkLogin()
{
	var url="/webmedia/oemui/customer/chkLogin.asp?rnd="+Math.random();
	
	xmlhttp.open("GET",url,true);
	xmlhttp.onreadystatechange=function(){
	
		if(xmlhttp.readystate==4)
		{
			var str=xmlhttp.responseText;
			
				
			if(str!='ok')
			{
				if(str=='charge')
					location.href="/webmedia/oemui/customer/charge.asp";
				else
					location.href="/webmedia/login.asp";
			}
		}

	};
	xmlhttp.send(null);
}

function chkLoginOut()
{
	var url="/webmedia/oemui/customer/logoutlive.asp";
	
	xmlhttp.open("GET",url,true);
	xmlhttp.onreadystatechange=function(){
	
		if(xmlhttp.readystate==4)
		{
			var str=xmlhttp.responseText;
			if(str=='ok')
				top.location.href="/webmedia/login.asp";
		}

	};
	xmlhttp.send(null);
}
		
	
	function user_chk_back(){
		
			if(xmlhttp.readystate==4){
				// && xmlhttp.status==200
			var str=xmlhttp.responseText;
				if(str.indexOf("yes")>-1){
					//window.location.reload();
					top.location.href='/webmedia/html/index.html';
				}else{
					alert(str);	
				}
				
			}
		}
		
		
		//添加用户评论
		
		function comment_into(f){
			var title=f.title.value;
			var content=f.content.value;
			var p=f.Program_ID.value;
			
			if(title.length==0){
				alert('评论主题不能空！');
				f.title.focus();
			}else if(content.length==0){
				alert('评论内容不能空！');
				f.content.focus();	
			}else{
				
				var url="../customer/comment_into.asp?p="+p+"&t="+title+"&c="+content+"&rnd="+Math.random();
				xmlhttp.open("GET",url,true);
				xmlhttp.onreadystatechange=comment_into_back;
				xmlhttp.send(null);
				
				}
			//alert(MD5.Encode(username));
			return false;
			}
			
		function comment_into_back(){
			if(xmlhttp.readystate==4){
				var str=xmlhttp.responseText;
				if(str.indexOf("评论成功")>-1){
					alert(str);	
					var p_id=document.all.Program_ID.value;
					if(p_id.length==0){
					window.location.reload();
					}else{
					window.location.href='remark.asp?id='+document.all.Program_ID.value;	
					}
					
					document.form_comment.title.value='';
					document.form_comment.content.value='';
					comment_show();
					
				}else if(str.indexOf("登录")>-1){
					alert(str);	
					comment_show();
					document.frames['users'].document.form_login.username.select();
					document.frames['users'].document.form_login.username.style.border='#9ECC00 1px solid';
					}else{
					alert(str);	
						}
			}
		}
		
		//关闭评论层
		function comment_show(){
			
			if($("comment_bg").style.display=='none' || $("comment_bg").style.display==''){
				$("comment_bg").style.display='block';
				$("comment").style.display='block';
				document.form_comment.title.focus();
			}else{
				$("comment_bg").style.display='none';
				$("comment").style.display='none';
				}
		}
		
		
		//加载评论内容
		function remark_show(id){
			var remarks=$("remarks_"+id);
			var url="../customer/comment_show.asp?id="+id+"&rnd="+Math.random();
			xmlhttp.open("GET",url,true);
			xmlhttp.onreadystatechange=function(){
					if(xmlhttp.readystate==4){
						var str=xmlhttp.responseText;
						remarks.innerHTML=str+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[<a href=javascript:remark_close("+id+");>收起本栏</a>]";
						remarks.className='remark_show';
						
					}
				}
			xmlhttp.send(null);
			}
			
		function remark_close(id){
			var remarks=$("remarks_"+id);
			remarks.innerHTML=remarks.innerHTML.substring(1,100)+"... [<a href=javascript:remark_show("+id+");>查看详情</a>]";
			remarks.className='remarks';
			//remarks.style.display='none';
			}
			
			
			
		//直播频道
		
		function liveclass(id){
			var url="liveclass.asp?id="+id+"&rnd="+Math.random();
			xmlhttp.open("GET",url,true);
			xmlhttp.onreadystatechange=function(){
					if(xmlhttp.readystate==4){
						var str=xmlhttp.responseText;
						
						if (str.length !=0){
							$("liveclass_"+id).innerHTML=str+"&nbsp;";
						}
						liveplaylist(id);
					}
				}
			xmlhttp.send(null);
			
			
		}
		
		function liveplaylist(id){
			var url="livelist.asp?id="+id+"&rnd="+Math.random();
			xmlhttp.open("GET",url,true);
			xmlhttp.onreadystatechange=function(){
					if(xmlhttp.readystate==4){
						var str=xmlhttp.responseText;
						
							if (str.length !=0){
							$("livelist").innerHTML=str;
						}
					}
				}
			xmlhttp.send(null);

		}
		
		
		
		
		
		