/* www共用JS4.1 */

function toConsole(data){var txt=document.createTextNode(data);GE('console2').appendChild(txt);}

function GE(a){return document.getElementById(a);}

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 "";}}

function setCookie(name,value,time) {if(time==0){document.cookie=name+"="+escape(value)+";domain=.cccv.cn;path=/;";}else{var today=new Date();var expires=new Date();expires.setTime(today.getTime()+60000*time);document.cookie = name + "=" + escape(value) +"; domain=.cccv.cn; path=/; expires="+ expires.toGMTString();}}

function cCookie(name){document.cookie=name+'=;domain=.cccv.cn;path=/;'}

function tip(name,val,num){GE(name).style.display='';GE(name).innerHTML=val; if(num>9){setTimeout('GE("'+name+'").style.display="none"',num)}}

function getXMLHTTPRequest(){var xRequest=null;if(window.XMLHttpRequest){xRequest=new XMLHttpRequest();}else if(typeof ActiveXObject != "undefined"){xRequest=new ActiveXObject("Microsoft.XMLHTTP");}return xRequest;}

function loadRequest(url,parames,method,tiptitle,tipobj,tipbegin,tipok,tiperr,isshow){
	if(tipobj==''){tipobj='console'}
	if(tipbegin==null){tipbegin='no'}
	if(tipok==null){tipok='no'}
	if(tiperr==null){tiperr='no'}
	if(tipbegin==''){tipbegin='正在'+ tiptitle +'...'}
	if(tipok==''){tipok=tiptitle +'完成'}
	if(tiperr==''){tiperr=tiptitle +'错误，操作中止'}

	if(tipbegin!='no'){ tip(tipobj,tipbegin,0) }
	var XR=getXMLHTTPRequest();
	if(XR){
		XR.onreadystatechange=function(){
			if(XR.readyState==4){
				if(XR.status==200){
					eval(XR.responseText);
					if(tipok!='no'){ tip(tipobj,tipok,4000) }
				}else if(XR.status==404){
					if(tiperr!='no'){ tip(tipobj,'没有找到网页',0) }
				}else{
					if(tiperr!='no'){ tip(tipobj,tiperr,0) }
				}
				if(isshow){try{toConsole('<hr>Status:'+XR.statusText+' CODE:'+XR.responseText)}catch(e){}}
			}
		}
		if(method==null){method='POST'}
		if(parames==null){parames=''}
		XR.open(method,url,true);
		XR.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		XR.send(parames)
	}else{
		if(tipobj!=null){ tip(tipobj,'浏览器不支持',0) }
	}
}

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='100';show.sClose=true;show.MX=0;show.MY=0;show.sec=0;show.Interval;show.Timeout;


show.lx=0, show.ly=0, show.canDrg=false, show.thiso=null, show.x, show.y;

show.close=function (){
	GE('InputBg').style.display='none';
	try{
		if( show.select != '' ){
			var list = show.select.split(",");
			for( var no=0; no<list.length; no++ ){
				GE(list[no]).style.display = '';
				if(no>100){ return }
			}
		}
	}catch(e){}

	show.isOpen = false;
	clearTimeout(show.Interval);
	clearTimeout(show.Timeout);
}


show.autoclose=function (num){ clearTimeout(show.Timeout); show.Timeout = setTimeout ( 'show.close()', num ); show.sec=num; clearTimeout(show.Interval); show.Interval = setInterval ( 'show.closetip()', 1000 ); }

show.closetip=function (){var a;if(show.sec>0){show.sec=show.sec-1000; a=show.sec/1000; GE('InputTitle').innerHTML=show.sTitle +'('+a+'秒后关闭)';}else{clearTimeout(show.Interval);}}

show.open=function (){
	try{
		if( show.select != '' ){
			var list = show.select.split(",");
			for( var no=0; no<list.length; no++ ){
				GE(list[no]).style.display = "none";
				if(no>100){ return }
			}
		}
	}catch(e){}
	GE('InputBg').style.display='';
	show.isOpen = true;
	show.move();
	clearTimeout(show.Interval);
	clearTimeout(show.Timeout);
}

