﻿var ImgFolder = "http://www.qc101.com/images/topfooter";
var LinkSrc = "http://www.qc101.com";
document.writeln("<style>");
document.writeln("#PT{width:100%; font-size:12px; font-weight:100; color:#333333; height:37px; background:url(" + ImgFolder + "/PT_Img.gif) repeat-x bottom #FFFFFF;}");
document.writeln("#PT dl, #PT dt, #PT dd{padding:0px; margin:0px; }");
document.writeln("#PT table, #PT tr, #PT td{ border:0px;}");
document.writeln(".PT_Center{width:1000px; margin:auto;}");
document.writeln(".PT_Logo{width:140px; height:37px; float:left;}");
document.writeln(".PT_Start{ height:30px; float:left; width:120px; background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -188px 7px; padding-top:7px; padding-left:15px;}");
document.writeln(".PT_Start a, .PT_Start a:visited{ width:100px; height:24px; font-size:14px; position:static; display:inline-block; text-align:center;color:#FF0000; font-weight:bold; background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -80px -24px; line-height:24px; text-decoration:none;}");
document.writeln(".PT_Start a:hover{ background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -80px -48px;}");
document.writeln(".PT_Notice{ width:330px; height:37px; float:left; background:url(" + ImgFolder + "/PT_Notice_Icon.gif) no-repeat 0% 50%;}");
document.writeln(".PT_Notice_List{ width:300px; height:21px; overflow:hidden; margin-top:10px; margin-left:20px;}");
document.writeln(".PT_Notice_List ul{ padding:0px; margin:0px; list-style:none;}");
document.writeln(".PT_Notice_List li{height:20px; font-family:'宋体'; line-height:20px; overflow:hidden;}");
document.writeln(".PT_Notice_List a{ color:#4B4B4B; position:static; text-decoration:underline;}");

document.writeln(".PT_Nav{width:395px; height:30px; float:left; padding-top:6px;}");
document.writeln(".PT_Nav_Login{width:142px; float:left;}");
document.writeln(".PT_Nav_Other{width:252px; float:left;}");
document.writeln(".PT_Nav ul{padding:0px; margin:0px; list-style:none; height:25px; overflow:hidden;}");
document.writeln(".PT_Nav li{ float:left;}");

document.writeln(".PT_Nav a{ display:inline-block; height:25px; line-height:25px; text-decoration:none; color:#655E57; position:static; overflow:hidden;}");
document.writeln(".PT_Nav span{ display:block; height:25px; line-height:25px; color:#655E57;}");

document.writeln(".PT_Nav_Logind{width:142px; height:25px; overflow:hidden; float:left;}");
document.writeln(".PT_Nav_Logind div{width:212px; height:25px; line-height:15px; overflow:hidden; position:absolute;  margin-left:-70px; text-align:right; color:#C3C3C3;}");
document.writeln(".PT_Nav_Logind a{padding:0px 5px; background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -188px -35px;}");
document.writeln(".PT_Nav_Logind a:hover{color:#FF7E00; text-decoration:underline;}");

/*Box Start*/
document.writeln(".PT_Box{width:242px; position:absolute; z-index:100; margin-top:-3px; margin-left:-6px;}");
document.writeln(".PT_Box_T{background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -77px -98px; height:11px; width:100%; overflow:hidden;}");
document.writeln(".PT_Box_C{background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -77px -108px; width:100%;}");
document.writeln(".PT_Box_B{background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -77px -232px; height:12px; width:100%; overflow:hidden;}");
document.writeln(".PT_Login_Submit{background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -141px -72px; width:61px; height:22px; border:none; cursor:pointer;}");
/*Box End*/

document.writeln(".PT_Msg_Right{width:18px; background:url(" + ImgFolder + "/PT_Img.gif) no-repeat 0px -136px; height:22px; position:absolute;}");

/*Reg Start*/
document.writeln("a.PT_Nav_A1,a.PT_Nav_A1:visited{background:none; position:static; width:84px; display:block;}");
document.writeln("a.PT_Nav_A1:hover{cursor:pointer; text-decoration:none;}");
document.writeln(".PT_Nav_Login li.PT_Nav_Li1 .PT_Reg{ display:none;}");
document.writeln(".PT_Nav_Login li.PT_Nav_Li1:hover{background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -323px 0px;}");
document.writeln(".PT_Nav_Login li.PT_Nav_Li1:hover .PT_Reg{ display:block;}");
document.writeln(".PT_Nav_Login li.PT_Nav_Hover1 {background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -323px 0px;}");
document.writeln(".PT_Nav_Login li.PT_Nav_Hover1 .PT_Reg{ display:block;}");

