﻿var emailExist = false;
function checkInput()
{
    if(!isEmail(getValue("txtEmail")))
    {
        showDialog("please input a email format");
        return false;
    }
    
    if(getValue("txtPwd").length < 6 || getValue("txtPwd").length > 16)
    {
        showDialog("the password must be 6-16");
        return false;
    }
    
    if(getValue("txtPwd") != getValue("txtPwdConfirm"))
    {
        showDialog("the password must be mathed.");
        return false;
    }
    
    if(emailExist)
    {
        showDialog("An account with this email already exists. Please enter another email.");
        return false;
    }
    
    if(!document.getElementById("checkAgree").checked)
    {
        showDialog("you should agree the privacy to continue registration.");
        return false;
    }
    return true;
}

function checkEmailExist()
{
    var email = getValue("txtEmail");
    getAjaxContent("../ajaxResponse/checkEmail.aspx?email=" + email,onCheckEmailExist);
}

function onCheckEmailExist(ret)
{
    if(ret == "yes")
        emailExist = true;
    else
        emailExist = false;
}

function initializePhotoCropper()
{
    var width=360;
    var height= 250;
    //debugger;
    var obj = document.getElementById(Cropper.idCropImage);
    obj.src = src+"?r="+Math.random();
    obj.width = width;
    obj.height = height;
    Cropper.init();
    
    document.getElementById(Cropper.idImageCropion).width = width;
    document.getElementById(Cropper.idImageCropion).height = height;
    document.getElementById(Cropper.idShield).style.width = width;
    document.getElementById(Cropper.idShield).style.height = height;
    document.getElementById(Cropper.idShield).style.top = 0;
    document.getElementById(Cropper.idShield).style.left = 0;
}


