/**
 * 邮箱注册二三步
 */

//获取邮箱传值
var mailVal = $.cookie('mailVal');
console.log(mailVal);  
var userId  = $.cookie('userId');
var mailCode = GetQueryString('sc');
//初始化
emailSuccess();	
//获取邮箱验证码传值注册
if(mailCode!=''){
    $.ajax("/ajax/regmail/"+mailCode,{
			type:"POST",
			async: true,
			success:function(data){ 
			   $('#completedcover').show(); 
			},
			error:function(){
			   $.MsgBox.Alert('消息','邮箱注册失败')
			},
			data:{"mail":mailVal,"userId":userId},			
		 	dataType: 'json'}
	); 	 
 }

//重新发送验证邮件
$("#resend_main").click(function(){
	emailResend();
});
	

function emailSuccess()
{
    $('#receiveMail').text(mailVal);
	$(".maillink").each(function() {  
        var url = mailVal.split('@')[1];
        for (var j in hash){  
            $(this).attr("href", hash[url]);  
        }  
     });
}

function goPersonal()
{
	 location.href="information-add.html?id="+userId;
}

function emailResend()
{
	
    console.log(mailVal); 
	$.ajax("/ajax/resendMail",{
			type:"GET",
			success:function(data){
			   // console.log(data);  
				$.MsgBox.Alert('消息','验证邮件重新发送成功,点击登录邮箱验证')
			},
			error:function(){
				$.MsgBox.Alert('消息','邮箱发送失败')
			},
			data:{"mail":mailVal},		
		 	dataType: 'json'}
		);
}