document.writeln(".PT_Reg{width:300px; position:absolute; z-index:100; margin-top:-3px; margin-left:-6px;}");
document.writeln(".PT_Reg_T{background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -317px -28px; height:11px; width:100%; overflow:hidden;}");
document.writeln(".PT_Reg_C{ background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -317px -38px; width:100%;}");
document.writeln(".PT_Reg_B{background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -317px -281px; width:100%; height:12px; overflow:hidden;}");
document.writeln(".PT_Reg_Submit{background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -407px 0px; width:61px; height:22px; border:none; cursor:pointer;}");

document.writeln(".PT_Reg_Center{width:240px; margin:auto; padding:5px 0px; background-color:#FFFFFF;}");
document.writeln(".PT_Reg_Center dl,dt,dd{margin:0px; padding:0px; list-style:none; text-align:left;}");
document.writeln(".PT_Reg_Center dl{ height:22px; width:100%; padding:5px 0px;}");
document.writeln(".PT_Reg_Center dl.TowRow{ height:42px; width:100%; padding:5px 0px;}");
document.writeln(".PT_Reg_Center dt{width:55px; display:block; float:left; line-height:22px;}");
document.writeln(".PT_Reg_Center dd{width:175px; display:block; float:left;}");
document.writeln(".PT_Reg_Center dd span{ line-height:20px; color:#999999; height:auto;}");
document.writeln(".PT_Reg_Center dd a:hover input{border:1px #ff0000 solid;}");
document.writeln(".PT_Reg_Center dd.PT_Reg_Msg{width:5px; display:block; float:left;}");
document.writeln(".PT_Reg_Center .PT_Reg_ReMsg{ text-align:center; color:#FF0000; line-height:22px;}");
document.writeln("input.PT_Reg_Input_Text{ border:1px #D7D7D7 solid; background-color:#F7F7F7; line-height:20px; height:20px; width:170px;}");
document.writeln("input.PT_Reg_Input_Text:hover{border:1px #878787 solid; background-color:#FFFECF; }");
document.writeln(".PT_Reg_Yzm span{ width:57px; float:left;}");
/*Reg End*/


/*Login Start*/
document.writeln("a.PT_Nav_A2,a.PT_Nav_A2:visited{background:none; width:58px; display:block;}");
document.writeln("a.PT_Nav_A2:hover{cursor:pointer; text-decoration:none;}");
document.writeln(".PT_Nav_Login li.PT_Nav_Li2 .PT_Box{ display:none;}");
document.writeln(".PT_Nav_Login li.PT_Nav_Li2:hover{background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -83px -72px;}");
document.writeln(".PT_Nav_Login li.PT_Nav_Li2:hover .PT_Box{ display:block;}");
document.writeln(".PT_Nav_Login li.PT_Nav_Hover2 {background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -83px -72px;}");
document.writeln(".PT_Nav_Login li.PT_Nav_Hover2 .PT_Box{ display:block;}");

document.writeln(".PT_Login_Load{width:220px; height:128px; background:url(" + ImgFolder + "/PT_Loading.gif) no-repeat center #FFF00F; position:absolute;  -moz-opacity:0.5; opacity: 0.5; filter:alpha(opacity=50);}");

document.writeln(".PT_Login_Center{width:175px; margin:auto; padding:5px 0px; background-color:#FFFFFF;}");
document.writeln(".PT_Login_Center dl,dt,dd{margin:0px; padding:0px; list-style:none; text-align:left;}");
document.writeln(".PT_Login_Center dl{ height:30px; width:100%;}");
document.writeln(".PT_Login_Center dt{width:45px; display:block; float:left; line-height:22px;}");
document.writeln(".PT_Login_Center dd{width:125px; display:block; float:left;}");
document.writeln(".PT_Login_Center dd.PT_Login_Msg{width:5px; display:block; float:left;}");
document.writeln(".PT_Login_Center .PT_Login_ReMsg{ text-align:center; color:#FF0000; line-height:22px;}");
document.writeln("a.PT_Forget_A{line-height:22px; display:inline-block; height:22px; color:#FF0000; width:60px; float:right; text-align:right;}");
document.writeln(".PT_Login_Input_Text{ border:1px #D7D7D7 solid; background-color:#F7F7F7; line-height:20px; height:20px; width:120px;}");
/*Login End*/

