jQuery(document).ready(function(){
bindLogin();
var validator = jQuery("#volunteerRegForm").validate({
rules: {
remote: "/sh_sbzyz/volunteerRegAction.do?methodName=login"
},
submitHandler: function(form) {
jQuery.blockUI();
jQuery(form).ajaxSubmit({
success: function(response) {
jQuery.unblockUI();
if (response=="1") {
alert(ERR_MSG[2]);
changeVerifycode();
return;
} else if (response=="2") {
alert(ERR_MSG[3]);
changeVerifycode();
return;
}else if(response=="3") {
alert(ERR_MSG[4]);
changeVerifycode();
return;
}
self.location = "/sh_sbzyz/volunteerPersonAction.do?methodName=person_req";
//var results=response.split("||")
//jQuery("#name").text(results[0]);
//jQuery("#zmdId_name").html(results[1]);
//hide(jQuery("#unloginUserArea"));
//show(jQuery("#loginUserArea"));
}
});
}
});
jQuery("#logout").click(function() {
jQuery.blockUI(); 
jQuery.ajax({
url: "/sh_sbzyz/volunteerRegAction.do?methodName=logout&t="+new Date().getTime(),
success: function(response) {
jQuery.unblockUI();
if (!response) {
changeVerifycode();
//jQuery("#errorContainer").text("");
return;
}
}
});
});
});
function init(data) {
if (!isEmpty(jQuery("#name").html())) {
hide(jQuery("#unloginUserArea"));
show(jQuery("#loginUserArea"));
}else{
show(jQuery("#verTypeArea"));
}
}
function bindLogin(){
jQuery("#verifyCode_i").keydown(function() {
var e = arguments[0]||window.event;
var ck = e.charCode||e.keyCode;
if(ck==13){
jQuery("#login").trigger("click");
}
});
jQuery("#login").click(function() {
if (jQuery("#userName_i").val().length==0|| jQuery("#password_i").val().length==0) {
alert(ERR_MSG[0])
if(jQuery("#userName_i").val().length==0){jQuery("#userName_i").select();return;}
if(jQuery("#password_i").val().length==0){jQuery("#password_i").select();return;}
}
if (jQuery("#verifyCode_i").val().length==0){
jQuery("#verifyCode_i").select();
alert(ERR_MSG[1])
return;
}
jQuery("#userName").val(jQuery("#userName_i").val());
jQuery("#verifyCode").val(jQuery("#verifyCode_i").val());
jQuery("#password").val(hex_md5(jQuery("#verifyCode_i").val())+hex_md5(jQuery("#password_i").val()));
jQuery("#volunteerRegForm").submit();
});
jQuery("#changeVerifyImage").click(function() {
return changeVerifycode();
});
jQuery("#verifyImage").click(function() {
return changeVerifycode();
});
jQuery("#goForgot").click(function() {
window.open('page/volunteer_forgot'+jQuery("#verType").val()+'.html', '_blank', 'height=400, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
return;
});
}
function changeVerifycode(){
var url = "/sh_sbzyz/volunteerRegAction.do?methodName=verifyImage&t=";
jQuery("#verifyImage").attr("src",url+new Date().getTime());
}

