var BASE_URL = 'http://www.92haowan.com';


//邮件绑定窗口
function showBindingemail() {
	var url = "http://www.92haowan.com/member/member/bindingemail?KeepThis=true&TB_iframe=true&height=250&width=420&modal=true";
	tb_show('feedback', url);
}

//发送成功窗口
function showMailOk(email) {
	var url = "http://www.92haowan.com/member/member/showmailok"+'/email/'+email+"?KeepThis=true&TB_iframe=true&height=250&width=420&modal=true";
	tb_show('mailok', url);
}

//验证绑定邮箱格式
function checkBindingemail() {
	var email = $("#email").val();
	var emailRepeat = $("#emailRepeat").val();

	if(!isEmail(email)) {
		$("#emailMessage").html('邮箱不正确');
		return false;
	} else {
		$("#emailMessage").html('');
	}

	if(emailRepeat != email) {
		$("#emailRepeatMessage").html('两次邮箱地址不一致');
		return false;
	} else {
		$("#emailRepeatMessage").html('');
	}

	var url = 'http://home.92haowan.com/cp.php?ac=profile&op=contact&newemail=1&callback=?';
	$.getJSON(url, {email:email},
	function(json){
		result = json.result;
		if(result == 1) {
			parent.showMailOk(email);
		}
	});
}

//重新发送邮件
function resendmail(email) {
	var url = 'http://home.92haowan.com/cp.php?ac=profile&op=contact&resendmail=1&callback=?';
	$.getJSON(url,
	function(json){
		result = json.result;
		if(result == 1) {
			parent.showMailOk(email);
		}
	});
}


//email对应接收网址转换
function emailToweb(email) {
	var web = new Array();
	var url = null;
	//各网站的邮件登录地址
	web['qq'] = 'https://mail.qq.com';
	web['google'] = 'https://www.google.com/accounts/Login';
	web['sina'] = 'http://mail.sina.com.cn';
	web['hotmail'] = 'https://login.live.com';
	web['163'] = 'http://mail.163.com/';
	web['yahoo'] = 'http://mail.cn.yahoo.com/';
	web['sohu'] = 'http://mail.sohu.com/';
	web['tom'] = 'http://mail.tom.com/';
	web['51'] = 'http://mail.51.com';
	web['139'] = 'http://mail.10086.cn/';
	web['92haowan'] = 'http://mail.92haowan.com/src/webmail.php';
	
	var e = email.split('@');
	if(e[1]) {
		var com = e[1].split('.');
		var key = com[0];
		if(web[key]) {
			url = web[key];
		} else {
			var url = 'http://www.'+e[1];
		}
	}
	$("#webUrl").attr('href', url);
	//parent.location.href = url;
}


//立即请求发送邮件
function doSendMail() {
	var url = 'http://home.92haowan.com/do.php?ac=sendmail&callback=?';
	$.getJSON(url, {r:Math.random()},
	function(json){

	});
}
