(function(){window.common_validate=function(opt,notSendHttp){if($(this).is(":hidden")){notSendHttp();return true}var phone=/^1[3|4|5|8][0-9]\d{8}$/;var email=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;var yahooEmail=/(@yahoo.com.cn)|(@yahoo.cn)/;var strHtml="";$(this).nextAll().filter("[validate]").remove();$(this).siblings("img.validate_loading").remove();if(opt.empty&&$.trim(this.value)==""){strHtml='
";error_ouput(this,"empty",opt,strHtml);if(($(this).css("borderWidth")=="0px"||$(this).css("borderWidth")=="")&&($(this).is("input:text")||$(this).is("textarea"))){$(this).parent().addClass("input_border_red")}else{$(this).addClass("input_border_red")}var tobj=this;setTimeout(function(){},100);return false}if(opt.express){var arr=opt.express;for(var i=0;i";error_ouput(this,"express"+i,opt,strHtml);if(($(this).css("borderWidth")=="0px"||$(this).css("borderWidth")=="")&&($(this).is("input:text")||$(this).is("textarea"))){$(this).parent().addClass("input_border_red")}else{$(this).addClass("input_border_red")}var tobj=this;if($(tobj).is("input:text")){setTimeout(function(){},100)}return false}}}if(opt.phone&&(!phone.test(this.value.replace(/\s/g,""))&&this.value!="")){strHtml='
";error_ouput(this,"phone",opt,strHtml);if(($(this).css("borderWidth")=="0px"||$(this).css("borderWidth")=="")&&($(this).is("input:text")||$(this).is("textarea"))){$(this).parent().addClass("input_border_red")}else{$(this).addClass("input_border_red")}var tobj=this;setTimeout(function(){tobj.focus();tobj.select()},100)}else if(opt.email&&(!email.test(this.value)&&this.value!="")){strHtml='
";error_ouput(this,"email",opt,strHtml);if(($(this).css("borderWidth")=="0px"||$(this).css("borderWidth")=="")&&($(this).is("input:text")||$(this).is("textarea"))){$(this).parent().addClass("input_border_red")}else{$(this).addClass("input_border_red")}var tobj=this;setTimeout(function(){tobj.focus();tobj.select()},100)}else if(opt.email&&(yahooEmail.test(this.value)&&this.value!="")){strHtml='
";error_ouput(this,"email",opt,strHtml);if(($(this).css("borderWidth")=="0px"||$(this).css("borderWidth")=="")&&($(this).is("input:text")||$(this).is("textarea"))){$(this).parent().addClass("input_border_red")}else{$(this).addClass("input_border_red")}var tobj=this;setTimeout(function(){tobj.focus();tobj.select()},100)}else{if(opt.noSuccess){return true}var loop=function(_this,opt){notSendHttp&¬SendHttp();if(_this.value==""){if(($(_this).css("borderWidth")=="0px"||$(_this).css("borderWidth")=="")&&($(_this).is("input:text")||$(_this).is("textarea"))){$(_this).parent().removeClass("input_border_red")}else{$(_this).removeClass("input_border_red")}return true}$(_this).nextAll("[validate]").remove();if(($(_this).css("borderWidth")=="0px"||$(_this).css("borderWidth")=="")&&($(_this).is("input:text")||$(_this).is("textarea"))){$(_this).parent().removeClass("input_border_red")}else{$(_this).removeClass("input_border_red")}return true};var callback=opt.callback;if(callback){var _this=this;$(_this).parent().find(":last").after("");callback.call(_this,function(bl,msg){if(bl){$(_this).siblings("img.validate_loading").remove();loop(_this,opt)}else{error_tip(_this,msg)}});return 1}else{return loop(this,opt)}}};function error_ouput(tobj,v1,opt,strHtml){var obj=$(tobj).nextAll().filter("[validate='"+v1+"']");var strObj=$(strHtml);var p=$(tobj).position();if(obj.length==0){$(tobj).after(strObj)}else{obj.replaceWith(strObj)}strObj.hide().fadeIn(200);var left=p.left+$(tobj).outerWidth(true)+10;var top=p.top-(strObj.outerHeight()-$(tobj).outerHeight())/2;if(($(tobj).css("borderWidth")=="0px"||$(tobj).css("borderWidth")=="")&&($(tobj).is("input:text")||$(tobj).is("textarea"))){var left=p.left+$(tobj).parent().outerWidth()+5}if(opt.align=="left"||left>$(window).width()-strObj.outerWidth(true)){strObj.removeClass("top").addClass("left");left=p.left-strObj.outerWidth(true)-10}else if(opt.align=="top"){top=p.top-strObj.outerHeight()-15;left=p.left-(strObj.outerWidth(true)-$(tobj).outerWidth(true))/2;strObj.removeClass("left").addClass("top")}strObj.css({left:left+(opt.x||0),top:top+(opt.y||0)})}window.email_auto=function(selector){var elt=$(selector);var strHtml='
'+' "+"
";var lc="#login_autoComplete";var autoComplete,autoLi;if($(lc).length==0){$("body").append(strHtml);$(lc).data("elt",elt);autoComplete=$("#login_autoComplete");autoLi=autoComplete.find("li:not(.login_auto_title)");autoLi.mouseover(function(){$(this).siblings().filter(".hover").removeClass("hover");$(this).addClass("hover")}).mouseout(function(){$(this).removeClass("hover")}).mousedown(function(){$(lc).data("elt").val($(this).text()).change();$(this).parent().parent().hide()})}else{$(lc).data("elt",elt);autoComplete=$("#login_autoComplete");autoLi=autoComplete.find("li:not(.login_auto_title)")}$(lc).css("width",elt.outerWidth()-1);elt.keyup(function(e){if(/13|38|40|116/.test(e.keyCode)||this.value==""){return false}var username=this.value;if(username.indexOf("@")==-1){autoComplete.hide();return false}autoLi.each(function(){this.innerHTML=username.replace(/\@+.*/,"")+$(this).attr("hz");if(this.innerHTML.indexOf(username)>=0){$(this).show()}else{$(this).hide()}}).filter(".hover").removeClass("hover");autoComplete.show().css({left:$(this).offset().left,top:$(this).offset().top+$(this).outerHeight(true)-1});if(autoLi.filter(":visible").length==0){autoComplete.hide()}else{autoLi.filter(":visible").eq(0).addClass("hover")}}).change(function(){$("#login_autoComplete").hide()}).keydown(function(e){if(e.keyCode==38){autoLi.filter(".hover").prev().not(".login_auto_title").addClass("hover").next().removeClass("hover")}else if(e.keyCode==40){autoLi.filter(".hover").next().addClass("hover").prev().removeClass("hover")}else if(e.keyCode==13){autoLi.filter(".hover").mousedown()}}).focus(function(){$("#login_autoComplete").data("elt",$(this))})};function error_tip(elt,msg){$(elt).siblings("img.validate_loading").remove();var _this=$(elt);_this.nextAll().filter("[validate]").remove();strHtml='
";error_ouput(_this,"msg",{},strHtml);if(($(_this).css("borderWidth")=="0px"||$(_this).css("borderWidth")=="")&&($(_this).is("input:text")||$(_this).is("textarea"))){_this.parent().addClass("input_border_red")}else{_this.addClass("input_border_red")}if(!_this.data("bindClick")){_this.data("bindClick",true);_this.bind("click",function(){$(this).nextAll("[validate]").fadeOut(200)})}var tobj=_this[0];var tag=tobj.tagName.toLowerCase();if(tag=="input"||tag=="textarea"){setTimeout(function(){tobj.focus();tobj.select()},100)}}UI.extend.validate=function(option){var opt={active:null,phone:null,email:null,empty:null,length:null,pass:""};$.extend(opt,option);if(opt.active||opt.active===""){$(this).focus(function(){var posSlt=null;if(opt.position&&/^[^\:]+/.test(opt.position)){posSlt=$(opt.position+" .zhfs_state:visible")}else{posSlt=$(this).nextAll().filter(".zhfs_state:visible")}if(posSlt.length>0){return}var clsName=opt.className?opt.className:"";if(opt.active){var strHtml='";error_ouput(this,"active",opt,strHtml)}$(this).addClass("login_input_color")}).blur(function(){if(opt.position&&/^[^\:]+/.test(opt.position)){$(opt.position+" [validate='active']").hide()}else{$(this).nextAll().filter("[validate='active']").hide()}$(this).removeClass("login_input_color")})}if(opt.length){var lengthValidate={text:opt.length.text,func:function(){var len=opt.length;if(len.min!=undefined&&this.value.lengthlen.max){return false}return true}};if(!opt.express){opt.express=[lengthValidate]}else{opt.express.push(lengthValidate)}}if(opt.phone||opt.empty||opt.email||opt.express){$(this).click(function(){if(!this.ischange){$(this).not("input:text").next("[validate]").fadeOut(200)}this.ischange=undefined});$(this).change(function(){var me=this;setTimeout(function(){me.ischange=true;var newObj={};for(var n in opt){newObj[n]=opt[n]}common_validate.call(me,newObj)})});if(opt.email){email_auto(this)}}};window.error_tip=error_tip})(jQuery);