function getCookie(Name) {
var search = Name + "=";
document.cookie.Domain="cccv.cn";
if(document.cookie.length > 0) {
var offset = document.cookie.indexOf(search);
if(offset != -1) {
offset += search.length;
var end = document.cookie.indexOf(";", offset);
if(end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(offset, end));
}else{return "";}}else{return "";}}

var show = new Object();
show.Version="2.0";
show.isOpen=false;
show.select="";
show.sTitle='';show.sTip='';show.sLeft='';show.sContent='';show.sBottom='';show.sWidth='';show.sClose=true;

show.lx=0, show.ly=0, show.canDrg=false, show.thiso=null, show.x, show.y;

show.close=function (){
	window.document.getElementById('InputBg').style.display='none';
	try{
		if( show.select != '' ){
			var list = show.select.split(",");
			for( var no=0; no<list.length; no++ ){
				window.document.getElementById(list[no]).style.display = '';
				if(no>100){ return }
			}
		}
	}catch(e){}

	show.isOpen = false;
}

show.open=function (){
	try{
		if( show.select != '' ){
			var list = show.select.split(",");
			for( var no=0; no<list.length; no++ ){
				window.document.getElementById(list[no]).style.display = "none";
				if(no>100){ return }
			}
		}
	}catch(e){}
	window.document.getElementById('InputBg').style.display='';
	show.isOpen = true;
	show.move();
}

show.move=function (){
	if(show.isOpen){
	window.document.getElementById('InputBg').style.top = (document.body.scrollTop+(document.body.clientHeight-document.getElementById("InputBg").offsetHeight)/2)+"px";
	window.document.getElementById('InputBg').style.left = (document.body.scrollLeft+(document.body.clientWidth-document.getElementById("InputBg").offsetWidth)/2)+"px";
	}
}

show.inner=function (name,values){
	if( values==''|values==null ){
		window.document.getElementById(name).style.display='none';
	}else{
		window.document.getElementById(name).style.display='';
		window.document.getElementById(name).innerHTML=values;
	}
}

show.tip=function (titles,tips,lefts,contents,bottoms,width,isclose,ishold){
	if(ishold==null|ishold){ show.sTitle=titles; show.sTip=tips; show.sLeft=lefts; show.sContent=contents; show.sBottom=bottoms; show.sWidth=width; show.sClose=isclose; }

	window.document.getElementById('InputBg').style.width=width;

	show.inner ( 'InputTitle', titles );
	show.inner ( 'InputTips', tips );
	show.inner ( 'InputBottom', bottoms );
	show.inner ( 'InputLeft', lefts );
	show.inner ( 'InputContent', contents );

	if(isclose){
		window.document.getElementById("InputClose").style.display='none';
	}else{
		window.document.getElementById("InputClose").style.display='';
	}
	show.open();
}

show.renew=function (){ show.tip(show.sTitle, show.sTip, show.sLeft, show.sContent, show.sBottom, show.sWidth, show.sClose, false); }

show.hidden=function (obj,mode){
	if(mode==null){
		if(window.document.getElementById(obj).style.display==''){
			window.document.getElementById(obj).style.display = 'none'
		}else{
			window.document.getElementById(obj).style.display = ''
		}
	}else if(mode==1){
		window.document.getElementById(obj).style.display = ''
	}else if(mode==0){
		window.document.getElementById(obj).style.display = 'none'
	}
}

// 加载提示
show.loading=function (str){
	if(str==null){ str='正在处理，请稍候' }
	show.tip( '','','','<div style="padding: 15px 10px;"><img src="http://www.cccv.cn/images/loading.gif" align="absmiddle"> '+ str +'.....</div>','','350px', true, false );
}

show.dargit=function (o,e){
	show.thiso = o;
	show.canDrg = true;
	if(!document.all){
		show.lx = e.clientX; show.ly = e.clientY;
	}else{
		show.lx = event.x; show.ly = event.y;
	}
	if(document.all) show.thiso.setCapture();
	show.st(o);
}

show.st=function(o){
	var p = o.parentNode;
	if(p.lastChild != o){
		p.appendChild(o);
	}
}



var login = new Object();
login.states=0; login.uid=''; login.name=''; login.cat=0; login.vip=0; login.outplace='login_tip'; login.mode=0;
login.input=function (tips, okjs, nojs){
	var userid = getCookie("userid");
	if( tips==null ){ tips='' }
	if( userid==null ){ userid='' }
	if( okjs==null ){ okjs='' }
	if( nojs==null ){ nojs='' }

	var bottoms = '<A HREF="http://www.cccv.cn/member/" target="_blank" style="color:red">还不是会员，免费注册&gt;&gt;</A>';
	var contents = '<form name="loginform" method="POST" onSubmit="return login.inputcheck(this)" action="http://www.cccv.cn/member/login/www3_input.asp" target="iframe_top"><input type="hidden" name="status" value="Checkem"><input type="hidden" name="okjs" value="'+ okjs +'"><input type="hidden" name="nojs" value="'+ nojs +'"><div style="padding: 6px;">用户名 <input type="text" name="userid" size="20" maxlength="20" onFocus="this.select();" style="border: #4a3163 1px solid; font-size:12px; ime-mode: disabled;" tabindex="1" value="'+ userid +'"> <a href="http://www.cccv.cn/member/user/forget/forgetid1.asp" tabindex="0" target="_blank">忘记用户名</a></div> <div style="padding: 6px;">密　码 <input type="password" name="password" size="20" maxlength="50" onFocus="this.select();" style="border: #4a3163 1px solid; font-size:12px; ime-mode: disabled;" tabindex="2"> <a href="http://www.cccv.cn/member/user/forget/forgetpsd1.asp" tabindex="0" target="_blank">忘记密码</a></div><div style="padding: 6px; text-align:center;"><input type="submit" value=" 登录 "tabindex="3"></div></form>';

	show.tip( '会员登录', tips, '', contents, bottoms, '300px', false, false );
}