document.writeln("a.PT_Nav_A3,a.PT_Nav_A3:visited ,a.PT_Nav_A4,a.PT_Nav_A4:visited ,a.PT_Nav_A5,a.PT_Nav_A5:visited{background:none;}");
document.writeln("a.PT_Nav_A3:hover ,a.PT_Nav_A4:hover ,a.PT_Nav_A5:hover{background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -80px 1px; text-decoration:none; cursor:pointer;}");

document.writeln(".PT_Nav_A1 span{ width:57px; padding-left:27px; background:url(" + ImgFolder + "/PT_Img.gif) no-repeat 5px 5px; }");
document.writeln(".PT_Nav_A2 span{ width:33px; padding-left:25px; background:url(" + ImgFolder + "/PT_Img.gif) no-repeat 5px -17px;}");
document.writeln(".PT_Nav_A3 span{ width:57px; padding-left:27px; background:url(" + ImgFolder + "/PT_Img.gif) no-repeat 5px -37px;}");
document.writeln(".PT_Nav_A4 span{ width:57px; padding-left:27px; background:url(" + ImgFolder + "/PT_Img.gif) no-repeat 5px -60px;}");
document.writeln(".PT_Nav_A5 span{ width:57px; padding-left:27px; background:url(" + ImgFolder + "/PT_Img.gif) no-repeat 5px -83px;}");

document.writeln(".PT_Msg{ position:absolute; z-index:5; margin-top:2px;}");
document.writeln(".PT_Msg_L{width:5px; background:url(" + ImgFolder + "/PT_Img.gif) no-repeat 0px -108px; overflow:hidden; height:21px;}");
document.writeln(".PT_Msg_C{padding:0px 6px; border-top:1px #F7C8A8 solid; border-bottom:1px #F7C8A8 solid; background-color:#FFF4E2; height:21px; color:#FF0000; white-space:nowrap;}");
document.writeln(".PT_Msg_R{width:2px; background:url(" + ImgFolder + "/PT_Img.gif) no-repeat -8px -108px; overflow:hidden; height:21px;}");

document.writeln("a.PT_Blue_A{display:inline; color:#0080C7; text-decoration:underline;}");
document.writeln("</style>");

//注册和登录
sfHover = function() {
	var PT_Li_1 = document.getElementById("PT_Nav_Li1");
	var PT_Li_2 = document.getElementById("PT_Nav_Li2");
	PT_Li_1.onmouseover=function() {
		this.className+=" PT_Nav_Hover1";
		PT_Li_2.className = "PT_Nav_Li2";
	}
	PT_Li_2.onmouseover=function() {
		this.className+=" PT_Nav_Hover2";
		PT_Li_1.className = "PT_Nav_Li1";
	}
	PT_Li_1.onmouseout=function() {
		this.className="PT_Nav_Li1";
	}
	PT_Li_2.onmouseout=function() {
		this.className="PT_Nav_Li2";
	}
}
//新闻滚动
function topJs_marquee(lh,speed,delay,marqueeDiv){
	var t;
	var p=false;
	var o=document.getElementById(marqueeDiv);
	o.innerHTML+=o.innerHTML;
	o.onmouseover=function(){p=true}
	o.onmouseout=function(){p=false}
	o.scrollTop = 0;
	function start(){
		t=setInterval(scrolling,speed);
		if(!p) o.scrollTop += 2;
	}
	function scrolling(){
		if(o.scrollTop%lh!=0){
		o.scrollTop += 2;
		if(o.scrollTop>=o.scrollHeight/2) o.scrollTop = 0;
		}else{
			clearInterval(t);
			setTimeout(start,delay);
		}
	}
	setTimeout(start,delay);
}

var navStr = '';
navStr +="";
navStr +="<!--[if lte IE 6]>";
navStr +="<script language=javascript>";
navStr +="if (window.attachEvent) window.attachEvent('onload', sfHover);";
navStr +="</script>";
navStr +="<![endif]-->";

