function loginJV(callback){
   var aaa = this;
   this.init = function(){
   	   aaa.addnotice();
   	   aaa.addm();
   	   aaa.check();
   	   aaa.unchange();
   	   return aaa;
   }
   this.addnotice = function(){

       $("input[type='text']").each(function(){
       		$(this)
       		.focus(function(){
       			if($(this).val() == $(this).attr('notice')){
       				$(this).val("");
       			}
       		})
       		.blur(function(){
       			if($(this).val() == $(this).attr('notice') || $.trim($(this).val()) == ""){
       				$(this).val($(this).attr('notice'));
       			}
       		});
       });   
   }
   this.cleannotice = function(){
       $("input[type='text']").each(function(){
       		if($(this).val() == $(this).attr('notice')){
       			$(this).val("");
       		}
       });    	
   }
   this.unchange = function(){
       $(".select").bind('change',function(){
       });    	
   }
   
   this.addm = function(){
     //追加自定义验证方法
       //字母数字
       jQuery.validator.addMethod("alnum", function(value, element) {
          return this.optional(element) || /^[a-zA-Z0-9]+$/.test(value);
       }, "只能包括英文字母和数字");
   }
   this.check = function(){
   	$('#loginForm').submit(function(){
		aaa.cleannotice();
	});
	 function showErrors(){  
		var t = this;
		for ( var i = 0; this.errorList[i]; i++ ) {
			var error = this.errorList[i];
  		var elename = this.idOrName(error.element);
			// 错误信息div
		  var errdiv = $('div[htmlfor='+ elename + ']');
			var errimg = $('img[htmlfor='+ elename + ']');
	   if(errdiv.length == 0){ // 没有div则创建
			  errdiv = $('<div class="error" style="padding:5px;"> </div>');
        errdiv.attr({"for":  this.idOrName(error.element), generated: true}).addClass(this.settings.errorClass);
				//errdiv.appendTo($('body'));
				errdiv.insertAfter(error.element);
			} 
     	errdiv.html(error.message);
   	 if(errimg.length == 0){ // 没有img则创建
				errimg = $('<img  src="/images/unchecked.png">')
				errimg.attr({"for":  this.idOrName(error.element), generated: true});
				errimg.insertAfter(error.element);
			}
			else
			  errimg.attr('src','/images/unchecked.png');
			// 鼠标放到图片显示错误
			$(errimg).hover(function(e){
 		  	/*$('div[htmlfor="'+ $(this).attr('htmlfor') + '"]').css({left:(e.pageX+20)+'px',top:e.pageY+'px'}); // 显示在鼠标位置偏移20的位置
      	$('div[htmlfor="'+ $(this).attr('htmlfor') + '"]').fadeIn(200); */
	      $(errimg).qtip({
          content:{text:$('div[htmlfor="'+ $(this).attr('htmlfor') + '"]').html(),
              title:{text:'请您注意!'} 
            },
          position: {
            my: 'left bottom',  // Position my top left...
            at: 'right center', // at the bottom right of...
            target:'mouse', // my target
            adjust: {
              x: 10
            }
         },
         style: {
           classes: 'ui-tooltip-shadow'
         },
         show: {
          delay: 1000,
          solo: true
         }
        }); 
      },
			function(){
			  //$('div[htmlfor="'+ $(this).attr('htmlfor') + '"]').fadeOut(200);
			});
      // 鼠标放到控件上显示错误
			$(error.element).hover(function(e){   
 		  	 /*$('div[htmlfor="'+ t.idOrName(this) + '"]').css({left:(e.pageX+20)+'px',top:e.pageY+'px'}); // 显示在鼠标位置偏移20的位置
	       $('div[htmlfor="'+ t.idOrName(this) + '"]').fadeIn(200);*/
         $(error.element).qtip({
          content:{text:$('div[htmlfor="'+ t.idOrName(this) + '"]').html() ,
            title:{text:'请您注意!'} 
            },
          position: {
            my: 'left bottom',   
            at: 'right center',  
            target:'mouse',  
            adjust: {
              x: 10
            }
         },
         style: {
           classes: 'ui-tooltip-shadow'
         },
         show: {
          delay: 1000,
          solo: true
         }
        }); 
			},
			function(){
			  //$('div[htmlfor="'+ t.idOrName(this) + '"]').fadeOut(200);
			});
	  }
		// 校验成功提示
		for ( var i = 0; this.successList[i]; i++ ) {
				$('div[htmlfor="'+ this.idOrName(this.successList[i]) + '"]').html('已通过验证!');
				$('img[htmlfor='+ this.idOrName(this.successList[i]) + ']').attr('src','/images/checked.png').hover(function(e){// 鼠标放到图片显示错误
				$('div[htmlfor="'+ $(this).attr('htmlfor') + '"]').css({left:(e.pageX+20)+'px',top:e.pageY+'px'}); // 显示在鼠标位置偏移20的位置
				$('div[htmlfor="'+ $(this).attr('htmlfor') + '"]').fadeIn(200);
			},
			function(){
				$('div[htmlfor="'+ $(this).attr('htmlfor') + '"]').fadeOut(200);
			});
		}
  } 
	$("#loginForm").validate({
    showErrors: showErrors, 
	   rules: {
	     fno:{
		     required:true,
		     alnum:true,
		     remote:{
           url:'/index.jsp?menuID=1&cmdID=30',
		       data: {
            fno:function() {
             return $("#fno").val();
            }
           }
         },	    
         rangelength:[4,10]
			 },
		   fkey: {
	       required:true,
	       alnum:true,
		     remote:{
           url:'/index.jsp?menuID=1&cmdID=31',
		       data: {
             fno:function() {
             return $("#fno").val();
             },
             fkey:function() {
             return $("#fkey").val();
            }
           }
         },	       
	       rangelength:[5,10]
	     }
     },
	   messages: {
	     fno: {
	       required: "只能包括英文字母、数字",
	       remote:"该帐号不正确，请换一个！",
         alnum:"只能是英文字母或数字",
	       rangelength: jQuery.format("长度请控制在{0} ~ {1}") 
	     },
	     fkey:{
	       required: "请输入英文字母或数字",
	       remote:"该密码不正确，请换一个！",
	       alnum:"只能是英文字母或数字",
	       rangelength: jQuery.format("长度请控制在{0} ~ {1}")
	     }
      },
	   submitHandler: function(form) {
				form.submit();
     }
     });
   }
}