login.inputcheck=function (theform){
	var uidstr=theform.userid.value.toLowerCase();

	if(uidstr==""){alert("用户名 不能为空!"); return (false);}
	if( uidstr.length<3 ){ alert("用户名必须大于或等于3个字符！"); return (false);}
	if( uidstr.length>18 ){ alert("用户名必须小于18个字符！"); return (false);}

	var compStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_.";
	for(var i=0;i<uidstr.length;i++){
		if(compStr.indexOf(uidstr.charAt(i))==-1){
			alert("请输入正确的用户名，用户名只能为半角的数字或英文字符！"); return false;
		}
	}

	if(theform.password.value==""){alert("密码 不能为空!"); return (false);}

	show.inner( 'InputTips', '<img src="http://www.cccv.cn/images/loading.gif" align="absmiddle"> 正在登录，请稍候.....' );
	return (true);
}

// 需要登录才能访问的网页前的检测
login.tourl=function (url,str,target){
	login.output();
	if(login.uid==''|login.name==''){
		if(str==null|str==''){str='登录超时或没有登录，需要登录才能操作。'}
		login.input( str, 'window.open(\''+ url +'\',\''+ target +'\');', ''); 
//		login.input( str, 'parent.location.href=\''+ url +'\';', ''); 
	}else{
		if(target==null|target==''){
			location.href=url;
		}else{
			window.open(url,target)
		}
	}
}

// 登录检查
login.check=function(){
	if(navigator.cookieEnabled==true){
		login.uid=getCookie('uid'); login.name=getCookie('name');
		if(login.uid==''|login.name==''){
			return -1;
		}else{
			login.cat=getCookie('cat'); login.vip=getCookie('vip'); login.states=getCookie('states'); login.time=getCookie('time'); return 1;
		}
	}else{
		return -2;
	}
}

// 登录状态显示
login.output=function(mode){
	if(navigator.cookieEnabled==true){
		login.uid=getCookie('uid'); login.name=getCookie('name');
		if(login.uid==''|login.name==''){
			login.loginno(mode);
		}else{
			login.cat=getCookie('cat'); login.vip=getCookie('vip'); login.states=getCookie('states'); login.time=getCookie('time'); login.loginok();
		}
	}else{
		login.nocookie();
	}
}
login.nocookie=function(){
	window.document.getElementById(login.outplace).innerHTML='对不起，您的浏览器不支持Cookie';
}
login.loginok=function(){
	window.document.getElementById(login.outplace).innerHTML=' 欢迎您！ <A HREF="http://wr.cccv.cn/'+login.uid+'" class="logintext" target="_blank">'+login.name+'</a> | <A HREF="http://www.cccv.cn/member/myhelper/" class="logintext" target="_blank">进入我的助手</A> | <A HREF="http://www.cccv.cn/member/login/www3_exit.asp" target="iframe_top" class="logintext" title="'+login.uid+' | '+login.name+'">退出</A> ';
}

login.loginno=function(){
	if(login.mode==1){
		window.document.getElementById(login.outplace).innerHTML='<img src="http://www.cccv.cn/images/btn_login.gif" height="20" border="0" hspace="6" align="absmiddle" onClick="login.input()" style="cursor:pointer">';
	}else if (login.mode==2){
		var userid = getCookie("userid");
		if( userid==null ){ userid='' }
		window.document.getElementById(login.outplace).innerHTML='<table border="0" cellpadding="0" cellspacing="0" id="login_no"><form name="form_login" method="post" onSubmit="return login.inputcheck(this)" action="http://www.cccv.cn/member/login/www3_input.asp" target="iframe_top"><input type="hidden" name="status" value="Checkem"><input type="hidden" name="okjs" value="alert(\'登录成功\')"><input type="hidden" name="mode" value="1"><tr><td class="logintext"><nobr>登录名 <input type="text" name="userid" size="14" maxlength="18" onFocus="this.select()" style="border: #4a3163 1px solid; font-size:12px; ime-mode: disabled;" value="'+ userid +'"> 密码 <input type="password" name="password" size="14" maxlength="18" onFocus="this.select();" style="border: #4a3163 1px solid; font-size:12px; ime-mode: disabled;"></nobr></td><td style="padding:1px 0px 0px 6px;"><input type="submit" value="登录" style="border: #666666 1px solid; padding-top:2px; width:36px; height:20px;"></td></tr></form></table>';
	}else{
		window.document.getElementById(login.outplace).innerHTML=' <a href="javascript:void(0)" onclick="login.input()" class="logintext">登录</a> | <a href="http://www.cccv.cn/member/" target="_blank" class="logintext">免费注册</a> ';
	}
}


document.onmousemove = function(e){
	if(!document.all){ show.x = e.clientX; show.y = e.clientY; }else{ show.x = event.x; show.y = event.y; }
	if(show.canDrg){
		var ofsx = show.x - show.lx;
		show.thiso.style.left = parseInt(show.thiso.style.left) + ofsx;
		show.lx = show.x;
		var ofsy = show.y - show.ly;
		show.thiso.style.top = parseInt(show.thiso.style.top) + ofsy;
		show.ly = show.y;
	}
}

document.onmouseup=function(){
	show.canDrg=false;
	if(document.all && show.thiso != null){
		show.thiso.releaseCapture();
		show.thiso = null;
	}
}


