﻿jQuery.fn.ImageAutoSize = function(width){
    $("img",this).each(function()
    {
        var image = $(this);
        if(image.width()>width)
        {
            image.width(width);
            image.height(width/image.width()*image.height());
        }
    });
}
jQuery.fn.mDefault = function() {
		var elements = this;
		var args = arguments;
		var c = 0;
		
		return(
			elements.each(function() {				
				var el = $(this);
				var def = args[c++];

				el.val(def).focus(function() {
					if(el.val() == def) {
						el.val("");
					}
					el.blur(function() {
						if(el.val() == "") {
							el.val(def);
						}
					});
				});
				
			})
		);
	}
jQuery.fn.mTextCounter = function(max, options) {
	options = $.extend({
		counterDisplayElement: "span",					
		counterDisplayClass: "mTextCounterDisplay",	
		addLineBreak: true								
	}, options);

	$(this).each(function(i) {
		MAYI.util.UpdateCounter(this, max, options, i);
		$(this).keyup(function() {
			MAYI.util.UpdateCounter(this, max, options, i);
			return this;
		});
	});
	return this;
};
String.prototype.Trim = function(){  
return this.replace(/(^\s*)|(\s*$)/g, "");  
}  
String.prototype.LTrim = function()  {  
return this.replace(/(^\s*)/g, "");  
}  
String.prototype.RTrim = function()  {  
return this.replace(/(\s*$)/g, "");  
}  
String.prototype.Length = function() { 
  var   j   =   0;   
  for   (var   i=0;   i<this.length;   i++){   
          if   (this.substr(i,1).charCodeAt(0)>255){
             j   =   j   +   2;   
          }else{ 
            j++ 
          }   
   }   
  return j;
}
String.prototype.isDate=function() { 
    var iaMonthDays = [31,28,31,30,31,30,31,31,30,31,30,31]
    var iaDate = new Array(3)
    var year, month, day
    if (arguments.length != 1) return false
    if(this.length<8||this.length>10) return false
    year = parseFloat(this.substr(0,4))
    if(this.length==10){
    month = parseFloat(this.substr(5,2))
    day=parseFloat(this.substr(8,2))
    }
    else{
    month = parseFloat(this.substr(5,1))
    day=parseFloat(this.substr(7,1))
    }

    if (year < 1900 || year > 2100) return false
    if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) iaMonthDays[1]=29;
    if (month < 1 || month > 12) return false
    if (day < 1 || day > iaMonthDays[month - 1]) return false
    return true
}

