// 会员登录的检查脚本
function checkLogin(form) {
	with (form){
		if (MemberID.value == ''){
			// 检查用户ID是否为空
			alert('请输入会员ID');MemberID.focus();return false;
		}
		if (MemberPassWord.value == ''){
			// 检查用户密码是否为空
			alert('请输入会员密码');MemberPassWord.focus();return false;
		}
		return true;
	}
}
function ajaxCheckLogin(form) {
	with (form){
		if (MemberID.value == ''){
			// 检查用户ID是否为空
			alert('请输入会员ID');MemberID.focus();return false;
		}
		if (MemberPassWord.value == ''){
			// 检查用户密码是否为空
			alert('请输入会员密码');MemberPassWord.focus();return false;
		}
		//var url = "ajaxlogin.php?MemberID="+MemberID.value+"&MemberPassWord="+MemberPassWord.value;
		//AjaxLogin(url);
		
		// 用jQuery方式登录
		$.jQueryLogin(MemberID.value, MemberPassWord.value, '1');
		return false;
	}
}
function ajaxPopupLogin() {
	var usr = document.getElementById("username_pop").value;
	var pas = document.getElementById("password_pop").value;
	var cookie = document.getElementById("iscookie").checked;
	var recordcookie = '0';
	if(cookie){
		recordcookie = '1';
	}
	if (usr == ''){
		// 检查用户ID是否为空
		alert('请输入天下通ID');document.getElementById("username_pop").focus();return false;
	}
	if (pas == ''){
		// 检查用户密码是否为空
		alert('请输入会员密码');document.getElementById("password_pop").focus();return false;
	}
	$.jQueryLogin(usr, pas, recordcookie);
	//var url = "ajaxlogin.php?MemberID="+usr+"&MemberPassWord="+pas;
	//AjaxLogin(url);
	
	// 用jQuery的ajax方式登录
	//$.jQueryLogin(usr, pas);
	return false;
	
}
function ajaxLogon(user, pass) {
	if (user == '' || pass == '')
	{
		alert('请输入乙太通行证ID和密码...');
	}
	$.jQueryLogin(user, pass, '1');
	return false;
}
function checkShopFlag() {
	if (shopFlag != '1'){
		if (confirm('您必须经过手机实名验证，才能发布商品信息！是否现在进行实名验证')){
			window.open("mobileverify.php", "VerifyWindow", "width=450, height=430, scrollbars=no, location=no, menubar=no, status=no");
		}
		return false;
	}
	return true;
}

	function checkPressKey() { 
		if (event.keyCode == 13) {
			ajaxCheckLogin(document.getElementById('loginform'));
		}
    }
	function checkPopPressKey() { 
		if (event.keyCode == 13) {
			ajaxPopupLogin();
		}
    }

	function AjaxLogin(url){
		xmlhttp=GetXMLHttpRequest();
		xmlhttp.onreadystatechange=function(){
			if (4==xmlhttp.readyState){
				if (200==xmlhttp.status){
					eval(xmlhttp.responseText);
					
					if (mID == '') {
						alert(msg);
						return;
					}
					try {
						document.getElementById('welcome_name_li').innerHTML="欢迎您:"+msg;					
						onUserLogin(mEtelNo, mPasswd, mPermitPublish);
					}catch(e){
					}
					try {
						nodeng();
					}catch(e){
					}
					
					if (ShopFlag != '1' && index_title < 50) {
						try {
						//if(objExists('mainFrame.mainFrame14.regshoptitle')){
							mainFrame.mainFrame14.document.getElementById('regshoptitle').style.display='';
						//}
						}catch(e){
						}
					}
					if (index_title == 1000) {
						try{
						//if(objExists('mainFrame.loginb2ctitle')){
							mainFrame.document.getElementById('loginb2ctitle').style.display='';
						//}
						}catch(e){
						}
					}
					try{
						mainFrame.document.getElementById('friendFrame').src="friends.php";
					}catch(e){
					}
					return ;
					/*var v=xmlhttp.responseText.replace(/(^\s*)|(\s*$)/g,"");
					var pos = v.indexOf('`');
					if (pos == -1) {
						alert(v);
					}else{
						// 格式 [ID].[乙太号码].[密码].[ShopFlag].[用户名]
						mID = v.substring(0, pos);	// ID
						//alert(mID);
						v = v.substring(pos+1);
						pos = v.indexOf('`');
						mEtelNo = v.substring(0, pos);
						//alert(mEtelNo);
						v = v.substring(pos+1);
						pos = v.indexOf('`');
						mPasswd = v.substring(0, pos);
						//alert(pass);
						v = v.substring(pos+1);
						pos = v.indexOf('`');
						ShopFlag = v.substring(0, pos);
						
						v = v.substring(pos+1);
						pos = v.indexOf('`');
						mPermitPublish = v.substring(0, pos);
						
						try {
							document.getElementById('welcome_name_li').innerHTML="欢迎你，"+v.substring(pos+1);					
							onUserLogin(mEtelNo, mPasswd, mPermitPublish);
						}catch(e){
						}
						
						if (ShopFlag != '1' && index_title < 50) {
							try {
							//if(objExists('mainFrame.mainFrame14.regshoptitle')){
								mainFrame.mainFrame14.document.getElementById('regshoptitle').style.display='';
							//}
							}catch(e){
							}
						}
						if (index_title == 1000) {
							try{
							//if(objExists('mainFrame.loginb2ctitle')){
								mainFrame.document.getElementById('loginb2ctitle').style.display='';
							//}
							}catch(e){
							}
						}
					}*/
				}
			}
		}
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	}
	
	function AjaxLogout(){
		xmlhttp=GetXMLHttpRequest();
		xmlhttp.onreadystatechange=function(){
			if (4==xmlhttp.readyState){
				if (200==xmlhttp.status){
					eval(xmlhttp.responseText);
					onUserLogout();
					
					try{
						mainFrame.document.getElementById('friendFrame').src="friends.php";
					}catch(e){
					}
					return ;
				}
			}
		}
		xmlhttp.open("GET","ajaxlogout.php",true);
		xmlhttp.send(null);
		return false;
	}
	
	function getUserEtelNo() {
		//alert(mEtelNo);
		if (mEtelNo == "") {
			alert("您还未登录，必须先登录才能进行使用该功能！");
			top.loginform.MemberID.focus();
		}
		return mEtelNo;
	}

	function getOsVersion() {
		var ua = window.navigator.userAgent; 
		var osVersion = ua.split(";")[2].split(")")[0]; 
		var osV = osVersion.substr(osVersion.length-3,3); 
		switch(osV) 
		{ 
			case "5.0": 
				return "Win2000";
				break; 
			case "5.1": 
				return "WinXP";
				break; 
			case "5.2": 
				return "Win2003"; 
				break; 
			case "6.0": 
				return "Vista"; 
				break; 
			case "6.1": 
				return "Win7"; 
				break; 
			default: 
				return "Others"; 
				break; 
		} 
	}

	function downloadmedia() {
		window.open('download/lmediasetup.exe');
		return false;
	}

	function downloadetel() {
		//window.open('download/setup201009.exe');
		//alert(ytponedownloadurl);
		window.open(ytponedownloadurl);
		return false;
	}

	function downloadmobile() {
		//window.open(ytmobiledownloadurl);
		window.open("/download/downloadmobile.html");
		return false;
	}

	function downloadandroid() {
		window.open("/download/downloadmobile.html");
		return false;
	}


	function onUserLogin(user, pass, publish) {
		mediaGatewayLogin(user, pass, publish);
		document.getElementById('before_login_display').style.display='none';
		document.getElementById('login_display').style.display='';
		online();
		setInterval('online()', 20000);
		setInterval('getnewmsg()', 2000);
	}
	function onUserLogout() {
		//mediaGatewayLogout();
		document.loginform.MemberID.value="";
		document.loginform.MemberPassWord.value="";
		document.getElementById('before_login_display').style.display='';
		document.getElementById('login_display').style.display='none';
		try{
			//mainFrame.mainFrame14.frames.item('mainframe_shop').location.reload();  //Firefox 下不行
			mainFrame.mainFrame14.frames['mainFrame_yt'].location.reload();
		}catch(e){
		}

		// location.href="index.php";
	}
	function chatWith(v, tel){
		//var obj = document.getElementById('mainFrame');
		mainFrame.chat(v, tel);
		return false;
	}
	function chatWithAndTuijian(v, tel){
		//var obj = document.getElementById('mainFrame');
		mainFrame.phoneTuijianChat(v, tel);
		return false;
	}
	function register(){
		window.open('/register.php');
		return false;
		if (mID != '')
		{
			alert('您已经是乙太天下通会员，无需再注册！');
		}else{
			window.open('/webshops/register.php', 'RegisterWindow', 'width=820, scrollbars=yes, location=no, menubar=no, status=no');
		}
		return false;
	}

	function changeUserInfo(){
		if (mID == ''){
			alert('您还未登录，请登录后再来修改资料！');
			tanceng();
			return false;
		}
		window.open('/webshops/editmemberinfo.php', 'RegisterWindow', 'width=820, scrollbars=yes, location=no, menubar=no, status=no');
		return false;
	}

	function searchNewFriend(){
		if (mID == ''){
			alert('您还未登录，请登录后再来添加好友！');
			tanceng();
			return false;
		}
		window.open('/tongxun/findfriend.php', 'FriendWindow', 'width=466, height=310, scrollbars=no, location=no, menubar=no, status=no');
		return false;
	}
	function logon(){
		if (mID == '')
		{
			tanceng();
		}
		return false;
	}
	function opennav(){
		try {
			var obj = mainFrame.document.getElementById('mainHideDisplay');
			obj.style.display = 'none';
			obj = mainFrame.document.getElementById('mainDisplay');
			obj.style.display = '';
		}catch(e){
			//alert(e.message);
		}
	}
	function openweb(src){
		try {
			if (mID == ''){
				alert('您还未登录，请登录后再来管理代理账户！');
				tanceng();
				return false;
			}
			var obj = mainFrame.document.getElementById('mainHideDisplay');
			obj.style.display = 'none';
			obj = mainFrame.document.getElementById('mainDisplay');
			obj.style.display = '';
			var obj1 = mainFrame.mainFrame14.document.getElementById('mainframe_shop');
			//alert(obj1);
			//var obj2 = obj1.getElementById('mainFrame14');
			//alert(obj2);
			//alert( obj1.src );
			obj1.src = src;
			return false;
		}catch(e){
			//alert(e.message);
		}
	}
	function link1()
	{
		document.getElementById('mainFrame').src='index_voip.php?indexfile=tiyan';
		document.getElementById('log1').style.display="none";
		document.getElementById('log2').style.display="none";
		return false;
	}
	function link2()
	{
		document.getElementById('mainFrame').src='index_shop.php?indexfile=goodsad1';
		document.getElementById('log1').style.display="none";
		document.getElementById('log2').style.display="none";
		return false;
	}
	function link3()
	{
		document.getElementById('mainFrame').src='index_shop.php?indexfile=singelpic';
		document.getElementById('log1').style.display="none";
		document.getElementById('log2').style.display="none";
		return false;
	}
	function link4()
	{
		document.getElementById('mainFrame').src='index_voip.php?indexfile=jf_index';
		document.getElementById('log1').style.display="none";
		document.getElementById('log2').style.display="none";
		return false;
	}
	function link5()
	{
		document.getElementById('mainFrame').src='index_voip.php?indexfile=../agent/voip/index2';
		document.getElementById('log1').style.display="none";
		document.getElementById('log2').style.display="none";
		return false;
	}
	function linkshop()
	{
		// 买手机送话费
		document.getElementById('mainFrame').src='index_shop.php?indexfile=discount';
		document.getElementById('log1').style.display="none";
		document.getElementById('log2').style.display="none";
		return false;
	}
	function linkSrc(v)
	{
		document.getElementById('mainFrame').src=v;
		return false;
	}

	function openWeb(v)
	{
		switch (v){
		case 1://TV频道  //aa
			//document.getElementById('mainFrame').src='index_voip.php';
			document.getElementById('mainFrame').src='index_tv.php';
			break;
		case 5://电话频道  //aa
			//document.getElementById('mainFrame').src='index_tv.php?channeltype=5';
			document.getElementById('mainFrame').src='index_voip.php';
			break;
		case 4://KTV频道  //aa
			//document.getElementById('mainFrame').src='index_tv.php?channeltype=4';
			document.getElementById('mainFrame').src='index_tv.php?channeltype=5';
			break;
		case 2://电影频道  //aa
			//document.getElementById('mainFrame').src='index_fc.php';
			document.getElementById('mainFrame').src='index_tv.php?channeltype=4';
			break;
		case 9://福彩频道  //aa
			//document.getElementById('mainFrame').src='index_shop.php';
			document.getElementById('mainFrame').src='index_fc.php';
			break;
		case 7://商铺频道  //aa
			//document.getElementById('mainFrame').src='index_tv.php';
			document.getElementById('mainFrame').src='index_shop.php';
			break;
		case 8://商城频道  //aa
			document.getElementById('mainFrame').src='index_shop.php?indexfile=webshops/discount.php';
			break;
		case 3:
			// 音乐频道  //aa
			document.getElementById('mainFrame').src='index_tv.php?channeltype=3';
			break;
		case 12:
			// 经验交流  //aa
			document.getElementById('mainFrame').src='index_jyjl.php';
			// 网络学堂  //aa
//			document.getElementById('mainFrame').src='index_school.php';
			break;
		case 14:
			// 视频会议  //aa
			document.getElementById('mainFrame').src='index_meting.php';
			break;
		case 0:
			// 公司新闻  //aa
			document.getElementById('mainFrame').src='index_about.php';
			break;
		case 16:
			// 百万程序  //aa
			document.getElementById('mainFrame').src='index_bada.php';
			break;
		case 6:
			// 代理  //aa
			document.getElementById('mainFrame').src='index_voip.php?agentsystem=./agent/voip/index_zy.html';
			break;
		case 15:
			// 接口  //aa
			document.getElementById('mainFrame').src='index_interface.php';
			break;
		case 10:
			// 交友  //aa
			document.getElementById('mainFrame').src='index_friend.php';
			break;
		case 13:
			// 法律  //aa
			document.getElementById('mainFrame').src='index_law.php';
			break;
		case 11:
			// 博客  //aa
			document.getElementById('mainFrame').src='index_boke.php';
			break;
		case 17:
			// 商铺咨询服务  //aa
			document.getElementById('mainFrame').src='index_serviceshops.php';
			break;
		case 18:
			// 工信部食品监督  //aa
//			document.getElementById('mainFrame').src='index_cxjd.php';
			document.getElementById('mainFrame').src='index_shop.php';
			break;
		case 19:
			// 微博  //aa
			document.getElementById('mainFrame').src='index_weibo.php';
			break;
		case 20:
			// 手机软件
			document.getElementById('mainFrame').src='index_phone.php';
			break;
		}
		return false;
	}

	function swapFlash(id, url){
		 var flash = document.getElementById(id);
		 flash.stop();
		 flash.LoadMovie(1, url);
	}

	function flash_display(){
		document.getElementById('flash_menu').style.display = 'none';
		document.getElementById('flash_ad').style.display = '';
	}
	function flash_nodisplay(){
		document.getElementById('flash_ad').style.display = 'none';
		document.getElementById('flash_menu').style.display = '';
	}

	// 把会员加入黑名单
	function addBlack(uid){
		xmlhttp=GetXMLHttpRequest();
		xmlhttp.onreadystatechange=function(){
			if (4==xmlhttp.readyState){
				if (200==xmlhttp.status){
					alert(xmlhttp.responseText);
				}
			}
		}
		var url = "/tongxun/operblack.php?act=add&uid="+uid;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
		return false;
	}
	
	function deleteBlack(uid){
		xmlhttp=GetXMLHttpRequest();
		xmlhttp.onreadystatechange=function(){
			if (4==xmlhttp.readyState){
				if (200==xmlhttp.status){
					alert(xmlhttp.responseText);
				}
			}
		}
		var url = "/tongxun/operblack.php?act=del&uid="+uid;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
		return false;
	}

	function applyRadioshop() {
		if (mID == "") {
			alert ("您必须先登录才能申请开通乙太视讯商铺！");
			tanceng();
			return false;
		}
		if (ShopFlag == '1') {
			alert ("您已经开通乙太视讯商铺，无需再次申请！");
			return false;
		}
		window.open('/webshops/reg.php', 'RegisterWindow', 'width=820, scrollbars=yes, location=no, menubar=no, status=no');
		return false;
	}

	function lastChatWith(){
		//var obj = document.getElementById('mainFrame');
		if (lastETelNo != '')
		{
			if (mEtelNo == lastETelNo) {
				lastETelNo = '';
				alert ("您不能和自己聊天！");
			}else{
				mainFrame.chat(1, lastETelNo);
			}
		}else{
			mainFrame.chat(1, mainFrame.uETelNo);
		}
		return false;
	}
	
var mID='';
var mEtelNo='';
var mPasswd = '';
var ShopFlag='';
var mPermitPublish='0';
var isJust = 0;
var lastETelNo = '';
var ifReload = 1;

var ytponedownloadurl = 'http://www.yt333.com/download/setup201009.exe';
var ytmobiledownloadurl = 'http://www.yt333.com/download/mobilemeeting.cab';
var ytmobiledownloadurl = 'http://www.yt333.com/download/androidmeeting.apk';