navStr +="<div id='PT'>";
navStr +="	<div class='PT_Center'>";
navStr +="		<div class='PT_Logo'><a href='http://passport.qc101.com/' target='_blank' title='汉森信息用户通行证'><img src='" + ImgFolder + "/PT_Logo.gif' width='135' height='37' border='0' /></a></div>";
navStr +="		<div class='PT_Start'><a href='" + LinkSrc + "/start.html' target='_blank' title='开始倾城游戏'>开始倾城游戏</a></div>";
navStr +="		<div class='PT_Notice'>";
navStr +="			<div class='PT_Notice_List' id='topJs_marquee'>";
navStr +="				<ul>";
navStr +="					<li><a href='" + LinkSrc + "/news/notice_game/20100622/656.htm' target='_blank'>纪念迈克尔杰克逊</a></li>";
navStr +="					<li><a href='" + LinkSrc + "/news/game_news/20100127/473.htm' target='_blank'>《倾城》——网页游戏次世代领航者</a></li>";
navStr +="					<li><a href='" + LinkSrc + "/news/game_news/20100126/470.htm' target='_blank'>海外拓展迅猛 《倾城》游戏产业年会再获嘉奖</a></li>";
navStr +="					<li><a href='" + LinkSrc + "/news/official_news/20100128/478.htm' target='_blank'>《倾城》新区“天马行空”30日火爆开启</a></li>";
navStr +="				</ul>";
navStr +="			</div>";
navStr +="		</div>";
navStr +="		<div class='PT_Nav'>";
navStr +="			<div class='PT_Nav_Login' style='display:block;'>";
navStr +="				<ul>";
navStr +="					<li id='PT_Nav_Li1' class='PT_Nav_Li1'><a href='#' class='PT_Nav_A1'><span>快速注册</span></a>";
navStr +="						<div class='PT_Reg'>";
navStr +="							<div class='PT_Reg_T'></div>";
navStr +="							<div class='PT_Reg_C'>";
navStr +="								<!--Reg Start-->";
navStr +="								<div class='PT_Reg_Center'>";
navStr +="									<div class='PT_Reg_ReMsg'></div>";
navStr +="									<dl class='TowRow'>";
navStr +="										<dt> 帐　号 </dt>";
navStr +="										<dd>";
navStr +="											<span><input type='text' class='PT_Reg_Input_Text' name='pt_reg_user_name' id='pt_reg_user_name' /></span>";
navStr +="											<span>4-16位英文、数字或下划线</span>";
navStr +="										</dd>";
navStr +="										<dd id='PT_Reg_UNMsg' class='PT_Reg_Msg'></dd>";
navStr +="									</dl>";
navStr +="									<dl class='TowRow'>";
navStr +="										<dt> 密　码 </dt>";
navStr +="										<dd>";
navStr +="											<span><input type='password' class='PT_Reg_Input_Text' name='pt_reg_password' id='pt_reg_password' /></span>";
navStr +="											<span>6－16个字母、数字组成</span>";
navStr +="										</dd>";
navStr +="										<dd id='PT_Reg_UPMsg' class='PT_Reg_Msg'>";
navStr +="										</dd>";
navStr +="									</dl>";
navStr +="									<dl class='TowRow'>";
navStr +="										<dt>重复密码</dt>";
navStr +="										<dd>";
navStr +="											<span><input type='password' class='PT_Reg_Input_Text' name='pt_reg_passconf' id='pt_reg_passconf' /></span>";
navStr +="											<span>请再输入一次密码</span>";
navStr +="										</dd>";
navStr +="										<dd id='PT_Reg_UPCMsg' class='PT_Reg_Msg'>";
navStr +="										</dd>";
navStr +="									</dl>";
navStr +="									<dl class='TowRow'>";
navStr +="										<dt>电子邮箱</dt>";
navStr +="										<dd>";
navStr +="											<span><input type='text' class='PT_Reg_Input_Text' name='pt_reg_email' id='pt_reg_email' /></span>";
navStr +="											<span>注册成功后不能修改</span>";
navStr +="										</dd>";
navStr +="										<dd id='PT_Reg_UEMsg' class='PT_Reg_Msg'></dd>";
navStr +="									</dl>";
/* navStr +="									<dl>";
navStr +="										<dt>验 证 码</dt>";
navStr +="										<dd class='PT_Reg_Yzm'>";
navStr +="											<span><input type='text' class='PT_Reg_Input_Text' name='pt_reg_captcha' id='pt_reg_captcha' style='width:53px;' length='4' /></span>";
navStr +="											<span><img id='pt_reg_imageYa' src='http://passport.qc101.com/index.php/register/get_captcha' align='absmiddle'></span>";
navStr +="											<span><a href='#' id='pt_reg_refr' class='PT_Blue_A'>看不清</a></span>";
navStr +="										</dd>";
navStr +="										<dd id='PT_Reg_UCMsg' class='PT_Reg_Msg'></dd>";
navStr +="									</dl>"; */
navStr +="									<dl>";
navStr +="										<dt>　</dt>";
navStr +="										<dd>";
navStr +="											<input name='pt_reg_agree' type='checkbox' id='pt_reg_agree' value='1' checked='checked' /> 我同意：<a href='" + LinkSrc + "/about/useragreement/' class='PT_Blue_A' target='_blank'>用户注册协议</a>";
navStr +="										</dd>";
navStr +="										<dd id='PT_Reg_UAMsg' class='PT_Reg_Msg'></dd>";
navStr +="									</dl>";
navStr +="									<dl>";
navStr +="										<dt>　</dt>";
navStr +="										<dd><input type='submit' value='' border='0' class='PT_Reg_Submit' id='PT_Reg_Submit' /></dd>";
navStr +="									</dl>";
navStr +="									<div style='clear:both;'></div>";
navStr +="								</div>";
navStr +="								<!--Reg End-->";
navStr +="							</div>";
navStr +="							<div class='PT_Reg_B'></div>";
navStr +="						</div>";
navStr +="					</li>";
navStr +="					<li id='PT_Nav_Li2' class='PT_Nav_Li2'><a href='#' class='PT_Nav_A2'><span>登录</span></a>";
navStr +="						<div class='PT_Box'>";
navStr +="							<div class='PT_Box_T'></div>";
navStr +="							<!--<div class='PT_Login_Load'></div>-->";
navStr +="							<div class='PT_Box_C'>";
navStr +="								<!--Login Start-->";
navStr +="								<div class='PT_Login_Center'>";
navStr +="									<div class='PT_Login_ReMsg'></div>";
navStr +="									<dl>";
navStr +="										<dt>用户名</dt>";
navStr +="										<dd><input name='user_name' type='text' class='PT_Login_Input_Text' id='pt_user_name' /></dd>";
navStr +="										<dd id='PT_Login_UNMsg' class='PT_Login_Msg'></dd>";
navStr +="									</dl>";
navStr +="									<dl>";
navStr +="										<dt>密　码</dt>";
navStr +="										<dd><input name='password' type='password' class='PT_Login_Input_Text' id='pt_password' /></dd>";
navStr +="										<dd id='PT_Login_UPMsg' class='PT_Login_Msg'>";
navStr +="										</dd>";
navStr +="									</dl>";
navStr +="									<dl>";
navStr +="										<dt>　</dt>";
navStr +="										<dd><a href='http://passport.qc101.com/recpasswd' target='_blank' class='PT_Forget_A'>忘记密码?</a><span><input type='submit' value='' class='PT_Login_Submit' id='PT_Login_Submit' border='0' /></span></dd>";
navStr +="									</dl>";
navStr +="								</div>";
navStr +="								<!--Login End-->";
navStr +="							</div>";
navStr +="							<div class='PT_Box_B'></div>";
navStr +="						</div>";
navStr +="					</li>";
navStr +="				</ul>";
navStr +="			</div>";
navStr +="			<div class='PT_Nav_Logind' style='display:none'>";
//navStr +="				<div><a href='#' class='' id='PT_login_user'>EIver</a> <a href='http://passport.qc101.com/member'  target='_blank'>用户中心</a> <a href='#' id='header_logout'>退出</a></div>";
navStr +="			</div>";
navStr +="			<div class='PT_Nav_Other'>";
navStr +="				<ul>";
navStr +="					<li><a href='http://pay.qc101.com' target='_blank' class='PT_Nav_A3'><span>游戏充值</span></a></li>";
navStr +="					<li><a href='" + LinkSrc + "/guide/' target='_blank' class='PT_Nav_A4'><span>新手帮助</span></a></li>";
navStr +="					<li><a href='http://bbs.qc101.com' target='_blank' class='PT_Nav_A5'><span>玩家论坛</span></a></li>";
navStr +="				</ul>";
navStr +="			</div>";
navStr +="		</div>";
navStr +="	</div>";
navStr +="</div>";
document.write(navStr);
topJs_marquee(20,20,1000,'topJs_marquee');


