//网站路径(域名)控制器
(function(){
	window.X||(window['X']={});
	X.domain = "10086.cn";
	X.PATH={
		ROOT:"http://music.10086.cn/newweb/",
		SUPPORT:"http://mdll.10086.cn/newweb/",
		VIP:"http://mapi.10086.cn/newweb/",
		CLUB:"http://mclub.10086.cn",
		WM:"http://wm.10086.cn",		
		M:"http://m.10086.cn",
		CONTENT:"http://content.12530.com/"		
	}
	//重载域名
	X.PATH.WAP=X.PATH.M;
	document.domain='10086.cn';
})();

function userHeaderSearch(){
	document.getElementById("search_content").value=document.getElementById("ringSearchInput").value;
	var testValue =document.getElementById("ringSearchInput").value.replace(/[\s]/g,"");
	var validRegExp=/[\/&<>%+|\\\']/;
	if (validRegExp.test(testValue)){
		  alert('输入内容不能包含“%”，“/”，“&”，“+”，“\\”，“|^|”,请尝试其他关键字！');
		  return;
	}else{
		search_content_click(0,2);
		document.form_search_content.submit();
	}
	
}
function isSearch(){
	var keyCode;   
	keyCode = window.event.keyCode;   
	if(keyCode == 13 ){
	  userHeaderSearch();
	  return true;
	}
	return false;
}

function islogin(){
	var keyCode;   
	keyCode = window.event.keyCode;   
	if(keyCode == 13 ){
	  ringUserLogin();
	}
}
function ringUserLogin(){
	document.getElementById("btnRingLogin").disabled=true;
	var userName=document.getElementById("ringUserName").value.replace(/[\s]/g,"");
	var pwd=document.getElementById("ringPwd").value.replace(/[\s]/g,"");
	var vCode=document.getElementById("ringVcode").value;
	var loginOption=document.getElementById("ringLoginOption").value;
	if(userName.length==0||!isCMCCmobile(userName)){
		alert("请输入正确的中国移动手机号！");
		document.getElementById("btnRingLogin").disabled=false;
		document.getElementById("ringUserName").select();
		return false;
	}
	
	if(pwd.length==0){
		alert("密码不能为空！");
		document.getElementById("btnRingLogin").disabled=false;
		return false;
	}
	if(vCode.length==0){
		alert("验证码不能为空！");
		document.getElementById("btnRingLogin").disabled=false;
		return false;
	}
	
	var jsonRequestObjectabc = new Object();
	jsonRequestObjectabc.userName=userName;
	jsonRequestObjectabc.pwd=pwd;
	jsonRequestObjectabc.vCode=vCode;
	jsonRequestObjectabc.loginOption=loginOption;
	jsonRequestObjectabc.logPars=from+","+fromchnl+","+fromcchnl+","+channel+","+cchannel+","+page;
	remotejs(X.PATH.ROOT+'jsp/v3_ring/ringUserLogin_v2.jsp', 'ringUserLoginCallback', jsonRequestObjectabc);

}
function ringUserLoginCallback(jsonString){
	var jsonObject = strToJSON(jsonString); 
	var isNameRight=jsonObject.isNameRight;
	var isPwdRight=jsonObject.isPwdRight;
	var isValidateRight=jsonObject.isValidateRight;
	var message=jsonObject.message;
	var loginOption=jsonObject.loginOption;
	document.getElementById("btnRingLogin").disabled=false;
	if(isValidateRight){
		if(isNameRight&&isPwdRight){
			getpopularity();
			var ringLoginState=jsonObject.ringLoginState;
			var ringUser=jsonObject.ringUser;
			if(ringLoginState==1){
				var loginState1="none";
				var loginState2="block";
				var loginState3="none";
				document.getElementById("welcomeUser1").innerHTML=ringUser;
			}else if(ringLoginState==2){
				var loginState1="none";
				var loginState2="none";
				var loginState3="block";
				document.getElementById("welcomeUser2").innerHTML=ringUser;
			}else{
				var loginState1="block";
				var loginState2="none";
				var loginState3="none";
			}
			document.getElementById("loginState1").style.display=loginState1;
			document.getElementById("loginState2").style.display=loginState2;
			document.getElementById("loginState3").style.display=loginState3;
			var isScUser=jsonObject.isScUser;
			if(isScUser==1){
				document.getElementById("controlmusicbox").href=X.PATH.SUPPORT+"sc/lingyinku/12530/_/_/p.html";
			}
			if(loginOption==1){
				if(isScUser==1){
					window.open(X.PATH.SUPPORT+"sc/lingyinku/12530/_/_/p.html");
				}else{
					window.open(X.PATH.SUPPORT+"musicbox/musicbox/12530/_/_/p.html");
				}
			}
		}else{
			refreshImgPass(document.getElementById('ringValidateImg'));
			document.getElementById("ringPwd").value="";
			document.getElementById("ringUserName").value="";
			document.getElementById("ringVcode").value="";
			alert(message);
		}
	}else{
		refreshImgPass(document.getElementById('ringValidateImg'));
		document.getElementById("ringVcode").value="";
		alert("验证码错误，请重新输入");
	}
}