show.move=function (){
	if(show.isOpen){
		if(show.MY==0){
			var docTop = document.documentElement.scrollTop||document.body.scrollTop;
			var docHeight = document.documentElement.clientHeight||document.body.clientHeight;
			GE('InputBg').style.top=(docTop+(docHeight-GE("InputBg").offsetHeight)/2)+"px";
		}else{
			GE('InputBg').style.top=show.MY;
		}
		if(show.MX==0){
			var docLeft = document.documentElement.scrollLeft||document.body.scrollLeft;
			var docWidth = document.documentElement.clientWidth||document.body.clientWidth;
			GE('InputBg').style.left=(docLeft+(docWidth-GE("InputBg").offsetWidth)/2)+"px";
		}else{
			GE('InputBg').style.left=show.MX;
		}
	}
}

show.snap=function(obj,position,MovePx){
	if(MovePx==null){MovePx=0}
	var objLeft = obj.offsetLeft;
	var objTop = obj.offsetTop;
	var objParent = obj.offsetParent;
	while (objParent.tagName != "BODY") {
		objLeft += objParent.offsetLeft;
		objTop += objParent.offsetTop;
		objParent = objParent.offsetParent;
	}
	if(position=='bl'){objTop+=obj.offsetHeight+2;}
	else if(position=='br'){objTop+=obj.offsetHeight+2;objLeft-=(MovePx-obj.clientWidth);}
	else if(position=='bc'){objTop+=obj.offsetHeight+2;objLeft-=(MovePx-obj.clientWidth)/2;}
	else if(position=='lb'){objLeft-=(MovePx+2);}
	else if(position=='rb'){objLeft+=(obj.clientWidth+2);}

	if(objLeft<1){objLeft=1;objTop+=obj.offsetHeight+2;}
	if(objTop<1){objTop=1;objLeft+=(obj.clientWidth+2);}

	show.MX=objLeft+'px'; show.MY=objTop+'px';
}