document.domain = 'qc101.com';
var isload = false;
var isregload = false;
$(document).ready(function() {
	if ($.cookie('qc101_user_name') != null) {
		login_header_succeed(2, $.cookie('qc101_user_name') + ';' + $.cookie('qc101_login_last_time'));
	}
	
	var ifr = $('<iframe src="http://passport.qc101.com/login/ajax_way" height="0" width="0" frameborder="0" scrolling="no" id="cross_domain"></iframe>');
	ifr.load(function () {
		isload = true;
	});
	ifr.appendTo("body");
	
	
	var regifr = $('<iframe src="http://passport.qc101.com/register/ajax_way" height="0" width="0" frameborder="0" scrolling="no" id="cross_domain_reg"></iframe>');
	regifr.load(function () {
		isregload = true;
	});
	regifr.appendTo("body");
	
	var formvalid = {
			user_name: false,
			password: false
		}; 
	var error_template = '<table class="PT_Msg" cellpadding="0" cellspacing="0"><tr><td class="PT_Msg_L">  </td><td class="PT_Msg_C">msg</td><td class="PT_Msg_R">  </td></tr></table>';
	var ok_template = '<div class="PT_Msg_Right"></div>';
	
	$("#pt_user_name").blur(function() {
		if ( /^[0-9a-zA-Z_]{4,16}$/.test( $("#pt_user_name").val() ) ) {
			$('#PT_Login_UNMsg').html(ok_template);
			formvalid.user_name = true;
		}
		else {
			$('#PT_Login_UNMsg').html(error_template.replace(/msg/, '帐号由4-16位英文、数字或下划线组成'));
			formvalid.user_name = false;
		}
	});
	
	$("#pt_password").blur(function() {
		if ( /^[\S]{6,16}$/.test( $("#pt_password").val() ) ) {
			$('#PT_Login_UPMsg').html(ok_template);
			formvalid.password = true;
		}
		else {
			$('#PT_Login_UPMsg').html(error_template.replace(/msg/, '由字母、数字组成，长度6－16个字符之间'));
			formvalid.password = false;
		}
	});
	
	$("#PT_Login_Submit").click(function() {
		for (result in formvalid) {
			if (!formvalid[result]) {
				return false;
			}
		}
		
		if (!isload) {
			return false;
		}
		
		$("#cross_domain").contents().find("#user_name").val($("#pt_user_name").val());
		$("#cross_domain").contents().find("#password").val($("#pt_password").val());
		$("#cross_domain").contents().find("#ajax_way_login").submit();
		formvalid.user_name = false;
		formvalid.password = false;
		return false;
	});
	
	/* logined_header_bind(); */
	if (typeof(index_login) != 'undefined') {
		index_login();
	}
	header_register();
});