if (typeof MAYI == "undefined" || !MAYI) {
    var MAYI = {};
}
MAYI.namespace = function() {
    var a=arguments, o=null, i, j, d;
    for (i=0; i<a.length; i=i+1) {
        d=a[i].split(".");
        o=MAYI;
        for (j=(d[0] == "MAYI") ? 1 : 0; j<d.length; j=j+1) {
            o[d[j]]=o[d[j]] || {};
            o=o[d[j]];
        }
    }

    return o;
};
MAYI.namespace("util","widget","app","cst");
MAYI.cst={
          MSG:{
               LOADING_HEAD:"正在进行中, 请稍候...",
               LOADING_BODY:'<img src="http://mui.mayi.com/images/ico/loading_2.gif"/>',
               BUTTON_CONFIRM:"确认",
               BUTTON_CANCEL:"取消"
            
          },
          CONFIG:{
          MAYI_HOST:"http://www.mayi.com/",
          PEOPLE_HOST:"http://www.mayi.com/people/",
          USERLOGO_HOST:"http://img1.mayi.com/user/",
          MUI_HOST:"http://mui.mayi.com/",
          MAYI_DOMAIN:"mayi.com"
          }
}
MAYI.widget.MessageBox=function(config){
           //是否已初始化过对话框
            var MessageOninit = false;
            //记录body滚动条的x,y偏移量;显示内容的元素对象，显示内容元素对象的父对象
            var MessageBox_scrolltop,MessageBox_scrollleft,Messagebox_AC,MessageBox_PC;
            //对话框对象，对话框宽度，对话框高度
            var MessageBox_win,MessageBox_width,MessageBox_height;
            //对话框是否处于移动状态
            var MessageBox_Moving = false;
            var option=config;
            var IsEnabled=false;
            //显示模式提示框
            this.show=function()
            {
              if ($(document).ready) {
                    var container,iframe,enabled,enabledframe;
                    var width =400;

                    MessageBox_scrolltop =0;
                    MessageBox_scrollleft =0;
                    if(option.enabled){
                       IsEnabled=option.enabled;
                    }
                    if(!MessageOninit)
                    {
                       CreateContainer(option);
                       
                       MessageOninit = true;
                       $(window).resize(function(){
                            SetStyle(option);
                            SetEnabledStyle();
                       
                       });
                       $(window).scroll(function(e){
                            MessageBox_scrolltop =document.documentElement.scrollTop;
                            MessageBox_scrollleft = document.documentElement.scrollLeft;
                            SetEnabledStyle();
                       });
                       MessageBox_win =  $('#'+option.control+'_win');
                       document.onmouseup = handleMouseUp;
                       
                       
                    }
                    
                    
                    if(option.width)
                    width = parseInt(option.width);
                    MessageBox_width = width;
                    Messagebox_AC = $('#'+option.control);
                    MessageBox_PC = Messagebox_AC.parent();
                    Messagebox_AC.css('display','');
                    enabled='<div id="messagebox_enabled" style="background-color: lightgrey;width:100%;height:100%;position:absolute;z-index:99998;"></div>'
                    enabledframe='<iframe id="messagebox_enabledframe"  frameborder=0 scrolling=no style="position:absolute; width:100%;height:100%;visibility:inherit; top:0px; left:0px;z-index:99997; "></iframe>';
                    $('#messagebox_enabledframe').remove();
                    $('#messagebox_enabled').remove();
                    MessageBox_win.append(Messagebox_AC);
                     var height=$('#'+option.control+'_win').height();
                    MessageBox_height=height;
                    SetStyle(option);
                    if($.browser.msie) $(document.body).append(enabledframe);
                    $(document.body).append(enabled);
                    SetEnabledStyle();
                    $('#'+option.control+'_win').fadeIn("slow");
                     var h=(document.documentElement.scrollTop || document.body.scrollTop) + Math.round(30 * (document.documentElement.clientHeight) / 100)+'px';
                     $('#'+option.control+'_win').css("top",h);
                      $(window).scroll(function(){
                      var h=(document.documentElement.scrollTop || document.body.scrollTop) + Math.round(30 * (document.documentElement.clientHeight) / 100) + 'px';
                      $('#'+option.control+'_win').css("top",h);
                      });
                 }
                    //创建对话框容器
                    function CreateContainer(option)
                    {
                        var html;
                        html='<div id="'+option.control+'_win" class="mDialog" style="position:absolute;z-index:99999;"></div>';
                        if(option.parent)
                        {
                            $('#' + option.parent).append(html);
                        }
                        else
                        {
                            $(document.body).append(html);
                        }

                    }
                    
                    //设置显示时背景式样
                    function SetEnabledStyle()
                    {
                        var de,w,h,css,css1,region;
                        region = GetDocumentRegion();
                        css ={
                        left: MessageBox_scrollleft+'px',top: MessageBox_scrolltop +'px'}
                        css1 ={width:region.width+"px",height:region.height+"px",
                        left: MessageBox_scrollleft+'px',top: MessageBox_scrolltop +'px'}
                        GetOpacity(css);
                        GetOpacity(css1);
                        $("#messagebox_enabled").css(css);
                        $("#messagebox_enabledframe").css(css1);

                    }
                    
                    //设置透明式样
                    function GetOpacity(css)
                    {
                       var ie='0',oth='0';
                       if(IsEnabled){
                           ie='30';
                           oth='0.3';
                       }
                            if($.browser.msie)
                            {
                                css.filter= 'progid:DXImageTransform.Microsoft.Alpha(opacity='+ie+')';
                            }
                            else
                            {
                                css.opacity= oth;
                            }
                    }
                    
                    //设置对话框试样
                    function SetStyle(option)
                    {
                        var region,css;
                        region = GetDocumentRegion();
                        css ={width:MessageBox_width+'px',
                        left: ((region.width - MessageBox_width)/2)+'px'}
                        if(region.height < MessageBox_height )//如果body显示的高度小于对话框高度
                        {
                            css.top=10+'px';
                        }
                        else
                        {
                           if ($.browser.msie){
                            css.top=(region.height/2)+'px'
                            }else{
                            css.top=((region.height-MessageBox_height)/2)+'px'
                            }
                        }
                        $('#'+option.control+'_win').css(css);
                      
                       
                    }
                    
                    var down_x,down_y,cx,cy;
                    function handleMouseDown(e)
                    {
                            var evt = e || event;
                          
                         down_x=evt.clientX;
                         down_y = evt.clientY;
                         cx =(parseInt(MessageBox_win.css('left'))|0);
                         cy = (parseInt(MessageBox_win.css('top'))|0)
                         document.documentElement.onselectstart = function(){return false};
                         document.documentElement.ondrag = function(){return false};
                       
                    }
                   
                    function GetDocumentRegion()
                    {
                        var w,h,de;
                        de = document.documentElement;
                        w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
                        h = self.innerHeight || (de&&de.clientHeight)|| document.body.clientHeight;
                        return {height:h,width:w};
                    }
                    
                    
                    function handleMouseUp()
                    {
                        document.onmousemove = null;
                    }
                this.hide=function()
                {
                    if(MessageOninit)
                    {
                       $('#'+option.control+'_win').hide();
                       $('#messagebox_enabled').remove();
                       $('#messagebox_enabledframe').remove();
                      Messagebox_AC.css('display','none');
                       MessageBox_PC.append(Messagebox_AC);
                        
                    }
                     document.documentElement.onselectstart = null;
                         document.documentElement.ondrag = null;
                }
                 
            }
}

