function getCookie(str){
 var tmp,reg=new RegExp("(^| )"+str+"=([^;]*)(;|$)","gi");
 if(tmp=reg.exec(document.cookie)){
   return(unescape(tmp[2]));
 }
 return null;
 }
function ClearCookie(name) { 
var ThreeDays=3*24*60*60*1000; 
var expDate = new Date(); 
expDate.setTime(expDate.getTime()-ThreeDays); 
document.cookie=name+"=;domain=.china.com;path=/;expires="+expDate.toGMTString(); 
}

function createCookie(name,value,days)
{
    if (days)
    {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; domain=.china.com; path=/";
}

function login_check(form)
{
  if (!textCheck(form.username, "用户名")){
      return;
  }
  if (!pwdCheck(form.password, "密码", 1))
      return;
  form.submit();
}
function register() {
     window.parent.location.href="http://passport.china.com/logon.do?processID=register1&domain=http://tuku.club.china.com";
}
function modify() {
    window.parent.location.href="http://passport.china.com/logon.do?processID=password&option=usermodify&domain=http://tuku.club.china.com";
}
function modifyPassword(){
    window.parent.location.href="http://passport.china.com/logon.do?processID=updatePassword";
   
}
function gotovalidate(){
    window.parent.location.href="http://passport.china.com";
}
function exitok(form){
if(confirm("确认退出？")){
  form.submit();
}
}


var userid=getCookie("CP_USER");

var nickname=getCookie("nickname");
function showLogin(){
    document.write('<form method="post" name="logon" action="http://rtuku.club.china.com/user/logon.do" onsubmit="return false;">');
	document.write('<div class="user01">');
	document.write('登录名：');
    document.write('<input class="input01" type="text" name="username" onkeypress="Next(this)" title="请输入通行证用户名或昵称" />&nbsp;');
	document.write('密码：');
	document.write('<input type="password" onkeypress="Next(this)" name="password" class="input01"/>&nbsp;');
	document.write('<input type="button" onclick="login_check(logon);" class="input02" value="登陆" />&nbsp;');
	document.write('<input type="button" onclick="register();" class="input02" value="注册" />&nbsp;</div>');
    document.write('</form>');
}

function showLogout(){
	document.write('<form method="post" name="logon" action="http://rtuku.club.china.com/user/logoff.do" onsubmit="return false;">');
	document.write('<div class="user01"><font color="green">' + nickname + '</font>用户：欢迎登录中华网图库&nbsp;');
	document.write('<input type="button" class="input_out" value="退出登陆" onclick="exitok(logon);" />&nbsp;');
	document.write('<input type="button" class="input_back" value="中华网通行证" onclick="gotovalidate();" />&nbsp;</div>');
    document.write('</form>');
}

if(userid==null){
    showLogin();
}else{
    showLogout();
}
