
var email=null;var emailConfirm=null;var pass=null;var passConfirm=null;var username=null;var capchaConfirm=null;var gender=null;var day=null;var month=null;var year=null;var agreement=null;var isValidEmail=false;var isValidPass=false;var isValidDate=false;var isValidFormValue=false;var isValidNick=false;var isValidAgreement=false;var isExistEmail=true;var isExistName=true;function changeImage(){document.getElementById("signup_captcha_image").src="${contextPath}/Captcha.jpg?time="+Math.random()*100;}
function showSignup(show){if(show){document.getElementById('info').style.display='block';document.getElementById('sigup_popup').style.display='block';}else{document.getElementById('info').style.display='none';document.getElementById('sigup_popup').style.display='none';}}
function signupnow(){document.getElementById("sign_b").disabled="disabled";email=document.getElementById("emails");pass=document.getElementById("password");username=document.getElementById("username");agreement=document.getElementById("agreement");validateSignupForm();if(isValidEmail&&isValidPass&&isValidNick&&isValidAgreement&&isExistEmail&&isExistName){$("#tempSecForm #j_username").val(username.value);$("#tempSecForm #j_password").val(pass.value);var captchaValue=$("#signup_captcha").val();if(captchaValue.trim()!=""){AjaxCaptchaService.checkCaptcha(captchaValue,function(result){if(result){ssoTypeInput=document.getElementById("ssoType");ssoIdentifierInput=document.getElementById("ssoIdentifier");ssoType=null;ssoIdentifier=null;if(ssoTypeInput!=null){ssoType=ssoTypeInput.value;}
if(ssoIdentifierInput!=null){ssoIdentifier=ssoIdentifierInput.value;}
AjaxUserService.signup(username.value,pass.value,email.value,captchaValue,ssoType,ssoIdentifier,signupCallback);return;}else{JSUtil.reloadCaptcha("signup_captcha_image");$("#captchaError").html('<em class="errors">Incorrect characters</em>');}});}else{$("#captchaError").html('<em class="errors">Please enter the captcha</em>');}}
signupFailCallback();}
function signupFailCallback(result){if(result!=null){var jsonObject=eval("({"+result+"})");if(jsonObject.captcha!=null){$("#captchaError").html('<em class="errors">'+jsonObject.captcha+'</em>');}}
document.getElementById("sign_b").disabled=false;}
function signupCallback(result){if(result==null){showThanksForSignup();$(document).ready(function(){setTimeout("hideThanksForSignup();",5000);});}else{if(result==null){return;}
var data=eval("("+result+")");if(data.email!=null){$("#error_email").html(data.email).show("slow");}else{$("#error_email").html("").hide("slow");}
if(data.username!=null){$("#error_username").html(data.username).show("slow");}else{$("#error_username").html("").hide("slow");}}
document.getElementById("sign_b").disabled=false;}
function validateSignupForm(){$('#error_password').hide();$('#error_privacy').hide();$('#agreement').hide();isValidPass=validatePassword(trim(pass.value));if(agreement.checked==true){isValidAgreement=true;}else{isValidAgreement=false;$('#error_privacy').show("slow");}
if(email.value!=""&&trim(email.value)!=email.defaultValue){isValidEmail=validateEmail(email.value);}else{isValidEmail=false;$("#error_email").html("Please choose a valid email address.").show("slow");}
if(username.value!=""&&trim(username.value)!=username.defaultValue){isValidNick=validateUsername(username.value);}else{isValidNick=false;$('#error_username').html("Please choose a valid member name.").show("slow");}}
function validateAgreement(val){if(val==null||!val){return false;}
return true;}
function trim(str){return str.replace(/^\s*|\s*$/g,"");}
function validatePassword(password){if(password==""){$("#error_password").html("Please enter your password.").show("slow");return false;}
if(password.length<6||password.length>10){$("#error_password").html("Your password must be between 6 and 10 characters.").show("slow");return false;}
return true;}
function hideSignup(){document.getElementById('overlay').style.display='none';$("#sigup_popup").hide();}
function hideThanksForSignup(){if($("#thanks_for_signup_popup").length>0){$('#tempSecForm').ajaxSubmit(callbackFunc_login);$('overlay').hide();$("#thanks_for_signup_popup").remove();}}
function showSignup(){if(window.lockSignupPopup===true){return;}
window.lockSignupPopup=true;if(document.getElementById("login_page")){$('#login_page').hide();}
removeSsoSignupIfExisted();if(!document.getElementById("sigup_popup")){urlSignup=__encodeURL(contextPath+"/swr/viewSignUp");$.post(urlSignup,function(result){result=JSUtil.trim(result);if(!document.getElementById("sign")){var newdiv=document.createElement('div');newdiv.id="sign";document.body.appendChild(newdiv);}
document.getElementById('overlay').style.display='block';$("#sign").append(result);init();JSUtil.centerObject("sigup_popup");$("#sigup_popup").draggable({cancel:"#chrep,input,button,img"});window.lockSignupPopup=false;});}else{document.getElementById("signUpFormId").reset();document.getElementById("fll").setAttribute((document.all?"className":"class"),"ischeck uncheck");$('#signUpFormId').find("div[id*='error']").hide();$('#agreement').hide();document.getElementById('overlay').style.display='block';JSUtil.centerObject("sigup_popup");$("#sigup_popup").draggable({cancel:"#chrep,input,button,img"});$("#sigup_popup").show();window.lockSignupPopup=false;}}
function removeSsoSignupIfExisted(){var ssoIdentifier=document.getElementById("ssoIdentifier");if(ssoIdentifier!=null){var oldSignUp=document.getElementById("sign");if(oldSignUp!=null){document.body.removeChild(oldSignUp);}}}
function showThanksForSignup(){$("#sigup_popup").hide();document.getElementById('overlay').style.display='block';if(!document.getElementById("thanks_for_signup_popup")){$.post(contextPath+"/swr/viewThanksForSignUp",function(result){result=JSUtil.trim(result);if(!document.getElementById("sign")){var newdiv=document.createElement('div');newdiv.id="sign";document.body.appendChild(newdiv);}
$("#thanks_for_signup_popup").hide();$("#sign").append(result);init();JSUtil.centerObject("thanks_for_signup_popup");$("#thanks_for_signup_popup").draggable({cancel:"#button,img"});$("#thanks_for_signup_popup").show();});}else{JSUtil.centerObject("thanks_for_signup_popup");$("#thanks_for_signup_popup").draggable({cancel:"#button,img"});$("#thanks_for_signup_popup").show();}}
function validateEmail(email){if(!JSUtil.validateEmail(email)){$("#error_email").html("Please choose a valid email address.").show("slow");return false;}
return true;}
function validateUsername(username){if(username.length<4||username.length>32){$('#error_username').html("Your member name must be between 4 and 32 characters long.").show("slow");return false;}
var firstChar=username.substring(0,1).toLowerCase();if(firstChar<'a'||firstChar>'z'){$('#error_username').html("Your member name must begin with a letter.").show("slow");return false;}
var isValid=/^([a-zA-Z0-9_-])+([\s\.a-zA-Z0-9_][\.a-zA-Z0-9_]+)*$/.test(username);if(!isValid){$('#error_username').html("Please choose a valid member name.").show("slow");return false;}
return true;}
function checkEmailExist(){var inputObj=document.getElementById("emails");var email=inputObj.value;if(email!=inputObj.defaultValue&&email.length>0){if(!validateEmail(email))
return;if(window.emailCheckingLock!=true){window.emailCheckingLock=true;if(window.emailCheckingTimeout!=undefined){window.clearTimeout(window.emailCheckingTimeout);}
isExistEmail=true;AjaxUserService.checkUserExistByEmail(email,function(data){window.emailCheckingLock=false;if(data!=null){isExistEmail=false;$("#error_email").html(String.splitLongWord(data,5)).show("slow");}else{isExistEmail=true;$("#error_email").hide();}});}else{window.emailCheckingTimeout=window.setTimeout('checkEmailExist()',1000);}}}
function checkMembernameExist(){var inputObj=document.getElementById("username");var username=inputObj.value;if(username!=inputObj.defaultValue&&username.length>0){if(!validateUsername(username))
return;if(window.usernameCheckingLock!=true){window.usernameCheckingLock=true;if(window.usernameCheckingTimeout!=undefined){window.clearTimeout(window.usernameCheckingTimeout);}
isExistName=true;AjaxUserService.checkUserExistByUsername(username,function(data){window.usernameCheckingLock=false;if(data!=null){isExistName=false;$('#error_username').html(data).show("slow");}else{isExistName=true;$("#error_username").hide();}});}else{window.usernameCheckingTimeout=window.setTimeout('checkMembernameExist()',1000);}}}
function onCheckAgreement(obj){if($(obj).hasClass("uncheck")){$("div#error_privacy").hide("slow");}
checkbox(obj);}
function showSignupForSSO(ssoType,ssoIdentifier){if(window.lockSignupPopup===true){return;}
window.lockSignupPopup=true;if(document.getElementById("login_page")){$('#login_page').hide();}
urlSignup=__encodeURL(contextPath+"/swr/viewSignUp?isSSO=true&ssoType="+ssoType+"&ssoIdentifier="+ssoIdentifier);$.post(urlSignup,function(result){result=JSUtil.trim(result);var oldSignUp=document.getElementById("sign");if(oldSignUp!=null){document.body.removeChild(oldSignUp);}
var newdiv=document.createElement('div');newdiv.id="sign";document.body.appendChild(newdiv);document.getElementById('overlay').style.display='block';$("#sign").append(result);init();JSUtil.centerObject("sigup_popup");$("#sigup_popup").draggable({cancel:"#chrep,input,button,img"});window.lockSignupPopup=false;});}