var u_url_login = "/club/user/login";
var u_url_register = "/club/user/register";
var u_url_logout = "/club/user/logout";
var url_t = "http://218.200.174.132/logger/client.js";//统计服务提供的js,采集客户端相关信息

function u_login(returnToThis){
	var returnToThis = returnToThis || true;
	if(returnToThis){
		var url = u_url_login + "?continue=" + encodeURIComponent(window.location);
	}else{
		var url = u_url_login;
	}
	window.location = url;
}

function u_register(returnToThis){
	var returnToThis = returnToThis || true;
	if(returnToThis){
		var url = u_url_register + "?continue=" + encodeURIComponent(window.location);
	}else{
		var url = u_url_register;
	}
	window.location = url;
}

function u_logout(returnToThis){
	if(returnToThis){
		var url = u_url_logout + "?continue=" + encodeURIComponent(window.location);
	}else{
		var url = u_url_logout;
	}
	window.location = url;
}

jQuery(function($){

	var username = $.cookie('mobile');
	var randomSessionKey = $.cookie('randomSessionKey');
	var html = "";
	if(username&&randomSessionKey){
		html = '<b>' + username + '</b>&nbsp;&nbsp;<a href="/myrings/queryInboxTone.action" style="color:#FFF">彩铃管理</a>&nbsp;|&nbsp;<a href="/myrings/loginout.action" style="color:#FFF">退出登录</a>';
	}else{
		//html = '<form method="post" name="loginSubmit" id="loginSubmit" onsubmit="return checkLoginForm();">手机号：<input name="mobile" id="username"  class="logininput" value="" />&nbsp;密码：<input type="password" name="password" id="password" class="logininput" value="" />&nbsp;<input type="submit" name="button" id="login" value="" />&nbsp;<a href="/myrings/open.action" target="_blank" class="register" style="color:#FFF">开通彩铃</a>&nbsp;<a href="/myrings/user_getpwd.action" target="_blank" class="register" style="color:#FFF">找回密码</a></form>'
		html = '';
	}
	$("#loginbox").html(html)
	$("#loginbox").show();
});

function isCMCCmobile(s) {
	return true;
}
function trim(s){   
	return s.replace(/(^\s*)|(\s*$)/g,"");       
} 
function checkLoginForm() {
	var mobile = trim($("#username").val());
	var password = $("#password").val();
	if(!isCMCCmobile(mobile)){
		alert('请输入正确的中国移动手机号。');
		$("#username").focus();
		return false;
	}
	if(trim(password) == '')
	{
		alert("密码不能为空");
		$("#password").focus();
		return false;
	}
	if(!password.match(/^\d{6}$/ig))
	{
	      alert("密码只能为6位数字");
	      return false;
	}
	document.forms["loginSubmit"].action = "/myrings/doLoingMyRings.action";
	document.forms["loginSubmit"].submit();
}
/* add ana code */
$(function(){
	$.getScript(url_t,function(){//动态装载client.js，回调执行该函数提供的方法
			try {
				var pageLogger = new analiytis(); 
				pageLogger.setSiteId("sc"); 
				pageLogger.pageTracker(); 
				var pageTracker = _gat._getTracker("UA-18193577-7");
				pageTracker._trackPageview();
			} catch(err) {}
		});
});
$(function(){
	var topHref=window.top.location.href;
	var selfHref=window.self.location.href;
if (topHref != selfHref) 
{ 
    alert("安全提示:本页面被其他网站嵌套，可能影响您电脑的安全，为了您的安全，请跳转到原页面 钓鱼网址:"+topHref+"本网址:"+selfHref); 
    window.top.location.href=selfHref; 
} 
});