MAYI.util.Dom=function(obj){
       return $("#"+obj)[0];
}
MAYI.util.UpdateCounter=function updateCounter(input, max, options, index) {
	var currentLength = 0;
	var val = $(input).val();
	if(val) {
		currentLength = val.Length();
	}
	if(currentLength > max) {
		$(input).val(val.substring(0, max));
	} else {
		var charLeft = max - currentLength;
		var counterDisplay = options.counterDisplayElement + "." + options.counterDisplayClass + ":eq("+index+")";
		var createNew = $(counterDisplay).length == 0;
		if(createNew) {
			var element = document.createElement(options.counterDisplayElement);
			if(options.counterDisplayElement == 'input') {
				$(element).val(charLeft.toString());
			} else {
				$(element).html(charLeft.toString());
			}
			$(element).addClass(options.counterDisplayClass).insertAfter($(input));
			if(options.addLineBreak) {
				$(input).after("<br />");
			}
		} else {
			if(options.counterDisplayElement == 'input') {
				$(counterDisplay).val(charLeft.toString());
			} else {
				$(counterDisplay).html(charLeft.toString());
			}
		}
		
	}
}
MAYI.widget.Container=function(option){
   var w=option.width+"px";
   var p=-parseInt(option.width) /2+"px";
        content_ac = $('#'+option.control);
        content_ac.addClass("panel");
        content_ac.append("<div class=\"mDialogClose\"> </div>");
         var dg=new MAYI.widget.MessageBox(option);

   this.show=function(){
	      dg.show();
        $('#'+option.control+' .mDialogClose').click(function(){
           dg.hide();
           });
     }
    this.setBody=function(str){
     $('#'+option.control+" .bd")[0].innerHTML=str;
    }
    this.hide=function(){
	  dg.hide();
    }
}