show.inner=function (name,values){
	if( values==''|values==null ){
		GE(name).style.display='none';
	}else{
		GE(name).style.display='';
		GE(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; }

	GE('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){
		GE("InputClose").style.display='none';
	}else{
		GE("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(GE(obj).style.display==''){
			GE(obj).style.display = 'none'
		}else{
			GE(obj).style.display = ''
		}
	}else if(mode==1){
		GE(obj).style.display = ''
	}else if(mode==0){
		GE(obj).style.display = 'none'
	}
}

// 加载提示
show.loading=function (str){
	if(str==null){ str='正在处理，请稍候' }
	show.tip( '','','','<div style="padding:15px 10px;"><img src="http://img.cccv.cn/h/loading.gif" width="16" height="16" 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.iuid=''; login.ipsd=''; login.mode=0; login.dojs=''; login.okjs=''; login.nojs=''; login.exitjs=''; login.alert=0;

login.disabled=function(val){if(document.forms.length==0){return}for(var i=0;i<document.forms.length;i++){if(document.forms[i].name.substring(0,5)=='login'){document.forms[i].submit.disabled=val;}}}

login.input=function (tips, okjs, nojs, userid){
	if( tips==null ){ tips='' }
	if( okjs==null|okjs=='' ){ okjs=login.dojs }
	if( nojs==null|nojs=='' ){ nojs=login.dojs }

	login.okjs=okjs; login.nojs=nojs;

	if(userid==null){ userid = getCookie("userid") }
	if(userid==null){ userid='' }
	login.iuid=userid;

	var bottoms = '<A HREF="http://www.cccv.cn/member/" target="_blank" style="color:red">还不是会员，免费注册&gt;&gt;</A>';
	var contents = '<form name="loginform1" style="margin:0" onSubmit="return login.inputcheck(this);"><input type="hidden" name="tipobj" value="InputTips"><div align="left" style="padding:10px 10px 6px 10px;">用户名 <input type="text" name="uid" size="20" maxlength="20" onFocus="this.select();" style="border: #4a3163 1px solid;font-size:12px;ime-mode:disabled;" value="'+ userid +'"> <a href="http://www.cccv.cn/member/user/forget/forgetid1.asp" target="_blank" tabindex="0">忘记用户名</a></div> <div align="left" style="padding:3px 10px 6px 10px;">密　码 <input type="password" name="psd" size="20" maxlength="50" onFocus="this.select();" style="border: #4a3163 1px solid; font-size:12px;ime-mode:disabled;"> <a href="http://www.cccv.cn/member/user/forget/forgetpsd1.asp" target="_blank" tabindex="0">忘记密码</a></div><div style="padding:15px;text-align:center;"><input type="submit" value=" 登录 " name="submit"></div></form>';

	show.tip( '会员登录', tips, '', contents, bottoms, '300px', false, false );
}

login.inputcheck=function(theform){
	var uid=theform.uid.value;
	var psd=theform.psd.value;
	var tipobj=theform.tipobj.value;

	if(uid==""){alert("用户名 不能为空!");return false;}
	if(uid.length<3){alert("用户名必须大于或等于3个字符！");return false;}
	if(uid.length>18){alert("用户名必须小于18个字符！");return false;}

	uid=uid.toLowerCase();

	var compStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_.";
	for(var i=0;i<uid.length;i++){
		if(compStr.indexOf(uid.charAt(i))==-1){
			alert("请输入正确的用户名，用户名只能为半角的数字或英文字符！"); return false;
		}
	}

	if(psd==""){alert("密码 不能为空!"); return false;}

	if(tipobj==''){tipobj=login.outplace;var mode=2,alert2=login.alert;}else{var mode=1,alert2=0;}

	login.disabled(true);

	var url='/common/logincheck4.4.asp';

	var parames='status=Checkem&userid='+ uid +'&password='+ psd +'&alert='+ alert2 +'&mode='+ mode +'&okjs='+ login.okjs +'&nojs='+login.nojs +'&tipobj='+tipobj;

	var tipbegin='<img src="http://img.cccv.cn/h/loading.gif" width="16" height="16" align="absmiddle"> 正在登录，请稍候...';

	loadRequest(url,parames,'POST','登录',tipobj,tipbegin,'no','',true)
	return false;
}


login.exit=function(tipobj){
	if(tipobj==null){tipobj=login.outplace}
	var url='/common/loginexit4.0.asp';
	var parames= 'alert='+ login.alert +'&mode='+ login.mode +'&exitjs='+ login.exitjs;
	loadRequest(url,parames,'POST','退出',null,'no','no','no',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(){
	if(navigator.cookieEnabled==true){
		login.uid=getCookie('uid'); login.name=getCookie('name');
		if(login.uid==''|login.name==''){
			login.loginno();
		}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(){
	GE(login.outplace).innerHTML='对不起，您的浏览器不支持Cookie';
}
login.loginok=function(){
	GE(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="javascript:void(0)" class="logintext" onClick="login.exit()" title="'+login.uid+' | '+login.name+'">退出</A> ';
}


login.loginno=function(){
	if(login.mode==1){
		GE(login.outplace).innerHTML='<img src="http://img.cccv.cn/h/btn_login.gif" height="20" border="0" hspace="6" align="absmiddle" onClick="show.snap(this,\'br\',300);login.input();" style="cursor:pointer">';
	}else if (login.mode==2){
		login.iuid = getCookie("userid");
		if( login.iuid==null ){login.iuid=''}
		login.ipsd='';
		GE(login.outplace).innerHTML='<form name="loginform2" style="margin:0" onSubmit="return login.inputcheck(this);"><input type="hidden" name="tipobj" value=""><table border="0" cellpadding="0" cellspacing="0" id="login_no"><tr><td class="logintext"><nobr>登录名 <input type="text" name="uid" size="14" maxlength="18" onFocus="this.select()" style="border: #4a3163 1px solid; font-size:12px; ime-mode: disabled;" value="'+ login.iuid +'"> 密码 <input type="password" name="psd" 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" name="submit" value="登录" style="border: #666666 1px solid; padding-top:2px; width:36px; height:20px;"></td></tr></table></form>';
	}else{
		GE(login.outplace).innerHTML=' <a href="javascript:void(0)" onclick="show.snap(this,\'br\',300);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 +'px';
		show.lx = show.x;
		var ofsy = show.y - show.ly;
		show.thiso.style.top = parseInt(show.thiso.style.top) + ofsy +'px';
		show.ly = show.y;
	}
}

document.onmouseup=function(){
	show.canDrg=false;
	if(document.all && show.thiso != null){
		show.thiso.releaseCapture();
		show.thiso = null;
	}
}


function fadeout(obj,speed) {if(speed==null){speed=50}try{if(GE(obj).filters.Alpha.Opacity<10){GE(obj).style.display='none';}else{GE(obj).filters.Alpha.Opacity-=10;setTimeout("fadeout('"+obj+"')",speed);}return;}catch(e){}try{if(GE(obj).style.opacity==''){GE(obj).style.opacity=1}if(GE(obj).style.opacity<0.1){GE(obj).style.display='none';}else{GE(obj).style.opacity-=0.1;setTimeout("fadeout('"+obj+"')",speed);}return}catch(e){}GE(obj).style.display='none';}

