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('<div class="loginPart">');
    document.write('<form method="post" name="GenPageForm" action="http://rtuku.club.china.com/user/logon.do" onsubmit="return false;">');
	document.write('<input type="hidden" name="refurl" value="'+document.location.href+'"/>');
	document.write('<label for="textfield">登录名：</label>');
    document.write('<input class="input70" id="textfield" type="text" name="username" onkeypress="Next(this)" title="请输入通行证用户名或昵称" />');
	document.write('<label for="label">密码：</label>');
	document.write('<input class="input70"  id="label" type="password" name="password" onkeypress="Next(this)"/>');
	document.write('<button class="btn_submit" type="button" onclick="login_check(GenPageForm);">登录</button>');
	document.write('<button class="btn_reg" onclick="register();">注册</button>');
    document.write('</form>');
    document.write('</div>');
}

function showLogout(){
    document.write('<div class="welcomePart">');
	document.write('<form method="post" name="GenPageForm" action="http://rtuku.club.china.com/user/logoff.do" onsubmit="return false;">');
	document.write('<span>' + nickname + '</span>用户：欢迎登录中华网图库');
	document.write('<button class="btn_exitok" type="button" onclick="exitok(GenPageForm);">退出登录</button>');
    document.write('<button class="btn_modify" onclick="modify();">修改个人资料</button>');
	document.write('<button class="btn_modifyPassword" onclick="modifyPassword();">修改密码</button>');
    document.write('<button class="btn_gotovalidate" onclick="gotovalidate();">返回通行证</button>');
    document.write('</form>');
	document.write('</div>');
}

if(userid==null){
    showLogin();
}else{
    showLogout();
}