var header_register = function () {
	var formvalid = {
		user_name: false,
		password: false,
		passconf: false,
		email: false,
		//captcha: false,
		agree: true
	};
	var error_template = '<table class="PT_Msg" cellpadding="0" cellspacing="0"><tr><td class="PT_Msg_L">  </td><td class="PT_Msg_C">msg</td><td class="PT_Msg_R">  </td></tr></table>';
	var ok_template = '<div class="PT_Msg_Right"></div>';
	$("#pt_reg_user_name").blur(function() {
		if ( /^[0-9a-zA-Z_]{4,16}$/.test( $("#pt_reg_user_name").val() ) ) {
			$.ajax({
				url: '/gateway_for_cross_domain.php',
				type: 'get',
				dataType: 'text',
				async: false,
				cache: false,
				data: {
					user_name: function () {
						return $('#pt_reg_user_name').val();
					},
					type: 'exist_name'
				},
				success:  function (result) {
					if (result == 'false') {
						$('#PT_Reg_UNMsg').html(ok_template);
						formvalid.user_name = true;
					}
					else {
						$('#PT_Reg_UNMsg').html(error_template.replace(/msg/, '该用户名已被使用或者是存在非法字符'));
						formvalid.user_name = false;
					}
				}
			});
		}
		else {
			$('#PT_Reg_UNMsg').html(error_template.replace(/msg/, '帐号由4-16位英文、数字或下划线组成'));
			formvalid.user_name = false;
		}
	});
	
	$("#pt_reg_password").blur(function() {
		if ( /^\S{6,16}$/.test( $("#pt_reg_password").val() ) ) {
			$('#PT_Reg_UPMsg').html(ok_template);
			formvalid.password = true;
		}
		else {
			$('#PT_Reg_UPMsg').html(error_template.replace(/msg/, '由字母、数字组成，长度6－16个字符之间'));
			formvalid.password = false;
		}
	});

	$("#pt_reg_passconf").blur(function() {
		if ( /^\S{6,16}$/.test( $("#pt_reg_passconf").val() ) &&  $("#pt_reg_passconf").val() == $("#pt_reg_password").val()  ) {
			$('#PT_Reg_UPCMsg').html(ok_template);
			formvalid.passconf = true;
		}
		else {
			$('#PT_Reg_UPCMsg').html(error_template.replace(/msg/, '两次密码输入不一致'));
			formvalid.passconf = false;
		}
	});
	
	$("#pt_reg_email").blur(function() {
		if ( /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.][a-zA-Z]+)*/.test($("#pt_reg_email").val()) ) {
			$.ajax({
				url: '/gateway_for_cross_domain.php',
				type: 'get',
				dataType: 'text',
				async: false,
				cache: false,
				data: {
					email: function () {
						return $('#pt_reg_email').val();
					},
					type: 'exist_email'
				},
				success:  function (result) {
					if (result == 'false') {
						$('#PT_Reg_UEMsg').html(ok_template);
						formvalid.email = true;
					}
					else {
						$('#PT_Reg_UEMsg').html(error_template.replace(/msg/, '邮箱地址已经被使用过了'));
						formvalid.email = false;
					}
				}
			});
		}
		else {
			$('#PT_Reg_UEMsg').html(error_template.replace(/msg/, '错误的邮件地址'));
			formvalid.email = false;
		}
	});
	
	/* $("#pt_reg_captcha").blur(function() {
		if ( /^[0-9]{4,4}$/.test($("#pt_reg_captcha").val()) ) {
			$('#PT_Reg_UCMsg').html(ok_template);
			formvalid.captcha = true;
		}
		else {
			$('#PT_Reg_UCMsg').html(error_template.replace(/msg/, '验证码输入错误'));
			formvalid.captcha = false;
		}
	}); */
	
	$("#pt_reg_refr").click(function() {
		var now = new Date();
		$("#pt_reg_imageYa").attr('src','http://passport.qc101.com/index.php/register/get_captcha/' + now.getTime());
		return false;
	});

	$("#pt_reg_agree").click(function() {
		if ( $("#pt_reg_agree")[0].checked == true ) {
			$('#PT_Reg_UAMsg').html(ok_template);
			formvalid.agree = true;
		}
		else {
			$('#PT_Reg_UAMsg').html(error_template.replace(/msg/, '必须同意倾城游戏用户许可协议,才能注册'));
			formvalid.agree = false;
		}
	});

	/* $("#PT_Reg_Submit").click(function() {
		for (result in formvalid) {
			if (!formvalid[result]) {
				return false;
			}
		}
		
		$.ajax({
			url: '/gateway_for_cross_domain.php',
			type: 'get',
			dataType: 'text',
			async: false,
			cache: false,
			data: {
				email: function () {
					return $('#pt_reg_email').val();
				},
				user_name: function () {
					return $('#pt_reg_user_name').val();
				},
				password: function () {
					return $('#pt_reg_password').val();
				},
				captcha: function () {
					return $('#pt_reg_captcha').val();
				},
				type: 'save'
			},
			success:  function (result) {
				$('.PT_Reg_ReMsg').text(result);
				if (/注册完成/gi.test(result)) {
					var now = new Date();
					var last_login_time = now.getFullYear() + '-' + now.getMonth() + '-' + now.getDate() + ' ' + now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds();
					login_header_succeed(2, $('#pt_reg_user_name').val() + ';' + last_login_time);
					$('#pt_reg_password').val('');
					$('#PT_Reg_UPMsg').html('');
					formvalid.password = false;
					$('#pt_reg_email').val('');
					$('#PT_Reg_UEMsg').html('');
					formvalid.email = false;
					$('#pt_reg_user_name').val('');
					$('#PT_Reg_UNMsg').html('');
					formvalid.user_name = false;
					$("#pt_reg_passconf").val('');
					$('#PT_Reg_UPCMsg').html('');
					formvalid.passconf = false;
				}
				if (result == 'true') {
					$('.PT_Reg_ReMsg').text('注册完成');
				}
				else {
					$('.PT_Reg_ReMsg').text('注册失败');
				}
			}
		});
	}); */
	
	$("#PT_Reg_Submit").click(function() {
		for (result in formvalid) {
			if (!formvalid[result]) {
				return false;
			}
		}
		
		if (!isregload) {
			return false;
		}
		
		//alert(document.getElementById('cross_domain').contentWindow.document);
		$("#cross_domain_reg").contents().find("#user_name").val($("#pt_reg_user_name").val());
		$("#cross_domain_reg").contents().find("#password").val($("#pt_reg_password").val());
		$("#cross_domain_reg").contents().find("#email").val($('#pt_reg_email').val());
		$("#cross_domain_reg").contents().find("#ajax_way_register").submit();
		
		return false;
	});
}