MAYI.widget.Dialog=function(con,wh){
	$("#"+con).css("display","none");
	if(wh!=undefined){
	 try{
	 wh=wh.replace("px","");
	 }catch(e){}
	}else{
	 wh="500";
	}
	var option={control:con,width:wh,enabled:false};
    var dg=new MAYI.widget.Container(option);
    return dg;
}

MAYI.widget.Dialog.MsgBox=function(msg,state){
	    $("body").prepend('<div class="panel" id="MsgDialog"><div class="bd"><p>'+msg+'</p></div><div class="mDialogClose"> </div><div class="ft tRight"><input type="button" class="submit" value="确认" /></div></div>')
	    var sc="tip";
	    if(state) sc=state;
	    sc+=" clearfix";
	    $("#MsgDialog p").addClass(sc);
	    var dg=new MAYI.widget.MessageBox({control:"MsgDialog",width:"300"});
        dg.show();
        this.agree=$("#MsgDialog .submit");
        this.agree.click(function(){
            dg.hide();
        });
         $('#MsgDialog .mDialogClose').click(function(){
               dg.hide();
         });
	this.show=function(){
			dg.show()
	}
    return this;
}
MAYI.widget.Dialog.Loading=function(){
       	 $("body").prepend('<div class="panel" id="mDialogLoading1"><div class="bd"><img src="http://mui.mayi.com/lib/images/ico_loading.gif" style="width:15px"/>&nbsp;正在进行中,请稍后...</div></div>')
         var dg=new MAYI.widget.MessageBox({control:"mDialogLoading1",width:"300",enabled:true});
        dg.show();
	   this.show=function(){
	     dg.show();
	   }
	   this.hide=function(){
	    dg.hide();
	   }
	   return this;
}
//cannel:true|false,是否显示取消按钮
MAYI.widget.Dialog.Confirm=function(msg,cancel){
    var c="#mDialogConfirm";
	$("body").prepend('<div id="mDialogConfirm"  class="panel"><div class="bd"><p>'+msg+'</p></div><div class="mDialogClose"> </div><div class="ft tRight"><input type="button" class="submit" value="确认" /> <input type="button" style="display:none" class="cancel" value="取消" /></div></div>')
	//$(c).css({"width":"300px","margin-left":"-150px"});
	if(cancel){
		$(c+" .cancel").show();
	}
     var dg=new MAYI.widget.MessageBox({control:"mDialogConfirm",width:"300"});
	this.agree=$(c+" .submit");
    this.cancel=$(c+" .cancel");
    $('#mDialogConfirm .mDialogClose').click(function(){
           dg.hide();
     });
  	this.show=function(){
			dg.show();
	}
	this.hide=function(){
			dg.hide();
	}
	return this;
}
MAYI.util.Xml=function(){

      this.Load=function(str){
              var ns4 = false;
              var ie4 =  false;
              if(window.navigator.userAgent.indexOf("MSIE")>=1){
                  ie4=true;
              }else{
                  ns4=true;
              }
              var xmlDoc;
              if(str.length>0)
              {
                  if(ie4)
                  {
                      xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
                      xmlDoc.async = false;
                      xmlDoc.loadXML(str);

                  }
                  else
                  {
                      Node.prototype.selectNodes=function(xPath)
                      {
                              var xresult=this.evaluate(xPath,this,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);
                              var nod=null,nods=[],k=0;
                              while((nod=xresult.iterateNext())!=null)
                              {
                                nods[k++]=nod;
                              }
                              return nods;
                      }
                      var oParser=new DOMParser();
                      xmlDoc=oParser.parseFromString(str,"text/xml");

                  }
              }
            return xmlDoc;
       }
   
}
MAYI.util.Window=function(url){
   window.open(url,"","width="+screen.availWidth+",height="+screen.availHeight+",modal=yes,top="+screen.availHeight/2+",left="+screen.availWidth/2+",toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes , location=yes , status=yes");
}
MAYI.util.SendMsg=function(un){
    location.href=MAYI.cst.CONFIG.MAYI_HOST+'mail/post?un='+un;
}
MAYI.util.Code=function(){
            this.UrlEncode=function (unzipStr,isCusEncode){
                            if(isCusEncode){
                                var zipArray = new Array();
                                var zipstr = "";
                                var lens = new Array();
                                for(var i=0;i<unzipStr.length;i++){
                                 var ac = unzipStr.charCodeAt(i);
                                 zipstr += ac;
                                 lens = lens.concat(ac.toString().length);
                                } 
                                zipArray = zipArray.concat(zipstr);
                                zipArray = zipArray.concat(lens.join("O"));
                                return zipArray.join("N");
                            }else{
                                var zipstr=""; 
                                var strSpecial="!\"#$%&'()*+,/:;<=>?[]^`{|}~%"; 
                                var tt= "";
                                for(var i=0;i<unzipStr.length;i++){ 
                                    var chr = unzipStr.charAt(i); 
                                    var c=StringToAscii(chr); 
                                    tt += chr+":"+c+"n"; 
                                    if(parseInt("0x"+c) > 0x7f){ 
                                         zipstr+=encodeURI(unzipStr.substr(i,1));
                                    }else{ 
                    
                                         if(chr==" ") 
                                            zipstr+="+"; 
                                         else if(strSpecial.indexOf(chr)!=-1) 
                                            zipstr+="%"+c.toString(16); 
                                         else 
                                            zipstr+=chr; 
                                    } 
                                 } 

                              return zipstr; 
                           }
               }
              this.UrlDecode=function (zipStr,isCusEncode){
                        if(isCusEncode){
                            var zipArray = zipStr.split("N");
                            var zipSrcStr = zipArray[0];
                            var zipLens;
                            if(zipArray[1]){
                                zipLens = zipArray[1].split("O");    
                            }else{
                                zipLens.length = 0;
                            }
                            var uzipStr = "";
                            for(var j=0;j<zipLens.length;j++){
                                var charLen = parseInt(zipLens[j]);
                                uzipStr+= String.fromCharCode(zipSrcStr.substr(0,charLen));
                                zipSrcStr = zipSrcStr.slice(charLen,zipSrcStr.length);
                            }        
                            return uzipStr;
                        }else{
                            var uzipStr=""; 
                            for(var i=0;i<zipStr.length;i++){ 
                                var chr = zipStr.charAt(i); 
                                if(chr == "+"){ 
                                     uzipStr+=" "; 
                                }else if(chr=="%"){ 
                                     var asc = zipStr.substring(i+1,i+3); 
                                     if(parseInt("0x"+asc)>0x7f){ 
                                        try{
                                         uzipStr+=decodeURI("%"+asc.toString()+zipStr.substring(i+3,i+9).toString());
                                         }catch(e){}
                                         i+=8; 
                                     }else{ 
                                         uzipStr+=AsciiToString(parseInt("0x"+asc)); 
                                         i+=2; 
                                     } 
                                }else{ 
                                     uzipStr+= chr; 
                                } 
                            } 
                     return uzipStr;
                        }
              this.EnUnicode=function(str){
                      var a = [], i = 0;
                        for (; i < str.length ;) a[i] = str.charCodeAt(i ++);
                        return "&#" + a.join(";&#") + ";";
              }
              this.DeUniCode=function(str){
                      return str.replace(/&#(x)?([^&]{1,5};)?/g, function (a, b, c) {
                                    return String.fromCharCode(parseInt(c, b ? 16 : 10));
                                });
              }
         }
       function StringToAscii(str){
                return str.charCodeAt(0).toString(16);
            }

      function AsciiToString (asccode){
            return String.fromCharCode(asccode);
        }
        return this;
}
MAYI.widget.Input=function(){
}
//通过XML来查询
MAYI.widget.Input.Taxis=function(){
    var txtObj      = null;  //input控件
    var txtObjDefaultValue = null; //input控制默认值
    var selObj      = null;  //div容器
    var xmlDoc      = null;  //xml数据源
    var pstIdObj    = null;  //选定数据id存放dom
    var pstNameObj  = null;  //选定数据name存放dom
    var selXPath    = null;  //xml路径
    var selAttributeName = null;//显示的内容的节点名称
    var callMethod = null;
    var idIndex = 0;
    var txtIndex = 1;
    var element  =null;
    var ns4 = (document.layers) ? true : false;
    var ie4 = (document.all) ? true : false;
    this.clear=function()
    {
        this.selObj.innerHTML = "";
        this.pstIdObj.value = "";
        this.pstNameObj.value = "";
    }

   this.isExists=function(){
        var s = this.txtObj.value;
        if(s.length>0){
         var root=this.xmlDoc.selectNodes(this.selXPath + "[starts-with(translate(@" + this.selAttributeName + ",'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),'" + s.toUpperCase()  + "')]");
         if(root.length>0){
          return true;
         }
        }
        return false;
   }
   this.onclick=function(el){
     if(list.txtObj!=null&&el.id != list.txtObj.id)
     {
            this.hidden();
     }
   }
   this.onclickDoc=function(el){
       if(el.id==null || el.id == "")
         {
                this.hidden();
                if(this.txtObj.value==""){
                this.txtObj.value=this.txtObjDefaultValue;
                }
         }
         
   }      
   this.moveSelection=function(keycode){
           if(keycode==38){
            if(this.element.offsetTop < this.selObj.scrollTop) {
                    this.selObj.scrollTop = this.element.offsetTop;
                }
                else if(this.element.offsetTop > (this.selObj.scrollTop + this.selObj.offsetHeight)) {
                    this.selObj.scrollTop = (this.element.offsetTop+this.element.offsetHeight) - this.selObj.offsetHeight;
                }

        }else{
          if((this.element.offsetTop+this.element.offsetHeight) > (this.selObj.scrollTop + this.selObj.offsetHeight)) {
                    this.selObj.scrollTop = (this.element.offsetTop+this.element.offsetHeight) - this.selObj.offsetHeight;
                }
                else if((this.element.offsetTop+this.element.offsetHeight) < this.selObj.scrollTop) {
                    this.selObj.scrollTop = this.element.offsetTop;

                }

        }
   }
   this.keydown=function(keycode){
        if(keycode==13&&this.element!=null){
           try
           {
          document.getElementById(this.pstNameObj.id).value=this.element.innerHTML;
          document.getElementById(this.pstIdObj.id).value=this.element.id.substring(this.element.id.indexOf("_")+1,this.element.id.length);
            }
            catch(e){}
          this.txtObj.value=this.element.innerHTML;
          return;
        }
        var v=0;
        var arr=$("#"+this.selObj).children("div");
        if(keycode==38){
           v=-1;
        }else{
           v=1;
        }
        if(this.element!=null){
            for(var count=0;count<arr.length;count++)
            {
               
               if($("#"+arr[count]).children()[0].id==this.element.id){
                  if(arr[count+v]!=null){
                      this.setFocus($("#"+arr[count]+v).children()[0]);
                      return;
                  }
               }
            }
        }
        this.setFocus($("#"+arr[0]).children()[0]);
   }
   this.setFocus=function(el){
     el.style.backgroundColor="#426FD9";
     el.style.color="#fff";
     if(this.element!=null)
      this.loseFocus(this.element);
      this.element=el;
      this.moveSelection();
   }
   this.loseFocus=function(el){
      el.style.backgroundColor="";
      el.style.color="#333"
      this.element=null;
   }
   
   this.show=function(){
    if(this.txtObj.value == this.txtObjDefaultValue){
        this.txtObj.value = "";
      }
    this.selObj.style.display = "";
   }
   
   this.hidden=function(){
        if(this.txtObj.value == ""){
        this.txtObj.value = this.txtObjDefaultValue;
      }
    this.selObj.style.display = "none";
   }
   
    this.init=function()
    {
        var s = this.txtObj.value;
        var code=new MAYI.util.Code();
        var temp =code.UrlEncode(s);
         temp=temp.toUpperCase();
        var w='205px';
        this.selObj.style.height='200px';
        var outHTML = "";
        if(ie4){this.xmlDoc.setProperty("SelectionLanguage","XPath");}
        if(s.length==0 && s!=this.txtObjDefaultValue)
        {
            if(this.xmlDoc)
                var root=this.xmlDoc.selectNodes(this.selXPath);
        }
        else
        {
            if(this.xmlDoc)
                var root=this.xmlDoc.selectNodes(this.selXPath + "[starts-with(translate(@" + this.selAttributeName + ",'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),'" + temp  + "')]");

        }
        if(root&&root.length>10){
          w='190px';
        }
        var Code=new MAYI.util.Code();
        if(ie4)
        {
            for(var i=0;i<root.length;i++)
            {
                
                outHTML += "<a href=\"javascript:void(0)\"><div style='padding-left:2px;line-height:20px;width:"+w+";text-decoration:none;color:#333;' onmouseover='list.setFocus(this)' onmouseout='list.loseFocus(this)' id=\"li_" + root(i).attributes(0).value + "\" onclick='document.getElementById(\"" + this.txtObj.id + "\").value=this.innerText;document.getElementById(\"" + this.pstIdObj.id + "\").value=this.id.substring(this.id.indexOf(\"_\")+1,this.id.length);document.getElementById(\"" + this.pstNameObj.id + "\").value=this.innerText;document.getElementById(\"" + this.selObj.id + "\").style.display=\"none\";" + (this.callMethod == null ? "" : this.callMethod + ";") + "'>" + Code.UrlDecode(root(i).attributes(1).value) + "</div></a>";
            }
        }
        else
        {
            for(var i=0;root&&i<root.length;i++)
            {
                
                outHTML += "<a href=\"javascript:void(0)\"><div style='padding-left:2px;line-height:20px;width:"+w+";text-decoration:none;color:#333;' onmouseover='list.setFocus(this)' onmouseout='list.loseFocus(this)' id=\"li_" + root[i].attributes[this.idIndex].value + "\" onclick='document.getElementById(\"" + this.txtObj.id + "\").value=this.textContent;document.getElementById(\"" + this.pstIdObj.id + "\").value=this.id.substring(this.id.indexOf(\"_\")+1,this.id.length);document.getElementById(\"" + this.pstNameObj.id + "\").value=this.textContent;document.getElementById(\"" + this.selObj.id + "\").style.display=\"none\";" + (this.callMethod == null ? "" : this.callMethod + ";") + "'>" + Code.UrlDecode(root[i].attributes[this.txtIndex].value) + "</div></a>";
                
            }
        }
        if(outHTML == "")
        {
            outHTML = "<br/>";
        }
        i= i==0 ? 1 : i;

        this.selObj.innerHTML = outHTML;
        this.selObj.style.position="absolute";

        this.selObj.style.height = 20 * i > 200 ? 200 : 20 * i;
        
        
        if(root&&root.length<10){
           this.selObj.style.height=root.length*20+'px';
        }

      document.body.onkeydown=function(e){
            try
            {
                var key;
                if (navigator.appName=="Opera"){
                     key=e.which;
                }else{
                   e=e||event;
                   key=e.keyCode;
                } 
               if (key == 38||key==40||key==13){
                     list.keydown(key);
                }
            }
            catch(e){}
         }
      document.body.onclick=function (event){
         try{
              var e=event||window.event;
              var eobj= e.srcElement ? e.srcElement : e.target;
              list.onclickDoc(eobj);
             }
           catch(e){}
        }

    }
}


function sendCameraTip(uid){
     $("#div_loading").html('<img src="http://mui.mayi.com/images/ico/ajax.gif" alt="提交中"/>');
     $.get("/ajax/mail.aspx",{action:'sys_camera',uid:uid},function(res){
                if(res="true"){
                    $("#div_loading")[0].innerHTML = "提醒信息发送成功。";
                }else{
                      $("#div_loading")[0].innerHTML = result;
                  }
     });
}