var loadurl = function (src) {
	isload = false;
	$("#cross_domain").attr('src', src);
}
function login_header_succeed(status, msg) {
	if (status == 1) {
		//alert(msg);
		$('.PT_Login_ReMsg').css("display", "block").text(msg);
	}
	else if (status == 2) {
		var info = msg.split(';');
		$("#pt_user_name").val('');
		$('#PT_Login_UNMsg').html('');
		$("#pt_password").val('');
		$('#PT_Login_UPMsg').html('');
		//$('#PT_login_user').text(info[0]);
		$('.PT_Login_ReMsg').css("display", "none").text('');
		$('.PT_Nav_Login').css("display", "none");
		$('.PT_Nav_Logind').css("display", "block").html('<div><a href="http://passport.qc101.com/member">' + info[0] + "</a><a href='http://passport.qc101.com/member'>用户中心</a><a href='#' id='header_logout' onclick='javascript:logout_header_act();'>退出</a></div>");
		$.cookie('qc101_user_name', info[0], { expires: 1, path: '/', domain: 'qc101.com' });
		$.cookie('qc101_login_last_time', info[1], { expires: 1, path: '/', domain: 'qc101.com' });
		if ( typeof(login_succeed) != 'undefined' ) {
			login_succeed(status, msg);
		}
	}
	else {
		return false;
	}
	
}
var logout_header_succeed = function () {
	$.cookie('qc101_user_name', null, { path: '/', domain: 'qc101.com' });
	$.cookie('qc101_login_last_time', null, { path: '/', domain: 'qc101.com' });
	loadurl('http://passport.qc101.com/login/ajax_way');
	$('.PT_Nav_Login').css("display", "block");
	$('.PT_Nav_Logind').css("display", "none").html('');
	if (typeof(logout_index_succed) != 'undefined') {
		logout_index_succed();
	}
}
var register_header_succeed = function (status, msg) {
	if (status == 1) {
		$('.PT_Reg_ReMsg').text(msg);
	}
	else if (status == 2) {
		login_header_succeed(2, msg);
		$('#pt_reg_password').val('');
		$('#PT_Reg_UPMsg').html('');
		//formvalid.password = false;
		$('#pt_reg_email').val('');
		$('#PT_Reg_UEMsg').html('');
		//formvalid.email = false;
		$('#pt_reg_user_name').val('');
		$('#PT_Reg_UNMsg').html('');
		//formvalid.user_name = false;
		$("#pt_reg_passconf").val('');
		$('#PT_Reg_UPCMsg').html('');
		//formvalid.passconf = false;
	}
}

var logout_header_act = function () {
	$("#cross_domain").attr('src', 'http://passport.qc101.com/member/logout_ajax_way');
	logout_header_succeed();
}
