﻿var LAOPOCMS_URL="/laopo2_0"; 
var LAOPOCMS_UPLOAD_ACTION="upload.laopo";

String.prototype.trim = function(){var content=this;try{return content.replace(/(^\s*)|(\s*$)/g, ""); }catch(e){}return content;};
String.prototype.leftTrim = function(){try{return this.replace(/(^\s*)/g, ""); }catch(e){}return this;};
String.prototype.rightTrim = function(){try{return this.replace(/(\s*$)/g, ""); }catch(e){}return this;};
String.prototype.endWith=function(str){
	var len=this.length;if(len<str.length)return false;
    var s1=this.substring(len-str.length);
	return s1.toLowerCase()==str.toLowerCase(); 
};
String.prototype.startWith=function(str){
    var len=this.length;if(len<str.length)return false;
    var s1=this.substring(0,str.length); 
	return s1.toLowerCase()==str.toLowerCase();
};
String.prototype.include=function(f){var fs=this.split(",");for(var i=0;i<fs.length;i++)if(fs[i]==f)return true;return false;};
String.prototype.replaceAll=function(o,n){var msg=this;while(msg.indexOf(o)!=-1)msg=msg.replace(o,n);return msg;};
String.prototype.isEmail=function(){return /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/.test(this);};
String.prototype.isPsw=function(){return /^[\w\d+!@#%^&*-\=$()\[\]]{5,20}$/.test(this);};
String.prototype.isAccount=function(){if(/^[\d]+$/.test(this))return false;return /^[\w\d_]{6,20}$/.test(this);};

String.prototype.toInt=function(){return parseInt(this);};
String.prototype.toFloat=function(){return parseFloat(this);};
String.prototype.interpret=function(value) { return value == null ? '' : String(value);};
String.prototype.specialChar={'\b': '\\b','\t': '\\t','\n': '\\n','\f': '\\f','\r': '\\r','\\': '\\\\'};
String.prototype.toArray=function(){return this.split(",");};
String.prototype.getDom=function(){return $L.DOM.getDom(this);};
String.prototype.getLength=function(w){
   var len=this.length*w;
   for(var i=0;i<this.length;i++){
      var c=this.charAt(i);
	  if(!/[\x00-\xff]+/.test(c))len+=parseInt(w*0.5);
   }
   return len;
}; 




String.prototype.hingDisplay=function(type){
	var message=this;  
	var java= " abstract assert boolean break byte case catch char class const " + "continue default do double else enum extends " + "false final finally float for goto if implements import " + "instanceof int interface long native new null " + "package private protected public return " + "short static strictfp super switch synchronized this throw throws true " + "transient try void volatile while ";
	var js=" abstract boolean break this byte case catch char class const continue debugger " + "default delete do double else enum export extends false final finally float " + "for function goto if implements import in instanceof int interface long native " + "new null package private protected public return short static super switch " + "synchronized this throw throws transient true try typeof var void volatile while with ";
	var keys=js;if(type=='java')keys=java; var ks=keys.split(" ");
	var clArray=new Array();var myCode=null;var buff="";var jsCode="";var sBuff="";
	var sTag="<SPAN clsaa=FString>",eTag="</SPAN>";var zhushi="";
	function CodeLine(){
	    clArray.push(this);myCode=this; 
		
	}; 
	function doKeyWord(){
	   if(buff=="")return;
	   if(keys.indexOf(" "+buff+" ")==-1)jsCode+=buff;
	   else jsCode+="<SPAN class=FKeyword>"+buff+"</SPAN>";
	   buff="";
	}
	 
	function parseCode(i){ 
	   var c=message.charAt(i);
	   
	   if(c=='"'||c=="'"){
		  doKeyWord();
	      if(sBuff==""||sBuff.charAt(0)!=c){sBuff+=c;return;} 
		  jsCode+="<SPAN class=FString>"+sBuff+c+"</SPAN>";
		 // if(i<100)alert(sBuff);
		  sBuff="";return;
	   }
	   if(sBuff.length>0){sBuff+=c;return;}
	   
	   
	   if(c=='/'&&zhushi.length==0){
		    var cc=message.substring(i,i+2);
			if(cc=="//"||cc=="/*"){zhushi+=c;return;}
	   }
	   if(zhushi.length>0){
		   if((zhushi.startWith("//")&&c=="\n")||(zhushi.startWith("/*")&&zhushi.endWith("*/"))){ 
		       jsCode+="<SPAN class=FPreprocessor>"+buff+zhushi+c+" </SPAN><BR/>";
			   zhushi="";buff="";return;
		   }
		   if(c=="\n")zhushi+="[BR]";
		   zhushi+=c; 
		   return; 
	   }
	     
	   if(c==" "){ 
		  doKeyWord();
		  jsCode+=$L.SPAN;
	   }else if(c=="{"||c=="}"||c=="("||c==")"||c=="."){
		  doKeyWord();
	      jsCode+="<SPAN class=FSing>"+c+"</SPAN>"; 
	   }else if(c=="="){
	      doKeyWord();
		  jsCode+="<SPAN class=FString>"+c+"</SPAN>"; 
	   }else if(c=="\n"){
	      doKeyWord();
		  jsCode+=c+"<BR/>";
	   }else{
		   buff+=c;
	   }
	} 
	for(var i=0;i<message.length;i++)parseCode(i);
	return jsCode.replaceAll('[BR]','<BR/>');
};
String.prototype.toStore=function(){
   try {
	    var msg=this;
        var store = eval("[" + msg + "]");
        if (store[0]){
			for(var n in store[0]){
			   if(typeof store[0][n]!='string')continue;
			   store[0][n]=store[0][n].replaceAll("/n/n","\n");
			} 
		    return store[0];
		}
    } catch(e){}
    if (!$L.storeDiv) {
        $L.storeDiv = $L.DOM.create("DIV", {},document.body);
        $L.storeDiv.hide();
    }
    $L.storeDiv.innerHTML = "[" + msg + "]";
    var store = eval($L.storeDiv.innerHTML);
	if (store[0]){
		for(var n in store[0]){
		   if(typeof store[0][n]!='string')continue;
		   store[0][n]=store[0][n].replaceAll("/n/n","\n");
		}
	}
    return store[0];
};

Date.prototype.toJSON = function() { 
  return '"' + this.getUTCFullYear() + '-' +
    (this.getUTCMonth() + 1).toPaddedString(2) + '-' +
    this.getUTCDate().toPaddedString(2) + 'T' +
    this.getUTCHours().toPaddedString(2) + ':' +
    this.getUTCMinutes().toPaddedString(2) + ':' +
    this.getUTCSeconds().toPaddedString(2) + 'Z"';
}; 
//RegExp.prototype.match = RegExp.prototype.test; 
//RegExp.escape = function(str) {return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');};
Array.prototype.size=function(){return this.length;};
Array.prototype.add=function(o){return this.push(o);};
Array.prototype.get=function(i){var self=this;return self[i];};
Array.prototype.moveAt=function(index,obj){if(index>this.length-1)index=this.length-1;this.remove(obj);this.insertAt(index,obj);};
Array.prototype.insertAt=function(index,o){var a1=new Array();	var a2=new Array();for(var i=0;i<index;i++){a1.push(this[i]);}for(var i=index;i<this.length;i++){a2.push(this[i]);}a1.push(o);	a1=a1.concat(a2);while(this.length>0)this.remove(this[0]);for(var i=0;i<a1.length;i++)this.push(a1[i]);};
Array.prototype.remove=function(obj){var self=this;for(var i=0;i<this.length;i++){if(self[i]!=obj)continue;if(i==0)this.splice(0,1);else this.splice(i,1);break;}};

function LaopoDom(dom){ 
  /**IE有一个BUG(不稳定因素)  尽量少用this调用  或者穿插使用自定义的this方法***/
    dom.loadPrototype=true;
	function getWidth(){
		var w=0;
		try{ 
			if(dom.style.display=='none')return 0;
			else if(dom.tagName=='BODY')w=$L.getWidth();
			else w=dom.offsetWidth; 
			if(dom.mw)return dom.mw;
		}catch(e){}
		if(!w&&dom.w)w=dom.w;
		return w;
	};
	function getHeight(){
		var h=0;
		try{ 
			if(dom.style.display=='none')return 0;
			else if(dom.tagName=='BODY')h=$L.getHeight();
			else h=parseInt(dom.offsetHeight);
			if(dom.mh)return dom.mh;
	    }catch(e){};
		return h;
    }; 
	function getLeft(){
		var el=dom;var left=0;while(el.offsetParent){left+=el.offsetLeft;el=el.offsetParent;}
		return left;
    }
	function getTop(){
		var el=dom;var top=0;var tempEl=el;var scrollTop=0;
		do{scrollTop+=tempEl.scrollTop; tempEl=tempEl.parentNode;}while(tempEl.tagName!='BODY');
		while(el.offsetParent){top+=el.offsetTop;el=el.offsetParent;}
		return top-scrollTop;
	 };
	 
	 function updateWidth(width){
		    if(width<0)return false;
			try{
			   if(dom.width==width)return false;
			   if(typeof width=='string')dom.style.width=width;
			   else dom.style.width=width+"px";
			   dom.width=width;
			   dom.hasChange=true;
			}catch(e){return false;}
			return true;
	  }
	  function updatHeight(height){
		   if(height<0)return false;
			try{
			   if(dom.height==height)return false;
			   if(typeof height=='string')dom.style.height=height;
			   else dom.style.height=height+"px";
			   dom.height=height;
			   dom.hasChange=true;
			}catch(e){return false;}
			return true;
	   } 
	   function moveTo(left,top){
			dom.style.position='absolute';
			if(left||left==0)dom.style.left=left+"px";
			if(top||top==0)dom.style.top=top+"px";
	   };
	  
	   function display(d,px,py){
			$L.DOM.show(dom);dom.w=getWidth();dom.h=getHeight();
			if(!d)return;
			d=$L.DOM.getDom(d); 
			if(!px)px=0;if(!py)py=0;
			var x=100,y=100;var w=this.w;var h=this.h;
			if(d){x=d.getLeft();y=d.getTop()+d.getHeight();}
			if((x+w)>$L.getWidth())x=$L.getWidth()-w-20;
			moveTo(x-px,y-py); 
			dom.hasChange=true;
			
	   };  
	   function setClass(className){dom.className=className;};
	   
	   
	  dom.setWidth=function(width){return updateWidth(width);};
	  dom.setHeight=function(height){updatHeight(height);};
	  dom.setSize=function(w,h){var rw=updateWidth(w);var rh=updatHeight(h);return rw||rh;};
	  dom.setText=function(text){if(!text)text=$L.SPAN;dom.innerHTML=text;};
	  dom.setClass=function(className){dom.className=className;};
	   
	dom.over=function(el,px,py){
	   el=$L.DOM.getDom(el);
	    if(!$L.isIE6&&!$L.isIE7)
	          document.body.appendChild(el);
	   dom.onmouseover=function(){
	       el.display();  
		   el.moveTo(dom.getLeft()-px,dom.getTop()-py);
		   var chs=el.childNodes;
		   var overId="over-"+el.getId();
		   $L.Event.addEvent("mousemove",overId,function(){
		        var w=el.getWidth();  
			    var h=el.getHeight();  
				if(event.clientX-el.getLeft()<0){el.hide();$L.Event.addEvent("mousemove",overId,function(){});return;}
				if(event.clientX-el.getLeft()>w){el.hide();$L.Event.addEvent("mousemove",overId,function(){});return;}
				if(event.clientY-el.getTop()<0){el.hide();$L.Event.addEvent("mousemove",overId,function(){});return;}
				if(event.clientY-el.getTop()>h){el.hide();$L.Event.addEvent("mousemove",overId,function(){});return;}
		   });
	   }; 
	};
	dom.moveTo=function(left,top){moveTo(left,top);};
	dom.getWidth=function(){return getWidth();};
	dom.getHeight=function(){return getHeight();};
	dom.getLeft=function(){return getLeft();};
	dom.getTop=function(){return getTop();};
	dom.getDom=function(){return dom;};
    dom.setPosition=function(type){if(!type)type='relative';this.style.position=type;};
	dom.getId=function(){if(!dom.id)dom.id="LAOPO-"+$L.getNumber();return dom.id;};
	dom.isFirst=function(){var ns=dom.parentNode.childNodes;return ns[0]==dom;}; 
	dom.add=function(el){el=$L.DOM.getDom(el);dom.appendChild(el);}; 
	dom.setSrc=function(src){ 
		if(!dom.frame)dom.frame=$L.DOM.create("IFRAME",{width:'100%',height:'100%',scrolling:'no','frameBorder':'0'},dom);
		dom.frame.src=src; 
	 };
	 dom.setBackground=function(url,config){ 
		 if(/^#/.test(url)){dom.style.background="none";dom.style.backgroundColor=url;return;}
		 url="url("+url+")";dom.style.backgroundImage=url;if(!config)config=" 0px 0px";
		 if($L.isFirefox||$L.isChrome){
		   config=config.trim();
		   if(!/px/.test(config)){config=config.replace(" ","px ");config+="px";}
		 } 
		 dom.style.backgroundPosition=config;
	  };
	  dom.setBg=dom.setBackground;
	  dom.setBorder=function(b,style){
		   if(style)dom.style.border=style;
		   if(!/s/.test(b))dom.style.borderTop="none";
		   if(!/x/.test(b))dom.style.borderBottom="none";
		   if(!/z/.test(b))dom.style.borderLeft="none";
		   if(!/y/.test(b))dom.style.borderRight="none";
	  };
	  dom.setBgColor=function(bgColor){dom.style.backgroundColor=bgColor;};
	  
	  
	  dom.setImg=function(src,w,h){
		  var image=new $L.Image(dom);
		  if(dom.delayLayout)dom.afterLayout=function(){image.setSrc(src);};
		  else image.setSrc(src);
		  
		  return image;
	  };
	  dom.slideToY=function(start,end,l){
			 var time=10;var y=-start*l;
			 var len=Math.abs(start-end)*l;
			 var speed=parseInt(len/10); 
		     new $L.SetInterval(20,function(){dom.moveTo(0,y);},function(){
				  if(start<end)y-=speed;
				  else y+=speed;
				  time--;
				  if(time<1)y=-end*l;
				  return time<1;
			 });
	  };
	  dom.slideToX=function(start,end,l){
			 var time=10;var x=-start*l;
			 var len=Math.abs(start-end)*l;
			 var speed=parseInt(len/10); 
		     new $L.SetInterval(20,function(){dom.moveTo(x,0);},function(){
				  if(start<end)x-=speed;
				  else x+=speed;
				  time--;
				  if(time<1)x=-end*l;
				  return time<1;
			 });
	   };
	   dom.hide=function(){$L.DOM.hide(dom);}; 
	   dom.display=function(dom,px,py){display(dom,px,py);};  
	   dom.clear=function(){dom.innerHTML="";};
	   dom.destroy=function(){dom.parentNode.removeChild(dom);};
	   dom.displayTo=function(x,y){
	       this.display();
		   this.moveTo(x,y);
	   };
	   dom.browserFont=function(size){if($L.isFirefox)dom.style.fontSize=size+"px";};
	   dom.toLeft=function(p){dom.style.position='absolute';dom.style.left=p+"px";};
	   dom.toRight=function(p){dom.style.position='absolute';dom.style.right=p+"px";};
	   dom.toTop=function(p){dom.style.position='absolute';dom.style.top=p+"px";};
	   dom.toBottom=function(p){dom.style.position='absolute';dom.style.bottom=p+"px";};
	   dom.alphaShow=function(type){
			var dom=this;
			dom.display();
			dom.op=0;
			var add=2;
			var dom=this;
			if(type=='fast')add=10;
			new $L.SetInterval(20,function(){$L.Css.setAlpha(dom,dom.op);},function(){
				dom.op+=add;if(dom.op>100)dom.op=100;
				return dom.op==100;
			});
		};
		dom.alphaHide=function(type){
			dom.op=100;var add=5;var dom=this;if(type=='slow')add=2;
			new $L.SetInterval(20,function(){$L.Css.setAlpha(dom,dom.op);},function(){
				dom.op-=add;if(dom.op<0)dom.op=0;
				return dom.op==0;
			});
		};
	    dom.fbResize=function(){dom.unResizeAble=true;};
		dom.isDisplay=function(){return !$L.DOM.isHide(this);};
	    if(dom.tagName=="INPUT")return;  
	    dom.getSrc=function(){
			if(!dom.tagName=="IFRAME")return "";
			var w=dom.contentWindow;
			return w.location.href
		}; 
		dom.autoScroll=function(){dom.setStyles("overflow-y:auto;");};
	    dom.lock=function(time){
			if(!time)time=1000;
			dom.locked=true;
			window.setTimeout(function(){dom.locked=false;},time);
		};
		dom.setCenter=function(){
			 el=dom;
			 var t=$L.DOM.scrollTop();var l=$L.DOM.scrollLeft();
			 var x=parseInt(($L.getWidth()-$L.getBoxWidth(el))/2)+l;
			 var y=parseInt(($L.getHeight()-$L.getBoxHeight(el))/2)+t; 
			 moveTo(x,y);
		};
		dom.onTop=function(){
	    	var chs=dom.parentNode.childNodes; 
			for(var i=0;i<chs.length;i++){ 
				if(!chs[i].style)continue;
			    var index=chs[i].style.zIndex;
				if(!index||index=='')index=100;
				index--;  
				chs[i].style.zIndex=index;
			} 
			dom.style.zIndex=3000;
		};
		dom.addClass=function(cls){
		   dom.removeClass(cls);
		   var className=dom.className+" "+cls; 
		   setClass(className.trim());
		};
		dom.removeClass=function(cls){
		   var className=dom.className;if(!className)className="";
	       var cs=className.split(" ");className="";
		   for(var i=0;i<cs.length;i++){
			   if(cs[i]==cls)continue;
			   if(className.length>0)className+=" ";
			   className+=cs[i];
		    }
		    setClass(className);
		};
		
		 
		
	    dom.fbSelect=function(){};
		dom.selectAble=function(){};
	 
}


//老婆对象集合
var Laopo=new Object();var $L=Laopo;$L.DOM=new Object();$L.loaclStores={};
$L.Form=new Object();$L.Css=new Object();$L.Event=new Object();
$L.request={};$L.getRequest=function(n){return $L.request[n.toLowerCase()]};
$L.iePath=location.href.substring(7);$L.host="";$L.myPath="";
try{
	var $start=$L.iePath.indexOf("/");	 var $end=$L.iePath.lastIndexOf("/"); 
	$L.host="http://"+$L.iePath.substring(0,$start);$L.myPath="http://"+$L.iePath.substring(0,$end);
	var href=location.href;var start=href.indexOf("?");
	if(start!=-1){
	   href=href.substring(start+1);var hs=href.split("&");
	   for(var i=0;i<hs.length;i++){
	       start=hs[i].indexOf("=");
		   if(start==-1)continue;
		   var n=hs[i].substring(0,start).toLowerCase();
		   var v=hs[i].substring(start+1);$L.request[n]=v; 
	   }
	} 
}catch(e){alert("错误");}
$L.checkHref=function(href){
   if(/^\//.test(href))return $L.host+href;
   if(/^http:/.test(href))return href;
   return $L.myPath+"/"+href;
};
$L.SPAN="&nbsp;";$L.NO=1;$L.getNumber=function(){return $L.NO++;};

$L.random=function(max){if(!max)max=10000;return parseInt(Math.random()*max);};
$L.SetInterval=function(time,call,backCall){
	 var times=0;
     var id=setInterval(function(){
		  if(backCall())clearInterval(id);
	      times++;call(times);
	 },time); 
};
$L.changeCode=function(img){
   img=$L.DOM.getDom(img);
   var src=img.src;
   if(src.indexOf("&t")==-1)src+="&t=1";
   else src+="1";
   img.src=src;
};


$L.checkIE=function(r){var ua = navigator.userAgent.toLowerCase();return r.test(ua);};
$L.isChrome=$L.checkIE(/chrome/);
$L.isOpera =$L.checkIE(/opera/);
$L.isIE=!$L.isOpera&&$L.checkIE(/msie/);
$L.isIE8 =$L.isIE &&$L.checkIE(/msie 8/);
$L.isIE6 =$L.isIE &&$L.checkIE(/msie 6/); 
$L.isFirefox=$L.checkIE(/firefox/);
$L.isIE7 =$L.isIE &&$L.checkIE(/msie 7/);
$L.isWindows=$L.checkIE(/windows|win32/);
$L.isLinux =$L.checkIE(/linux/);
$L.over=function(muDom,oDom,px,py){
	 if(!py)py=0;if(!py)py=0;
     var mySeJi=$L.DOM.getDom(muDom);
     mySeJi.over(oDom,px,py);
}; 


//单独选址
/*
 * e 触发事件 click mouseover两种
 * pel 触发的标签id
 * css 标签转换的css 
 * */

$L.SingleSelect=function(e,pel,css,handle,dis){
	var chs=new Array(); 
	if(typeof pel=='string'&&pel.indexOf(",")!=-1){
	    var ps=pel.split(",");
		for(var i=0;i<ps.length;i++){
		    var d=$L.DOM.getDom(ps[i]);
			chs.push(d);
		}
	}else{
	    pel=$L.DOM.getDom(pel); 
	    chs=$L.DOM.getChs("",pel); 
	} 
	for(var i=0;i<chs.length;i++){
	   if(chs[i].SID)chs[i].con=$L.DOM.getDom(chs[i].SID);
	   $L.Css.hand(chs[i]);
	   chs[i].handle=function(){
	      for(var j=0;j<chs.length;j++){
		      chs[j].removeClass(css);
			  if(chs[j].con)chs[j].con.hide();
	      } 
	      this.addClass(css);
		  if(this.con)this.con.display();
		  if(handle)handle(this);
	   }; 
	   if(e=='click')
	       chs[i].onclick=function(){ this.handle();};
	   if(e=='mouseover')
	       chs[i].onmouseover=function(){ this.handle();}; 
	}
	chs[0].handle(); 
      
};
/*****Cookies的操作****/
$L.setCookie=function(name,value,time){
 var str=name+"="+escape(value);//编码以适合任何浏览器
 if(time<0){
   var mm=time*1000*60;//time分钟
   var date =new Date();
   date.setTime(date.getTime()+mm);
   str+=";expires="+date.toGMTString();
 }
 document.cookie=str;
}

 


$L.getCookie=function(name){
	name=name.toUpperCase()+"=";
    var msg=document.cookie;
	if(!msg)return "";
	msg=msg.split(";");
	
	for(var i=0;i<msg.length;i++){
		msg[i]=msg[i].trim(); 
        if(msg[i].indexOf(name)==0) 
		return msg[i].substring(name.length);
	}
	return "";
	
}
//
$L.defaultText=function(input,text){
    input=$L.DOM.getDom(input);
	input.defaultText=text;
	input.value=text;
	input.onblur=function(){
	    if(this.value=="")this.value=this.defaultText;
	};
	input.onfocus=function(){
	    if(this.value==this.defaultText)this.value="";
	}; 
};

//
$L.unSelect=function(dom){
	if(!dom)dom=document.body; 
    $L.unSelectAble=true;
	if(dom.addClass)dom.addClass("FBSelect");
};
$L.select=function(dom){
    if(!dom)dom=document.body;
	$L.unSelectAble=false; 
	if(dom.removeClass)dom.removeClass("FBSelect"); 
};

$L.saveIndex=function(){var sObj=event.srcElement;sObj.style.behavior='url(#default#homepage)';sObj.setHomePage(location.href);};
$L.addFavorite=function(title){var url=location.href;window.external.addFavorite(url,title);};
$L.getHeight=function(){var h=document.documentElement.clientHeight;if(h)return h;return document.body.clientHeight;};
$L.getWidth=function(){var w=document.documentElement.clientWidth;if(w)return w;return document.body.clientWidth;};
$L.getAllHeight=function(){var h=document.documentElement.scrollHeight;if(h)return h;return document.body.scrollHeight;};
$L.getAllWidth=function(){var w=document.documentElement.scrollWidth;if(w)return w;return document.body.scrollWidth;};

/**JS显示高亮**/
$L.checkJSCode=function(el,dom){
   setTimeout(function(){
      if(!dom)dom=el;el=$L.DOM.getDom(el);
	  dom=$L.DOM.getDom(dom);
	  var code=el.innerHTML;  
	  dom.innerHTML=code.hingDisplay(); 
   },100);
};

$L.getDateByString=function(d){
	d=d.replaceAll("-"," ");
	d=d.replaceAll(":"," "); 
    var ds=d.split(" ");
    return new $L.Date(ds[0],ds[1],ds[2],ds[3],ds[4],ds[5]);
} 
$L.getDay=function(){return parseInt(new Date().getTime()/(1000 * 3600 * 24))-14609;};
$L.Date=function(year,month,day,h,m,s){ 
   var _self=this;
   var n=new Date();
//   var d=new Date();if(year)d.setYear(year); if(month)d.setMonth(month-1); if(day)d.setDate(day);
   var d=new Date();if(year)d.setYear(year); if(month)d.setMonth(month); if(day)d.setDate(day);
   if(h)d.setHours(h);if(m)d.setMinutes(m);if(s)d.setSeconds(s);
   this.getWeek=function(){return d.getDay();};
   this.getDay=function(){return d.getDate();};
   this.getMonth=function(){return d.getMonth()+1;};
   this.getYear=function(){var year=d.getYear();if(year<200)year+=1900;return year;};
   this.getMaxDay=function(m){
       if(!m)m=0;var y=this.getYear();var m=this.getMonth()+m;
	   if(m>12){m=1;y+=1;}if(m<1){m=12;y-=1;}
	   return this.checkMaxDay(y,m);
   }; 
   this.checkMaxDay=function(y,m){
       if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)return 31;
	   if(m==2){if(y%4==0&&y%100!=0)return 29;if(y%100==0&&y%400==0)return 29;return 28;}
	   return 30;
   };
   
   this.setDateStr=function(date){
   	   n=date;
   }
   
   this.djs=function(el,isDoy,remark,handle,nowdate){
   	   if(typeof(el)=="string")el=$(el);
   	   if(nowdate)n=nowdate;
	   var ds=d.getSeconds();
	   var dm=d.getMinutes();
	   var dh=d.getHours();
	   var dd=d.getDate();
	   var dmon=d.getMonth();
	   var dyear=d.getYear();   
	   
	   
		var EndTime= new Date(dmon+"/"+dd+"/"+dyear+" "+dh+":"+dm+":"+ds);
		var nMS =EndTime.getTime() - n.getTime();
		var nD=Math.floor(nMS/(1000 * 60 * 60 * 24));
		var nH=Math.floor(nMS/(1000*60*60)) % 24;
		var nM=Math.floor(nMS/(1000*60)) % 60;
		var nS=Math.floor(nMS/1000) % 60;
		var code="";
		if(nD<0){
			if(!remark)
				remark="规定时间已过";
			el.innerHTML=remark
			if(handle)handle();
			return ;
		}
		if(nD>0)
			code=nD+"天"
		
		code+=nH+"时"+nM+"分"+nS+"秒";
	    el.innerHTML=code;
	    if(!isDoy)return;
	    setTimeout(function(){
	       _self.djs(el,isDoy,remark,handle,nowdate);
	    },500);
   }; 
};

//遮罩层的支持
$L.Mask=new function(){
	var mask=null;
	function getMask(op){
		if(!mask){mask=$L.DOM.create("DIV",{},document.body);mask.setClass("LMask"); 
		   mask.innerHTML=$L.SPAN;
	    }
		if(!op)op=30;
		$L.Css.setAlpha(mask,op);
	    return mask;
    }
	this.show=function(el,op){
	    var mask=getMask(op);
		mask.style.display='';
		mask.onTop();el.onTop();
		
		
		$L.Mask.updateSize();
	};
	this.hide=function(el){
		var mask=getMask();
	    mask.style.display='none';
		if(el)el.setZIndex(100);
	};
	this.updateSize=function(){
	   if(!mask)return;
	   mask.setWidth($L.getAllWidth());
	   mask.setHeight($L.getAllHeight());
	};
	this.getZindex=function(){return getMask().getZIndex();};
};
//数据的支持
$L.Store = function(c) {
    if (!c.head) c.head = ["label", "value", "filter"];
    if (!c.label) c.label = ["标签", "值", "过滤"];
    var configs = {};
    configs.labels = {};
    configs.datas = new Array();
    for (var i = 0; i < c.head.length; i++) configs.labels[c.head[i]] = c.label[i];
    for (var i = 0; i < c.data.length; i++) {
        configs.datas[i] = {};
        for (var j = 0; j < c.head.length; j++) configs.datas[i][c.head[j]] = c.data[i][j];

    }
    var records = new Array();
    var labels = {};
    var handles = {};
    var _self = this;
    function Record(map) {
        var data = {};
        for (var n in map) {
            data[n.toLowerCase()] = map[n];
        }
        this.get = function(n) {
            if (!n) return "";
            n = checkName(n);
            var v = data[n.toLowerCase()];
            if (!v) v = "";
            return v;
        };
        this.getLabel = function() {
            return this.get("label")
        };
        this.getValue = function() {
            return this.get("value")
        };
		this.update=function(n,v){n=n.toLowerCase();data[n]=v;};
        this.getFilter = function() {
            return this.get("filter")
        };
        records.push(this); 
    };
    function checkName(n) {
        if (n == 'label' && _self.tl) return _self.tl;
        if (n == 'value' && _self.tv) return _self.tv;
        if (n == 'filter' && _self.tf) return _self.tf;
        return n; 
    }
    function get(name, value) {
        for (var i = 0; i < records.length; i++)
        if (records[i].get(name) == value) return records[i];
        return null; 
    }
	
	
	
    //this.setFilter=function(lf,vf,ff){_self.lField=lf;_self.vField=vf;_self.fField=ff;};
    this.getHandle = function(n) {
        if (n) return handles[n.toLowerCase()];
        return null;
    };
    this.addHandle = function(n, handle) {
        handles[n.toLowerCase()] = handle;
    };
    this.getRecord = function(index) {
        return records[index];
    };
	this.createRecord=function(){
	    return new Record({});
	};
    this.addRecord = function(r, name) {
        if (!name) name = 'value';
        for (var i = 0; i < records.length; i++) {
            if (r.get(name) == records[i].get(name)) return;

        }
        records.push(r);

    };
    this.addRecords = function(rs, name) {
        for (var i = 0; i < rs.length; i++) this.addRecord(rs[i], name);
    };

    this.removeRecord = function(r) {
        records.remove(r);

    };
    this.removeRecords = function(rs) {
        for (var i = 0; i < rs.length; i++) this.removeRecord(rs[i]);

    };
    this.getRecords = function() {
        return records;
    };
    this.size = function() {
        return records.length;
    };
    this.getLabel = function(n) {
        var label = labels[n.toLowerCase()];
        if (!label) label = n;
        return label;
    };
    this.get = function(index, name) {
        if (!records[index]) return "";
        return records[index].get(name);
    };
    this.setLabels = function(lbs) {
        configs.labels = lbs;
        for (var n in lbs) {
            labels[n.toLowerCase()] = lbs[n];
        }
    };
    this.setData = function(datas) {
        configs.datas = datas;
        for (var i = 0; i < datas.length; i++) new Record(datas[i]);
    };
    this.getDatas = function() {
        return configs.datas;
    };
    this.getLabels = function() {
        return configs.labels;
    };
    this.getPa = function() {
        return c.pa;
    };
    this.setTree = function(l, v, f) {
        this.tl = l;
        this.tv = v;
        this.tf = f;
        for (var i = 0; i < records.length; i++) {
            records[i].pRecord = get(v, records[i].get(f));
            if (records[i].pRecord == records[i]) records[i].pRecord = null;
            records[i].chs = new Array();

        }
        for (var i = 0; i < records.length; i++) {
            for (var pr = records[i].pRecord; pr != null; pr = pr.pRecord) {
                pr.chs.push(records[i]);

            }

        }

    };
    if (configs.labels) this.setLabels(configs.labels);
    if (configs.datas) this.setData(configs.datas);
    this.getTree = function(root) {
        return new
        function() { 
			this.getRecord=function(key){
			    for (var i = 0; i < records.length; i++) {
				    if(records[i].get("value")==key)return records[i];
				}
				return null;
			};
			this.getSons=function(r,rs){
			   if(!rs)rs=new Array();
			   rs.push(r);
			   var id=r.get("value");
			   for(var i=0;i<records.length;i++){
			      var filter = records[i].get("filter");
				  if(filter!=id)continue; 
				  if(records[i].hasSon)this.getSons(records[i],rs);
				  else rs.push(records[i]);
			   } 
			   return rs;
			};
            this.getRecords = function(tf) {

                var rs = new Array();
                for (var i = 0; i < records.length; i++) {
                    var filter = records[i].get("filter");
                    if (tf == filter) {
                        rs.push(records[i]);
                        continue;
                    }
                    if (!tf && filter == 0) {
                        rs.push(records[i]);
                        continue;
                    }
                }
                for (var i = 0; i < rs.length; i++) {
                    rs[i].hasSon = false;
                    rs[i].isFirst = true;
                    rs[i].isEnd = true;
                    var beforeMe = true;

                    for (var j = 0; j < records.length; j++) {
                        //盘算是否具有子节点
                        if (rs[i].get("value") == records[j].get('filter')) {
                            rs[i].hasSon = true;

                        }
						
                        if (rs[i] == records[j]) {
                            beforeMe = false;
                            continue;
                        }
                        //在我之前 
                        var result = rs[i].get('filter') == records[j].get('filter');
                        if (result) {
                            //找到兄弟了
                            if (beforeMe) rs[i].isFirst = false;
                            if (!beforeMe) rs[i].isEnd = false;

                        }

                    }

                }
                return rs;

            };

        };

    };

};

/**通过tag标签获取所有子对象**/
$L.DOM.tagName=function(tag,source){if(!source)return document.getElementsByTagName(tag);return source.getElementsByTagName(tag);};
/**显示DOM**/
$L.DOM.show=function(el){el=$L.DOM.getDom(el);el.style.display='';};

$L.DOM.getChs=function(tag,dom){
   if(!dom)dom=document.body;
   if(!dom)return new Array();
   var chs=dom.childNodes;
   var array=new Array();
   for(var i=0;i<chs.length;i++)
       if(chs[i].tagName==tag||tag==""){
	       array.push(chs[i]);
		   if(!chs[i].loadPrototype)new LaopoDom(chs[i]);
	   }
   return array;
};
 
/**隐藏DOM**/
$L.DOM.hide=function(el){
	el=$L.DOM.getDom(el);el.style.display='none'; 
};
/**判断DOM是否隐藏**/
$L.DOM.isHide=function(el){return el.style.display=='none';};
/**显示s隐藏h**/
$L.DOM.aORb=function(s,h){$L.hide(h);$L.show(s);};
/**获取兄弟节点**/
$L.DOM.brothers=function(obj,index){obj=this.el(obj);return obj.parentNode.childNodes[index];};
/**带上滚动条的Y坐标**/
$L.DOM.scrollTop=function(){var t1=document.documentElement.scrollTop;var t2=document.body.scrollTop;if(t1)return t1;if(t2)return t2;return 0;};
/**带上滚动条的X坐标**/
$L.DOM.scrollLeft=function(){var l1=document.documentElement.scrollLeft;var l2=document.body.scrollLeft;if(l1)return l1;if(l2)return l2;return 0;};
/**上间隔**/
$L.DOM.MarginTop=function(dom,h){
    var div=$L.DOM.create("DIV",{},dom);
	div.style.width="100%";div.style.height=h+"px";div.style.clear="both";
	return div;
};
/**左间隔**/
$L.DOM.MarginLeft=function(dom,w){
    var div=$L.DOM.create("DIV",{},dom);
	div.style.width=w+"px";div.style.height="100%";div.style.cssFloat="left";div.style.styleFloat="left";
	return div;
};
/**创建节点**/
$L.DOM.create=function(tag,attr,parent,test){
	 tag=tag.toUpperCase();var tagObj=null;
	 if(tag=="INPUT"){ 
		 if($L.isIE){
			 var attrCode="type=text"; 
		     if(attr&&attr['type']){attrCode=" type='"+attr['type']+"' "}
		     if(attr&&attr['name']){attrCode+=" name='"+attr['name']+"' "}
			 tagObj=document.createElement("<input "+attrCode+"/>");
		 }else{tagObj=document.createElement("INPUT");}
		 tagObj.setValue=function(value){this.value=value;};
		 tagObj.getValue=function(){return this.value;};
		 tagObj.getName=function(){return this.name;};
	 }else{tagObj=document.createElement(tag);}
	 for(n in attr){
	    try{
			tagObj.setAttribute(n,attr[n]);tagObj[n]=attr[n];
		}catch(e){}
	 }
	 tagObj.setStyles=function(attr){$L.Css.setStyles(tagObj,attr);};
	 tagObj.setStyle=function(n,v){if(n=='float'){tagObj.style.styleFloat=v;tagObj.style.cssFloat=v;}else tagObj.style[n]=v;};
	 if(parent){parent.appendChild(tagObj);} 
	 new LaopoDom(tagObj,test);return tagObj;
};
/**获取节点**/
$L.DOM.getDom=function(el){
	if( typeof el=='string')el=document.getElementById(el);
	if(!el)return el;
	el.setStyles=function(attr){$L.Css.setStyles(el,attr);};
	if(!el.loadPrototype)new LaopoDom(el);
	return el;
};

/**移动基准线的支持**/
$L.MoveLine=function(source,type,handle,scop){
		 if(!$L.moveLine)$L.moveLine=$L.DOM.create("DIV",{},document.body);
		 var moveLine=$L.moveLine;moveLine.hide(); 
		 function xMove(){
		      moveLine.setClass("LVMoveLineY");moveLine.setSize(source.getWidth(),5);
		      moveLine.moveTo(source.getLeft(),source.getTop());
			  moveLine.display();moveLine.onTop();
		 }
		 function yMove(){
			  var h=source.getHeight();
			  if(source.moveHeight)h=source.moveHeight();
		      moveLine.setClass("LVMoveLineX");moveLine.setSize(5,h);
		      moveLine.moveTo(source.getLeft(),source.getTop());
			  moveLine.display();moveLine.onTop();
		 } 
	     source.onmousedown=function(evn){
			 if(!source.moveAble)return;
			 $L.unSelect();$L.Event.copy(evn);if(source.unResizeAble)return;
			 if(type=="x")xMove();else if(type=="y")yMove();var xm=0,ym=0;
			 var xMin=0,yMin=0,xMax=$L.getWidth()-5;yMax=$L.getHeight()-5;
			 $L.Mask.show(moveLine,2);
			 
			 if(scop&&scop!=document.body){
				xMin=scop.getLeft();
				xMax=xMin+scop.getWidth()-5;
				yMin=scop.getTop();yMax=yMin+scop.getHeight()-5;
			 }
			 $L.Event.addEvent("mousemove",source.getId(),function(e){//移动的支持
			      var x=e.clientX;var y=e.clientY;
				  if(x<xMin)x=xMin;if(x>xMax)x=xMax;if(y<yMin)y=yMin;if(y>yMax)y=yMax;
				  xm=x-source.getLeft();ym=y-source.getTop();
				  if(source.getMin){
				      var min=source.getMin();
					  if(type=="y"&&x<min)return;
					  if(type=="x"&&y<min)return;
				  }
				  if(source.getMax){
				      var max=source.getMax();
					  if(type=="y"&&x>max)return;
					  if(type=="x"&&y>max)return;
				  }
				  if(type=="x")moveLine.moveTo(null,y);
				  else if(type=="y")moveLine.moveTo(x,null);
			 });
			 $L.Event.addEvent("mouseup",source.getId(),function(){
				   $L.Event.addEvent("mouseup",source.getId(),null);
				   $L.Event.addEvent("mousemove",source.getId(),null);
				   $L.select();moveLine.hide();
				   if(handle)handle(xm,ym);
				   $L.Mask.hide();
		      }); 
		 }
};





 
/**获取el下名称为name的所有checkbox**/
$L.Form.getCheckBox=function(el,name){
	var ns=$L.DOM.tagName("INPUT",el);var tags="";
	for(var i=0;i<ns.length;i++){if(ns[i].type!='checkbox')continue;
	if(ns[i].name!=name||!ns[i].checked)continue;if(tags.length>0)tags+=",";tags+=ns[i].value;}return tags;
};
/**全选**/
$L.Form.getBoxSelect=function(el,name){var ns=this.getCheckBox(el,name);for(var i=0;i<ns.length;i++)ns[i].checked=true;};
/**全不选**/
$L.Form.getBoxUnSelect=function(el,name){var ns=this.getCheckBox(el,name);for(var i=0;i<ns.length;i++)ns[i].checked=false;};
/**反选**/
$L.Form.getBoxAntiSelect=function(el,name){var ns=this.getCheckBox(el,name);for(var i=0;i<ns.length;i++)ns[i].checked=!ns[i].checked;};
/**回车键的支持**/
$L.Form.enter=function(form,fun){form=$L.DOM.getDom(form);for(var i=0;i<form.length;i++){form[i].onkeypress=function(){if(event.keyCode==13)fun();}}};
/**为表单设置值**/
$L.Form.setValues=function(dom,ds){//设置表单
    var inputs=dom.getElementsByTagName("INPUT");
	for(var i=0;i<inputs.length;i++){//输入框对象集合
	     var n=inputs[i].name;if(!n)continue;if(!inputs[i].value)continue;n=n.toLowerCase();
		 if(inputs[i].type=='radio'||inputs[i].type=='checkbox'){
			 if(inputs[i].type=='checkbox')alert(inputs[i].value+"===="+ds[n]);
			 if(inputs[i].value==ds[n])inputs[i].checked=true; 
			 
		 }else inputs[i].value=ds[n]; 
	}
};
/**加载SELECT**/
$L.Form.loadSelect=function(sel,data){
	for(var i=0;i<data.length;i++){var d=data[i]; var o=new Option(d[0],d[1]);sel.add(o);o.data=d;}
};
/***级联菜单**/
$L.Form.SelectJL=function(s1,s2){
     s1=$L.DOM.getDom("s1");
	 s2=$L.DOM.getDom("s2");
	 if(!s1.pools)s1.pools={};
	 if(!s1.sons)s1.sons=new Array();
	 s1.sons.push(s2);
	 var a=new Array();
	 s1.pools[s2.getId()]=a;
	 var ops=s2.options;
	 for(var i=0;i<ops.length;i++){
	    a[i]=new Object();
		a[i].value=ops[i].value; 
		a[i].label=ops[i].innerHTML;
		a[i].pid=ops[i].pid;
	 }
	 s2.doFilter=function(p){
	     var v=p.value;
		 var key=this.getId();
		 var ops=this.options;
		 for(var i=ops.length;i>0;i--)
		    this.remove(ops[0]);
		 var ap=p.pools[key];
		 for(var i=0,j=0;i<ap.length;i++){
		    if(ap[i].pid!=v)continue;
			var o=new Option(ap[i].label,ap[i].value);
			this.options[j++]=o;
		 }
		 if(this.doChange)this.doChange(this);
	 };
	 s1.doChange=function(){
	    if(!s1.sons)return;
		for(var i=0;i<this.sons.length;i++)
		   this.sons[i].doFilter(this); 
	 };
	 s1.onchange=function(){this.doChange();};
	 s1.doChange();
};

/**手形鼠标**/
$L.Css.hand=function(el){el.style.cursor='pointer';};

$L.Css.addClass=function(el,css){
   el=$L.DOM.getDom(el);
   el.addClass(css);
};
$L.Css.removeClass=function(el,css){
    el=$L.DOM.getDom(el);
	el.removeClass(css); 
};
/**设置样式**/
$L.Css.setStyles=function(el,attr){
   if(typeof attr=='string'){
		var as=attr.split(";");
		attr={};
		for(var i=0;i<as.length;i++){
			as[i]=as[i].trim();
			var start=as[i].indexOf(":");
			var n=as[i].substring(0,start);
			var v=as[i].substring(start+1);
			n=n.trim();v=v.trim();n=this.upp(n);
			attr[n]=v;
		}
	 }
	 if(attr['float']){attr['styleFloat']=attr['float'];attr['cssFloat']=attr['float'];}
	 for(n in attr){try{el.style[n]=attr[n];}catch(e){}}
};
/**样式大写转换 例如  font-zize转换为 fontSize**/
$L.Css.upp=function(str){
  str=str.replace(/-\w+/g,function(word) {return word.substring(1,2).toUpperCase( )+word.substring(2);});
  return str;
};
/**添加样式内容**/
$L.Css.add=function(content){ 
    if(!this.cache)this.cache="";
	this.cache+=content+"\n";
	if(this.cache.length>1024)this.flush();
};
/**清空写入内容**/
$L.Css.flush=function(){
    if(!this.cache)return;
	this.cache="<style>"+this.cache+"</style>";
	document.write(this.cache);
	this.cache=""; 
};
/**浮动*/
$L.Css.float=function(el,type){
   if(!type)type="left";
   el.style.float=type;
};
/**设置透明度**/
$L.Css.setAlpha=function(el,opacity){
	var style=el.style; 
	if ($L.isIE) {
        if (!el.style.filters) {
            el.style.filter = "alpha(opacity:" + opacity + ")";
            return;
        }
        el.style.filters["alpha"].opacity = opacity;

    }else if($L.isFirefox){style.MozOpacity=opacity/100;}
	else{
	    style.opacity = style['-moz-opacity'] = style['-khtml-opacity'] =opacity/100;
	}
	 
	
}; 
 /**事件模型的支持*srcElement**/
$L.Event.copy=function(e){if(e)window.event=e;};
//添加事件
$L.Event.addEvent=function(type,name,handle,source){
    type=type.toLowerCase();name=name.toLowerCase();
	if(!this.events){this.events={};this.sources={};}
	if(!this.events[type]){this.events[type]={};this.sources[type]={};}
	this.events[type][name]=handle;this.sources[type][name]=source;
};
$L.Event.target=function(e,type){
    if(!this.events)return;
	var es=this.events[type];
	for(var n in es){
	   if(es[n])es[n](e);
	}
};


  
/**获取相对坐标X**/
$L.Event.getX=function(dom){if(!dom)return event.clientX;return event.clientX-dom.getLeft();};
/**获取相对坐标Y**/
$L.Event.getY=function(dom){if(!dom)return event.clientY;return event.clientY-dom.getTop();};
/**document事件的支持**/
$L.Event.init=function(){
	document.onclick=function(evn){$L.Event.copy(evn);$L.Event.target(event,'click');}; 
	document.onmouseover=function(evn){$L.Event.copy(evn);$L.Event.target(event,'mouseover');}; 
	document.onmouseout=function(evn){$L.Event.copy(evn);$L.Event.target(event,'mouseout');}; 
	document.onmousedown=function(evn){$L.Event.copy(evn);$L.Event.target(event,'mousedown');}; 
	document.onmousemove=function(evn){$L.Event.copy(evn);$L.Event.target(event,'mousemove');}; 
	document.onmouseup=function(evn){$L.Event.copy(evn);$L.Event.target(event,'mouseup');}; 
	document.ondblclick=function(evn){$L.Event.copy(evn);$L.Event.target(event,'dblclick');}; 
	document.onkeydown=function(evn){$L.Event.copy(evn);$L.Event.target(event,'keydown');}; 
	document.onkeypress=function(evn){$L.Event.copy(evn);$L.Event.target(event,'keypress');}; 
	document.onkeyup=function(evn){$L.Event.copy(evn);$L.Event.target(event,'keyup');}; 
	document.onselectstart=function(){return $L.unSelectAble!=true;};
};
$L.Event.init();//事件模型的初始化




/***********************************************************************************************************************************

*************************UI控件的支持**************************************************************************

**/ 
setInterval(function(){
    if(!document.body)return;var layouts=$L.UI.layouts;
    if(!layouts)return;
	if(!document.body.loadPrototype){
	    new LaopoDom(document.body); 
		$L.ieWidth=$L.getWidth();$L.ieHeight=$L.getHeight();
	}
	document.body.style.overflowX='hidden';
    var w=$L.getWidth();var h=$L.getHeight();
	var hasChange=(w!=$L.ieWidth||h!=$L.ieHeight);
	$L.ieWidth=w;$L.ieHeight=h;$L.Mask.updateSize();
	if(hasChange)document.body.hasChange=true;
	for(var i=0;i<layouts.length;i++){
	   layouts[i].autoLayout();
	}
},100);

$L.UI=new Object();$L.UI.windowFactorys=new Array();$L.UI.Theme=new Object();
$L.UI.AutoLayout=function(ui,root){
	if(!root)root=document.body;
    if(!$L.UI.layouts)$L.UI.layouts=new Array();
	ui.autoLayout=function(){
	   if(!(root.hasChange||!root.isInit))return;
	   var rs=ui.doLayout();
	   if(rs){root.hasChange=false;root.isInit=true;}
	};
	$L.UI.layouts.push(ui);
};

$L.UI.Theme.Icons={
     'p.first':' 0 0','p.last':' -16 -48','p.next':' -16 -16','p.end':' 0 -32'
	 ,'p.first.dis':' 0 -16','p.last.dis':' -16 -32','p.next.dis':' -16 0','p.end.dis':' 0 -48'
	,'l.add':' 0 -64','l.del':' 0 -80','l.upd':' 0 -96','l.query':' 0 -112','l.error':' -17 -64'
	,'l.yes':' -17 -80','l.save':' -16 -96','l.img':' 0 -144'
	,'':''
};

$L.UI.FontFamily=new $L.Store({
    data:[["宋体","宋体"],["黑体","黑体"],["楷体","楷体"]]
}); 
$L.UI.FontSize=new $L.Store({
    data:[["一号","1"],["二号","2"],["三号","3"]]
}); 
$L.UI.Theme.defaultUrl=LAOPOCMS_URL+"/default";
$L.UI.Theme.iconUrl=LAOPOCMS_URL+"/icons.png";
$L.UI.Theme.psUrl=LAOPOCMS_URL+"/ps.png";
$L.UI.Theme.def={
     bg:$L.UI.Theme.defaultUrl+'/panel/bg.gif'
	,tools:$L.UI.Theme.defaultUrl+'/panel/tools.gif'
	,btn:$L.UI.Theme.defaultUrl+'/panel/btn.png'
	,grid_hbg1:$L.UI.Theme.defaultUrl+'/grid/hbg1.gif'
	,grid_hbg2:$L.UI.Theme.defaultUrl+'/grid/hbg2.gif'
	,grid_hbtn:$L.UI.Theme.defaultUrl+'/grid/hbtn.gif'
	,grid_rbg2:$L.UI.Theme.defaultUrl+'/grid/rbg2.gif'
	,grid_index:$L.UI.Theme.defaultUrl+'/grid/index.gif'
	,grid_indexSel:$L.UI.Theme.defaultUrl+'/grid/indexSel.gif'
	,grid_rowbox:$L.UI.Theme.defaultUrl+'/grid/rowbox.gif'  
	
	,grid_rbg3:"#DFE8F6" 
	
	,form_textbg1:$L.UI.Theme.defaultUrl+'/form/text-bg.gif'
	,form_textError:$L.UI.Theme.defaultUrl+'/form/error.gif' 
	,form_dateBtn:$L.UI.Theme.defaultUrl+'/form/date-trigger.gif'
	,form_dateBg:$L.UI.Theme.defaultUrl+'/form/date-bg.gif'
	,form_dateBtns:$L.UI.Theme.defaultUrl+'/form/date-btn.gif'  
	,form_combox:$L.UI.Theme.defaultUrl+'/form/trigger.gif' 
	,form_search:$L.UI.Theme.defaultUrl+'/form/search.gif' 
	
	
	 
 	,errorMsg:$L.UI.Theme.defaultUrl+'/error-tip.gif'
	,shadow:$L.UI.Theme.defaultUrl+'/form/shadow.png'
	,shadowLr:$L.UI.Theme.defaultUrl+'/form/shadow-lr.png'
	
	,btnBg:$L.UI.Theme.defaultUrl+'/btns/btn.gif'
	,btnCs:$L.UI.Theme.defaultUrl+'/btns/cs.gif'
	,btnLr:$L.UI.Theme.defaultUrl+'/btns/lr.gif'
	
	,winLc:$L.UI.Theme.defaultUrl+'/window/lc.png'
	,winRc:$L.UI.Theme.defaultUrl+'/window/rc.png'
	,winLR:$L.UI.Theme.defaultUrl+'/window/lr.png'
	,winTB:$L.UI.Theme.defaultUrl+'/window/tb.png'
	,winAsk:$L.UI.Theme.defaultUrl+'/window/icon-question.gif'  
	,tree_bg:$L.UI.Theme.defaultUrl+'/tree/p.png'
	,qqEdit:$L.UI.Theme.defaultUrl+"/form/qqEdit.png"
	
	,tabBg:$L.UI.Theme.defaultUrl+'/tab/bg.gif'
	,tabClose:$L.UI.Theme.defaultUrl+'/tab/close.gif'
	
	
	
};
_ThemeFactory=$L.UI.Theme.def;
$L.UI.getError=function(n){
   return {
	   'setStore':'请配置正确的数据源!'
	   ,"form.selectBox.setSrc":"对不起，请配置您要选择的路径!"
	}[n];
};
$L.UI.Local=new Object();
$L.UI.Local.get=function(name){var n=$L.UI.Local.CN[name];if(!n)n=name;return n;};

$L.UI.Local.CN={
   'shou.qi':'收起','zhan.kai':'展开','guan.bi':'关闭','quan.pin':'全屏','hui.fu':'恢复' 
   ,'week.1':'一','week.2':'二','week.3':'三','week.4':'四','week.5':'五','week.6':'六','week.0':'日','week.7':'日'
   ,'month.1':'一月','month.2':'二月','month.3':'三月','month.4':'四月','month.5':'五月','month.6':'六月'
   ,'month.7':'七月','month.8':'八月','month.9':'九月','month.10':'十月','month.11':'十一月','month.12':'十二月'
   ,'':''
};
//颜色对象
$L.UI.colors=[
        '000000', '993300', '333300', '003300', '003366', '000080', '333399', '333333',
        '800000', 'FF6600', '808000', '008000', '008080', '0000FF', '666699', '808080',
        'FF0000', 'FF9900', '99CC00', '339966', '33CCCC', '3366FF', '800080', '969696',
        'FF00FF', 'FFCC00', 'FFFF00', '00FF00', '00FFFF', '00CCFF', '993366', 'C0C0C0',
        'FF99CC', 'FFCC99', 'FFFF99', 'CCFFCC', 'CCFFFF', '99CCFF', 'CC99FF', 'FFFFFF'
];
$L.UI.dom=function(dom,w,h){
	if(!document.body.loadPrototype)new LaopoDom(document.body);
	if(!dom||dom==document.body)dom=document.body;
	else if(dom.isContainer)dom=dom.getContainer();
	else dom=dom.getDom();
	if(w&&h){dom=$L.DOM.create("DIV",{},dom);dom.setSize(w,h);}
	return dom;
};

//边界布局的支持
$L.UI.BorderView=function(root){
	 root=$L.UI.dom(root);var main=$L.DOM.create("DIV",{},root);main.setClass("LView LVBorder"); var _self=this; 
	 var northEl=$L.DOM.create("DIV",{},main);northEl.setClass("LVNorth");
	 northEl.margin=$L.DOM.create("DIV",{},main);northEl.margin.setClass("LVNMargin");  
	 var centerEl=$L.DOM.create("DIV",{},main);centerEl.setClass("LVCenter");  
	 var south_margin=$L.DOM.create("DIV",{},main);south_margin.setClass("LVSMargin"); 
	 var southEl=$L.DOM.create("DIV",{},main);southEl.setClass("LVSouth"); 
	 southEl.margin=south_margin; 
	 var westEl=$L.DOM.create("DIV",{},centerEl);westEl.setClass("LVWestEl");
	 westEl.margin=$L.DOM.create("DIV",{},centerEl);westEl.margin.setClass("LVWMargin");  
	 var contentEl=$L.DOM.create("DIV",{},centerEl);contentEl.setClass("LVContentEl"); 
	 var east_margin=$L.DOM.create("DIV",{},centerEl);east_margin.setClass("LVEMargin"); 
	 var eastEl=$L.DOM.create("DIV",{},centerEl);eastEl.setClass("LVEastEl");
	 eastEl.margin=east_margin;
	  
       new $L.MoveLine(northEl.margin,"x",function(mw,mh){_self.setTop(northEl.getHeight()+mh);_self.doLayout();},main);
       new $L.MoveLine(southEl.margin,"x",function(mw,mh){_self.setFoot(southEl.getHeight()-mh);_self.doLayout();},main);
       new $L.MoveLine(westEl.margin,"y",function(mw,mh){_self.setLeft(westEl.getWidth()+mw);_self.doLayout();},main);
       new $L.MoveLine(eastEl.margin,"y",function(mw,mh){_self.setRight(eastEl.getWidth()-mw);_self.doLayout();},main);
	   
	   this.moveAble=function(b){
	       if(/s/.test(b))northEl.margin.moveAble=true;
		   if(/x/.test(b))southEl.margin.moveAble=true;
		   if(/z/.test(b))westEl.margin.moveAble=true;
		   if(/y/.test(b))eastEl.margin.moveAble=true;
		   
	   }; 
	   this.openView=function(b){
	       if(!/s/.test(b))this.closeNorth();
		   if(!/x/.test(b))this.closeSouth();
		   if(!/z/.test(b))this.closeWest();
		   if(!/y/.test(b))this.closeEast();
	   };
	   this.closeNorth=function(){northEl.hide();northEl.margin.hide();this.doLayout();};
	   this.closeSouth=function(){southEl.hide();southEl.margin.hide();this.doLayout();};
	   this.closeWest=function(){westEl.hide();westEl.margin.hide();this.doLayout();};
	   this.closeEast=function(){eastEl.hide();eastEl.margin.hide();this.doLayout();};
	   this.getNorth=function(){return northEl;}; this.getWest=function(){return westEl;};
	   this.getSouth=function(){return southEl;};this.getEast=function(){return eastEl;};
	   this.getContent=function(){return contentEl;};this.getEl=function(){return this.getContent();};
	   this.setTop=function(height){northEl.setHeight(height);this.doLayout();};
	   this.setFoot=function(height){southEl.setHeight(height);this.doLayout();}; 
	   this.setLeft=function(width){westEl.setWidth(width);this.doLayout();}; 
	   this.setRight=function(width){eastEl.setWidth(width);this.doLayout();};
	   this.doLayout=function(){
		    var w=root.getWidth();var h=root.getHeight();
			if(!w||!h)return false;
			main.setSize(w,h);
	        var centerHeight=h-northEl.getHeight()-southEl.getHeight()-southEl.margin.getHeight()-northEl.margin.getHeight();
			var centerWidth=w-westEl.getWidth()-westEl.margin.getWidth()-eastEl.getWidth()-eastEl.margin.getWidth();
			centerEl.setHeight(centerHeight);contentEl.setWidth(centerWidth);
			return true;
	   };
	   new $L.UI.AutoLayout(this,root);//自动布局的支持
};
 
/****/
$L.UI.Round=function(root,len){
     var frame=$L.DOM.create("DIV",{},root);frame.setClass('RoundFrame');
	 var left=$L.DOM.create("DIV",{},frame);left.toLeft(0);left.toTop(len);
	 var right=$L.DOM.create("DIV",{},frame);right.toRight(0);right.toTop(len);
	 var top=$L.DOM.create("DIV",{},frame);top.toLeft(len);top.toTop(0);
	 var bottom=$L.DOM.create("DIV",{},frame);bottom.toLeft(len);bottom.toBottom(0);
	 var tLeft=$L.DOM.create("DIV",{},frame);tLeft.moveTo(0,0);tLeft.setSize(len,len);
	 var tRight=$L.DOM.create("DIV",{},frame);tRight.toTop(0);tRight.toRight(0);tRight.setSize(len,len);
	 var bLeft=$L.DOM.create("DIV",{},frame);bLeft.toBottom(0);bLeft.toLeft(0);bLeft.setSize(len,len);
	 var bRight=$L.DOM.create("DIV",{},frame);bRight.toBottom(0);bRight.toRight(0);bRight.setSize(len,len);
	 var main=$L.DOM.create("DIV",{},frame);main.toLeft(len);main.toTop(len);
 
	 this.setLeftBg=function(url,config){left.setBackground(url,config);};
	 this.setRightBg=function(url,config){right.setBackground(url,config);};
	 this.setTopBg=function(url,config){top.setBackground(url,config);};
	 this.setBottomBg=function(url,config){bottom.setBackground(url,config);};
	 this.setLeftTopBg=function(url,config){tLeft.setBackground(url,config);};
	 this.setRightTopBg=function(url,config){tRight.setBackground(url,config);};
	 this.setLeftBottomBg=function(url,config){bLeft.setBackground(url,config);};
	 this.setRightBottomBg=function(url,config){bRight.setBackground(url,config);};
 	 this.getEl=function(){return main;};
	 this.setBgColor=function(bgColor){this.bgColor=bgColor;main.setBackground(this.bgColor);};
	 this.doLayout=function(w,h){
		 if(!this.bgColor)this.bgColor="#DFE8F6";
		 if(!w)w=root.getWidth();if(!h)h=root.getHeight();
		 if(!w||!h)return false;
	     left.setSize(len,h-len*2);right.setSize(len,h-len*2);
		 top.setSize(w-len*2,len);bottom.setSize(w-len*2,len);
		 main.setSize(w-len*2,h-len*2);main.setBackground(this.bgColor);
		 main.setBackground("#CCC");
		 return true;
	 };
	// new $L.UI.AutoLayout(this,root);//自动布局的支持
};
//圆角矩形
$L.UI.RoundRect=function(root,color,w,h){
     root=$L.UI.dom(root,w,h);var frame=$L.DOM.create("DIV",{},root);frame.setClass("RoundRect");
	 var content=$L.DOM.create("DIV",{},frame);content.moveTo(1,3);var points=new Array();var _self=this;
	 var line1=$L.DOM.create("DIV",{},frame);line1.moveTo(1,2);
	 var line2=$L.DOM.create("DIV",{},frame);line2.moveTo(2,1);
	 var line3=$L.DOM.create("DIV",{},frame);line3.toLeft(1);line3.toBottom(2);
	 var line4=$L.DOM.create("DIV",{},frame);line4.toLeft(2);line4.toBottom(1);
	 var main=$L.DOM.create("DIV",{},content);main.setPosition();
	 
	 function Point(x,y,lx,by){
	     var p=$L.DOM.create("DIV",{},frame);p.setClass('RectPoint');p.setBackground(color);
		 if(x>0||x==0)p.toLeft(x);if(y>0||y==0)p.toTop(y);
		 if(lx>0||lx==0)p.toRight(lx);if(by>0||by==0)p.toBottom(by);
		 this.hide=function(){p.hide();};
	 }
	 points[0]=new Point(2,0); points[1]=new Point(1,1); points[2]=new Point(0,2);
	 points[3]=new Point(null,0,2,null); points[4]=new Point(null,1,1,null); points[5]=new Point(null,2,0,null);
	 points[6]=new Point(null,null,2,0); points[7]=new Point(null,null,1,1); points[8]=new Point(null,null,0,2);
	 points[9]=new Point(2,null,null,0); points[10]=new Point(1,null,null,1); points[11]=new Point(0,null,null,2);
	 var top=$L.DOM.create("DIV",{},frame);top.moveTo(3,0);top.setBackground(color);
	 var left=$L.DOM.create("DIV",{},frame);left.moveTo(0,3);left.setBackground(color);
	 var right=$L.DOM.create("DIV",{},frame);right.toRight(0);right.toTop(3);right.setBackground(color);
	 var bottom=$L.DOM.create("DIV",{},frame);bottom.toLeft(3);bottom.toBottom(0);bottom.setBackground(color);
	 this.top=top;this.left=left;this.right=right;this.bottom=bottom;
	 
     this.setBackground=function(background,x,y,h){
		 var c1="",c2="",c3="",c4="",c="";if(!h)h=content.getHeight();
		 if((x||x==0)&&(y||y==0)){
			c=" "+x+" "+(y-3);
		    c1=" "+x+" "+(y-1);
			c2=" "+x+" "+(y-2);
			c3=" "+x+" "+(y-1-h);
			c4=" "+x+" "+(y-2-h);
		 }
	     content.setBackground(background,c);
		 line1.setBackground(background,c1);
		 line2.setBackground(background,c2);
		 line3.setBackground(background,c3);
		 line4.setBackground(background,c4);
	 };
	 
	 function closeBottom(w,h){
		for(var i=6;i<12;i++) points[i].hide();
		left.setSize(1,h-3);right.setSize(1,h-3);
		line3.setSize(w-1,1);line4.setSize(w-2,1);
		bottom.toLeft(1);bottom.setWidth(w-2);
	 };
	 function closeTop(w,h){
		for(var i=0;i<6;i++) points[i].hide();
		left.setSize(1,h-3);right.setSize(1,h-3);
		line1.setSize(w-1,1);line2.setSize(w-1,1);
	 }; 
	 this.doLayout=function(){
		 var w=root.getWidth();var h=root.getHeight();
		 top.setSize(w-6,1);left.setSize(1,h-6);right.setSize(1,h-6); bottom.setSize(w-6,1);
		 content.setSize(w-2,h-6);line1.setSize(w-2,1);line2.setSize(w-4,1);line3.setSize(w-2,1);line4.setSize(w-4,1);
		 main.setSize(w-2,h-6);
		 if(_self.closeBottom)closeBottom(w,h);
		 if(_self.closeTop)closeTop(w,h);
	 };
	 
	 this.skipBottom=function(){_self.closeBottom=true;this.doLayout();};
	 this.skipTop=function(){_self.closeTop=true;this.doLayout();};
	 
	 
	 this.setAutoFill=function(){this.setBackground(color);}; 
	 this.getEl=function(){return main;}; 
};

//BOX的支持
$L.UI.Box=function(){  
     var root=$L.DOM.create("DIV",{},document.body);root.setClass("LBoxRoot");var _self=this;root.hide();
	 var round=new $L.UI.Round(root,6);
	 round.setLeftBg(_ThemeFactory.shadowLr," 0 0");round.setRightBg(_ThemeFactory.shadowLr," -6 0");
	 round.setTopBg(_ThemeFactory.shadow," 0 -30");round.setBottomBg(_ThemeFactory.shadow," 0 -36");
	 round.setLeftTopBg(_ThemeFactory.shadow);round.setRightTopBg(_ThemeFactory.shadow," 0 -18");
	 round.setLeftBottomBg(_ThemeFactory.shadow," 0 -12");round.setRightBottomBg(_ThemeFactory.shadow," 0 -6");
	 var main=round.getEl();main.moveTo(4,2);   
	 this.moveTo=function(x,y){root.moveTo(x,y);};
	 this.setSize=function(w,h){
		 root.setSize(w,h);
		 round.doLayout(w,h);
		 main.setSize(w-8,h-4);
	 };
	 this.show=function(dom){
		 if(_self.modle)$L.Mask.show(root);
		 root.display(dom);root.onTop();
	 };
	 this.getRoot=function(){return root;};
	 this.showMask=function(){$L.Mask.show(root);};
	 this.hide=function(){root.hide();};
	 this.isHidden=function(){return $L.DOM.isHide(root);};
	 this.setTop=function(){};
	 this.setBgColor=function(color){round.setBgColor(color);};
	 this.getEl=function(){return main;};
	 this.setCenter=function(){
	      var x=parseInt(($L.getAllWidth()-root.getWidth())/2);
		  var y=parseInt(($L.getAllHeight()-root.getHeight())/2);
		  if(x<0)x=-5;if(y<0)y=-5;
		  root.moveTo(x,y);return;
	 };
	 this.init=function(){
	    _self.modle=false;
		root.moveTo(0,0);
		this.setSize(1,1);
	 };
	 this.setMoveAble=function(source,beforeMove,afterMove){
		 source.style.cursor="move";var x=0;var y=0;
		 source.onmousedown=function(evn){
			 if(source.locked)return;$L.unSelect();
			 $L.Css.setAlpha(main,30);
			 $L.Event.copy(evn);
		     $L.Mask.show(root);source.moveUnLock=true;
			 x=$L.Event.getX(root);y=$L.Event.getY(root);
			 if(beforeMove)beforeMove();
		 };
		 $L.Event.addEvent("mousemove",source.getId(),function(){

			  if(!source.moveUnLock)return;
			  root.moveTo(event.clientX-x,event.clientY-y);
		 });
		 $L.Event.addEvent("mouseup",source.getId(),function(){
			  source.moveUnLock=false;if(!_self.modle)$L.Mask.hide();
			  if(afterMove)afterMove();
			  $L.select();
			  $L.Css.setAlpha(main,100);
			   
		 }); 
	 };
};

//显示错误信息
$L.UI.ShowErrorMsg=function(msg,dom,w,h){
     if(this.ErrorMsg){this.ErrorMsg.show(msg,dom,w,h);return;}
	 this.ErrorMsg=new function(){
	     var root=$L.DOM.create("DIV",{},document.body);root.setClass("LErrorMsg");root.hide();
		 var round=new $L.UI.Round(root,5);
		 round.setLeftBg(_ThemeFactory.errorMsg," 0 -30");round.setRightBg(_ThemeFactory.errorMsg," -495 -40");
	     round.setTopBg(_ThemeFactory.errorMsg," 0 -12");round.setBottomBg(_ThemeFactory.errorMsg," 0 -19");
	     round.setLeftTopBg(_ThemeFactory.errorMsg);round.setRightTopBg(_ThemeFactory.errorMsg," -494 0");
	     round.setLeftBottomBg(_ThemeFactory.errorMsg," 0 -6");round.setRightBottomBg(_ThemeFactory.errorMsg," -494 -7"); 
		 var main=round.getEl();
		 var content=$L.DOM.create("DIV",{},main);content.setClass('LErrorMsgContent LFont_EMsg');
		 var errorIcon=$L.DOM.create("DIV",{},main);errorIcon.setClass('LErrorMsgIcon'); 
		 content.browserFont(12); 
		 this.show=function(msg,dom,w,h,isOk,noWin){
			  if(!w||w<100)w=200;if(!h||h<30)h=30;
			  content.setText($L.SPAN+msg);root.setSize(w,h);
			  if(noWin){
			     root.display(dom);
			  }else{
			     var x=dom.getLeft()+dom.px+dom.getWidth();
			     var y=dom.getTop()+dom.py+dom.getHeight()+10;
			     root.displayTo(x,y);
				
				 root.onTop();
				 
			  }
			  round.doLayout(w,h);
			  var icon="l.error";if(isOk)icon="l.yes";
			  errorIcon.setBackground($L.UI.Theme.iconUrl,$L.UI.Theme.Icons[icon]);
		 };
		 this.hide=function(){root.hide();};
	 };
     this.ErrorMsg.show(msg,dom,w,h);
};

//隐藏错误信息
$L.UI.HiddenErrorMsg=function(){if(this.ErrorMsg)this.ErrorMsg.hide();};
//颜色框的支持
$L.UI.showColorPanel=function(dom,handle){
    if(this.ColorPanel){this.ColorPanel.show(dom,handle);return;}
    this.ColorPanel=new function(){
		 var box=new $L.UI.Box();var root=box.getEl();box.setSize(155,120);
		 var frame=$L.DOM.create("DIV",{},root);frame.setClass("ColorFrame");
		 var disPlay=$L.DOM.create("DIV",{},frame);disPlay.setClass("DisplayPanel");
		 var colorPanel=$L.DOM.create("DIV",{},disPlay);colorPanel.setClass("ColorPanel");

		 for(var i=0;i<40;i++){
		    var colorEl=$L.DOM.create("DIV",{},frame);colorEl.setClass("ColorEl");
			colorEl.unselectable="on";
		    if(i%8==7)$L.DOM.MarginTop(frame,1);
			colorEl.color="#"+$L.UI.colors[i];
			colorEl.setBackground(colorEl.color);
			colorEl.onmouseover=function(){
			   colorPanel.setBackground(this.color);
			};
			colorEl.onclick=function(){
			    if(handle)handle(this.color);
				box.hide();
			};
		 }
		 this.show=function(dom,handle){
			  frame.lock(200);
		      box.show(dom);
			  colorPanel.setBackground("#FFF");
		 };
		 this.hide=function(){if(frame.locked)return;box.hide();};
	};
	this.ColorPanel.show(dom,handle);
};
//隐藏颜色框
$L.UI.hideColorPanel=function(){
    if(!this.ColorPanel)return;this.ColorPanel.hide();
}; 


//工具栏的支持
$L.UI.ToolBar=function(root){
     var toolBar=$L.DOM.create("DIV",{},root);toolBar.setClass("LToolBar");toolBar.setBackground(_ThemeFactory.bg," 0 -26");
	 this.setBorder=function(b,style){ toolBar.setBorder(b,style);}; 
	 this.addButton=function(icon,text,handle,hasLine){
		 var btn=new $L.UI.ToolButton(toolBar,icon,text,handle);
		 if(hasLine){var line=new $L.UI.ToolButton(toolBar,"line");btn.line=line.getDom();}
		 return btn;
	 };
	 this.getHeight=function(){return toolBar.getHeight();};
	 this.display=function(){toolBar.display();};
	 this.hide=function(){toolBar.hide();};
	 this.init=function(){toolBar.clear();};
	 $L.unSelect(toolBar);
};


//工具按钮的支持
$L.UI.ToolButton=function(root,iconCls,text,callback){
     var btn=$L.DOM.create("DIV",{},root);btn.setClass("LTBtn");var _self=this;this.getDom=function(){return btn;};
	 if(iconCls=="line"){btn.setClass("LTLine");btn.setBackground(_ThemeFactory.btn," 0 -153");return;}
	 var left=$L.DOM.create("DIV",{},btn);left.setClass("LBtnLeft");
	 var icon=$L.DOM.create("DIV",{},btn);icon.setClass("LBtnIcon");
	 var center=$L.DOM.create("DIV",{},btn);center.setClass("LBtnCenter"); 
	 var right=$L.DOM.create("DIV",{},btn);right.setClass("LBtnRight");
	 left.innerHTML=$L.SPAN;right.innerHTML=$L.SPAN;var btnBg=_ThemeFactory.btn;
	 this.setText=function(msg){this.textMsg=msg;center.innerHTML=$L.SPAN+msg;};
	 this.getText=function(msg){return this.textMsg;};
	 this.setIcon=function(cls){ 
		 this.cls=cls;
		 if(this.disabled)cls+=".dis";
		 var config=$L.UI.Theme.Icons[cls];if(!config){icon.className="LBtnIcon "+cls;return;}
	     icon.setBackground($L.UI.Theme.iconUrl,config);icon.setSize(16,16);
	 };
	 this.hide=function(){btn.hide();};
	 this.display=function(){btn.display();};
	 this.closeLine=function(){if(this.line)this.line.hide();};
	 this.openLine=function(){if(this.line)this.line.display();};
	 this.disable=function(){
	    _self.disabled=true;this.setIcon(this.cls);
		center.style.color="#666";
	 };
	 this.enable=function(){
	    _self.disabled=false;this.setIcon(this.cls);
		center.style.color="#000";
	 }; 
	 function s0(){btn.setBackground("");left.setBackground("");right.setBackground("");$L.select(root);} 
	 function s1(){
		 $L.unSelect(root);
		 if(_self.disabled)return;
	     btn.setBackground(btnBg," 0 -50");left.setBackground(btnBg);right.setBackground(btnBg," 0 -25");
	 } 
	 function s2(){
		 if(_self.disabled)return;
	     btn.setBackground(btnBg," 0 -125");left.setBackground(btnBg," 0 -75");right.setBackground(btnBg," 0 -100");
	 } 
	 btn.onmouseover=function(evn){$L.Event.copy(evn);s1();};
	 btn.onmousedown=function(evn){$L.Event.copy(evn);s2();};
	 btn.onmouseup=function(evn){$L.Event.copy(evn);s1();};
	 btn.onmouseout=function(evn){$L.Event.copy(evn);s0();};s0();
	 btn.onclick=function(evn){
		 if(_self.disabled)return;$L.Event.copy(evn);
		 if(callback)callback(_self);
	 };
	 if(text)this.setText(text);
	 if(iconCls)this.setIcon(iconCls);
}; 
/**图标按钮**/
$L.UI.IconButton=function(root,title,handle,toolIndex){
	var _self=this;title=$L.UI.Local.get(title);
    var main=$L.DOM.create("DIV",{},root);main.setClass("LIconButton");main.title=title;
	this.setBackground=function(bg,config,bg1,config1){_self.bg=bg;_self.config=config;_self.bg1=bg1;_self.config1=config1;_self.resunm();};
	this.setTools=function(index){
		this.toolIndex=index;
		config=" 0 -"+index*15;config1=" -15 -"+index*15;this.setBackground(_ThemeFactory.tools,config,_ThemeFactory.tools,config1);
	};
	this.getToolIndex=function(){return this.toolIndex;}; 
	this.resunm=function(){main.setBackground(_self.bg,_self.config);};
	this.on=function(){main.setBackground(_self.bg1,_self.config1);};
	this.hide=function(){main.hide();};this.show=function(){main.display();};
	this.getEl=function(){return main;};
	this.setLock=function(lockDom){this.lockDom=lockDom;};
	main.onmouseover=function(evn){_self.on();};
	main.onmouseout=function(evn){_self.resunm();};
	main.onmousedown=function(){if(_self.lockDom)_self.lockDom.lock();};
	main.onclick=function(evn){if(handle)handle(_self);};
	main.innerHTML=$L.SPAN;
	if(toolIndex)this.setTools(toolIndex);
};

//按钮的支持
$L.UI.Button=function(bar,text,width,height,callback){
     if(!width)width=50;if(!height)height=25;var root=$L.DOM.create("DIV",{},bar); var _self=this;$L.Css.float(root);
	 var round=new $L.UI.Round(root,3);var content=round.getEl();$L.Css.hand(root);content.setClass('LFont_Btn');
	 function statu0(){
		  $L.select(root);
	      round.setLeftTopBg(_ThemeFactory.btnBg);
	      round.setRightTopBg(_ThemeFactory.btnBg," -3 0");
		  round.setTopBg(_ThemeFactory.btnBg," 0 -6");
		  round.setLeftBg(_ThemeFactory.btnBg," 0 -24");
		  round.setRightBg(_ThemeFactory.btnBg," -3 -24");
		  round.setLeftBottomBg(_ThemeFactory.btnBg," 0 -3");
		  round.setRightBottomBg(_ThemeFactory.btnBg," -3 -3");
		  round.setBottomBg(_ThemeFactory.btnBg," 0 -15");
		  content.setBackground(_ThemeFactory.btnBg," 0 -1096");
	 };
	 function statu1(){
		  $L.unSelect(root);
		  round.setLeftTopBg(_ThemeFactory.btnBg,' -6 0');
	      round.setRightTopBg(_ThemeFactory.btnBg," -9 0");
		  round.setTopBg(_ThemeFactory.btnBg," 0 -9");
		  round.setLeftBg(_ThemeFactory.btnBg," -6 -24");
		  round.setRightBg(_ThemeFactory.btnBg," -9 -24");
		  round.setLeftBottomBg(_ThemeFactory.btnBg," -6 -3");
		  round.setRightBottomBg(_ThemeFactory.btnBg," -9 -3");
		  round.setBottomBg(_ThemeFactory.btnBg," 0 -18");
		  content.setBackground(_ThemeFactory.btnBg," 0 -2168");
	 };
	 function statu2(){
		  round.setLeftTopBg(_ThemeFactory.btnBg,' -12 0');
	      round.setRightTopBg(_ThemeFactory.btnBg," -15 0");
		  round.setTopBg(_ThemeFactory.btnBg," 0 -12");
		  round.setLeftBg(_ThemeFactory.btnBg," -12 -24");
		  round.setRightBg(_ThemeFactory.btnBg," -15 -24");
		  round.setLeftBottomBg(_ThemeFactory.btnBg," -12 -3");
		  round.setRightBottomBg(_ThemeFactory.btnBg," -15 -3");
		  round.setBottomBg(_ThemeFactory.btnBg," 0 -21");
		  content.setBackground(_ThemeFactory.btnBg," 0 -3240");
	 };
	 root.onmouseover=function(evn){$L.Event.copy(evn);statu1();};root.onmouseout=function(){statu0();};root.onmousedown=function(){statu2();};
	 root.onmouseup=function(evn){$L.Event.copy(evn);statu1();};root.onclick=function(){if(_self.handle)_self.handle();};
	 root.onclick=function(evn){$L.Event.copy(evn);if(callback)callback();};
	 this.doLayout=function(){
		 root.setSize(width,height);
		 round.doLayout(width,height);
	 };
	 this.setHandle=function(handle){callback=handle;};
	 this.setText=function(text,w,h){if(w)width=w;if(h)height=h;content.setText(text);this.doLayout();};
	 this.moveTo=function(x,y){root.moveTo(x,y);}; 
	 this.setText(text);statu0();
}; 


//面板的用法
$L.UI.Panel=function(root,w,h){
	this.isContainer=true;root=$L.UI.dom(root,w,h);var _self=this;var frame=$L.DOM.create("DIV",{},root);frame.setClass("LPanel");
	var titleEl=$L.DOM.create("DIV",{},frame);titleEl.setSize("100%",25);titleEl.hide();
	titleEl.setBackground(_ThemeFactory.bg);titleEl.setClass("LTitle"); 
	var titleIcon=$L.DOM.create("DIV",{},titleEl);titleIcon.setClass("LIcon");titleIcon.hide();
	var titleText=$L.DOM.create("DIV",{},titleEl);titleText.setClass("LTitleText LFont_PanelT");titleText.browserFont(12);
	var buttonsEl=$L.DOM.create("DIV",{},titleEl);buttonsEl.setClass("LButtons");
	buttonsEl=$L.DOM.create("DIV",{},buttonsEl);buttonsEl.setClass("LEL");
	var hiddenPanel=null;var showPanel=null;
	this.collapsible=function(){
	   if(hiddenPanel||showPanel)return;
	   hiddenPanel=this.addIconButton('shou.qi',function(){frame.sizeH(25);hiddenPanel.hide();showPanel.show();},4);
	   showPanel=this.addIconButton('zhan.kai',function(){
			 frame.sizeH(h);hiddenPanel.show();showPanel.hide();},5);
	   showPanel.hide();
	}; 
	this.addIconButton=function(title,handle,toolIndex){
		 var iconBtn=new $L.UI.IconButton(buttonsEl,title,handle);
		 if(!toolIndex)toolIndex=0;iconBtn.setTools(toolIndex);
	     return iconBtn;
	}; 
	this.setTitle=function(title){titleText.setText(title);titleEl.display();};
	this.setBgColor=function(color){if(!color)color="#FFF";main.style.backgroundColor=color;};
//工具栏的支持	
	var toolBar=null;var toolsEl=$L.DOM.create("DIV",{},frame);toolsEl.setClass("LPTools");toolsEl.hide();
	this.addButton=function(icon,text,handle,hasLine){
	    if(toolBar==null){toolBar=new $L.UI.ToolBar(toolsEl);toolsEl.display();}
		return toolBar.addButton(icon,text,handle,hasLine);
	};
//中间内容的支持
    var view=$L.DOM.create("DIV",{},frame);view.setClass("LPView");view.delayLayout=true;
	this.getView=function(){return view;};
	this.getEl=function(){return this.getView();};
	this.getContainer=function(){return this.getView();};
	this.setAutoScroll=function(){view.setStyles("overflow-y:auto;");};
//状态栏的支持
	var statuBar=null;var statuEl=$L.DOM.create("DIV",{},frame);statuEl.setClass("LPStatu");statuEl.hide();
	this.getTitleFrame=function(){return titleEl;};
	this.doLayout=function(){ 
		 var h=root.getHeight()-2;var w=root.getWidth()-2;if(!w||!h)return false;
		 frame.setSize(w,h);
	     var height=h-titleEl.getHeight()-toolsEl.getHeight()-statuEl.getHeight();
		 view.setHeight(height);
		 if(view.afterLayout)view.afterLayout();
		 return true;
	}; 
	new $L.UI.AutoLayout(this,root);//自动布局的支持 
};

/**TAB面板的支持**/
$L.UI.TabPanel=function(root,w,h){
	root=$L.UI.dom(root,w,h);var _self=this;var frame=$L.DOM.create("DIV",{},root);var allLen=5;
	var frameBar=$L.DOM.create("DIV",{},frame);frameBar.setPosition();var tabButtons=new Array(); 
	var btnBar=$L.DOM.create("DIV",{},frameBar);var btnBarLine=$L.DOM.create("DIV",{},frameBar);
	btnBar.setBackground(_ThemeFactory.tabBg);btnBarLine.setBackground(_ThemeFactory.tabBg," 0 -165");
	btnBar.setBorder("sxzy","1px solid #99BBE8");btnBarLine.setBorder("xzy","1px solid #99BBE8");
	var main=$L.DOM.create("DIV",{},frame);main.setBorder("xzy","1px solid #99BBE8");var active=null;
 
	function TabButton(text,handle,closeAble){
		tabButtons.push(this);var tabBtn=this;
		var btnFrame=$L.DOM.create("DIV",{},frameBar);
		var rectFrame=$L.DOM.create("DIV",{},btnFrame);rectFrame.setPosition();
		var line=$L.DOM.create("DIV",{},btnFrame);
		var rect=new $L.UI.RoundRect(rectFrame,"#8DB2E3");$L.Css.hand(btnFrame); 
		rect.skipBottom();var textEl=rect.getEl();
		var conEl=$L.DOM.create("DIV",{},main);conEl.setClass("TabContent");conEl.delayLayout=true;
		var closeBtn=$L.DOM.create("DIV",{},rectFrame);closeBtn.setBackground(_ThemeFactory.tabClose);
		closeBtn.setSize(11,11);closeBtn.toRight(3);closeBtn.toTop(3); 
		closeBtn.onclick=function(){
		   tabBtn.destroy();
		};
		
		btnFrame.onmouseover=function(){if(tabBtn.actived)return;rect.setBackground(_ThemeFactory.tabBg,0,-50);};
		btnFrame.onmouseout=function(){if(tabBtn.actived)return;tabBtn.init();};
		btnFrame.onclick=function(){
			for(var i=0;i<tabButtons.length;i++)tabButtons[i].init();
			tabBtn.active();
		}; 
		
		this.destroy=function(){
			if(active==this)active=null;
		    btnFrame.destroy();
			conEl.destroy();
			tabButtons.remove(tabBtn);
			_self.doLayout();
		}; 
		this.doLayout=function(){ 
		   if(!active)active=this;
		   var start=allLen;textEl.setText(text);btnFrame.toLeft(start);textEl.setClass("Font_Tab");
		   var len=text.getLength(13)+10;
		   if(len<70)len=70;btnFrame.toBottom(4);
		   btnFrame.setSize(len,22); 
		   allLen+=len+5;line.setSize(len,3);this.init();
		   rect.doLayout();
		   active.active();
		}; 
		this.init=function(){
			this.actived=false;conEl.hide();if(tabButtons[0]==tabBtn||!closeAble)closeBtn.hide();
			rect.bottom.setBackground("#8DB2E3");line.hide();
		    rect.setBackground(_ThemeFactory.tabBg,0,-80);btnFrame.toBottom(4);
			btnFrame.setHeight(22);rectFrame.setHeight(22);
		}; 
		this.active=function(){  
		    this.actived=true;conEl.display();active=this; 
		    line.display();btnFrame.setHeight(26);btnFrame.toBottom(0); 
		    rect.setBackground(_ThemeFactory.tabBg,0,-145,20);
			line.setBackground(_ThemeFactory.tabBg," 0 -165");
			rect.bottom.setBackground(_ThemeFactory.tabBg," 0 -165"); 
			if(typeof handle=='string'&&!conEl.init)conEl.setSrc(handle); 
			if(typeof handle=='function'&&!conEl.init)handle(); 
			conEl.setHeight(main.getHeight());
			if(conEl.afterLayout)conEl.afterLayout();
			conEl.init=true;
		};
		this.getEl=function(){return conEl;};
	}  
	
	this.doLayout=function(){
		 var h=root.getHeight();var w=root.getWidth();
		 if(!w||!h)return false;
		 frame.setSize(w,h);
		 btnBar.setSize(w-2,25);btnBarLine.setSize(w-2,3);allLen=5;
		 main.setSize(w-2,h-32);
		 for(var i=0;i<tabButtons.length;i++)tabButtons[i].doLayout(i);
		 return true;
	}; 
	
	this.add=function(title,handle,closeAble){
	   var tab=new TabButton(title,handle,closeAble); 
	   active=tab;
	   this.doLayout();
	   return tab;
	}; 
	new $L.UI.AutoLayout(this,root);//自动布局的支持 
};
 


//Window的支持
$L.UI.Window=function(w,h,href,parentWin){  
	 var _self=this;this.isContainer=true;
     var box=new $L.UI.Box();box.hide();var root=box.getEl();var boxRoot=box.getRoot();boxRoot.win=this; 
	 var frame=$L.DOM.create("DIV",{},root);frame.setClass("LWindow");
	 var rect=new $L.UI.RoundRect(frame,"#8DB2E3");rect.setBackground("#C6D4E4");var winHref="";
	 var viewFrame=rect.getEl();  
	 var titleEl=$L.DOM.create("DIV",{},viewFrame);titleEl.setClass("LTitle");
	 var titleIcon=$L.DOM.create("DIV",{},titleEl);titleIcon.setClass("LIcon");titleIcon.hide();
	 var titleText=$L.DOM.create("DIV",{},titleEl);titleText.setClass("LTitleText LFont_PanelT");
	 var buttonsEl=$L.DOM.create("DIV",{},titleEl);buttonsEl.setClass("LButtons");
	 buttonsEl=$L.DOM.create("DIV",{},buttonsEl);buttonsEl.setClass("LEL");
	 var closeBtn=new $L.UI.IconButton(buttonsEl,"guan.bi",function(){_self.hide();});
	 closeBtn.setBackground(_ThemeFactory.tools,' 0 0',_ThemeFactory.tools,' -15 0'); 
	 var sizeBtn=new $L.UI.IconButton(buttonsEl,"",function(){
		 if(sizeBtn.getToolIndex()==2){
		    sizeBtn.setTools(3);
		    _self.w=$L.getWidth()+10,_self.h=$L.getHeight(); _self.show();
			box.moveTo(-5,-5);
		 }else{
		    sizeBtn.setTools(2); _self.w=w,_self.h=h; _self.show();
			box.setCenter();
		 } 
	 },2);
	 closeBtn.setLock(titleEl);sizeBtn.setLock(titleEl); 
	 
	 var view=$L.DOM.create("DIV",{},viewFrame);view.setClass("LWinView");
	 var _view=$L.DOM.create("DIV",{},viewFrame);_view.setClass("LWinView_");_view.hide();
	 $L.Css.setAlpha(_view,30); 
	 
	 var bottomMargin=$L.DOM.MarginTop(viewFrame,3);bottomMargin.hide();
	 var tools=$L.DOM.create("DIV",{},viewFrame);tools.setClass("LWinTools");tools.hide();
	 
	 
	 box.setMoveAble(titleEl,function(){
        view.hide();_view.display(); 
		$L.Css.setAlpha(_view.parentNode.parentNode,30);
		 
	 },function(){
	    _view.hide();view.display();
		$L.Css.setAlpha(_view.parentNode.parentNode,100);
	 }); 
	 
//全屏和关闭的拦截器和触发器支持
     this.setParentWin=function(pw){parentWin=pw;};
	 this.setCloseAble=function(isCloseAble){if(!isCloseAble)closeBtn.hide();else closeBtn.show();};
	 this.setFullAble=function(isFullAble){if(!isFullAble)sizeBtn.hide();else sizeBtn.show();};
     this.setTitle=function(title){titleText.setText(title);};
	 this.getId=function(){return frame.getId();};
	 this.showBorder=function(){view.setStyles("border:1px solid #99BBE8;");};
	 this.isHidden=function(){return box.isHidden();}; 
	 this.hide=function(){if(this.beforeHide&&!this.beforeHide())return;
	     box.hide();
		 if(box.modle)$L.Mask.hide();
		 if(parentWin)parentWin.show();
		 if(this.afterHide)this.afterHide();
	 };
	 this.destroy=function(){this.hide();boxRoot.destroy();};
	 this.setModle=function(){box.modle=true;box.showMask();};
	 this.setSize=function(width,height){if(width)w=width;if(height)h=height;box.setSize(w,h);};
	 this.setCenter=function(){box.setCenter();};
	 this.setHref=function(href,pw){
		 this.init(pw);winHref=href;
		 var v=this.getView();v.setSrc(href);
	 };
	 this.getHref=function(){return winHref;};
	 this.addButton=function(text,width,height,handle,x,y){
		 tools.display();bottomMargin.display();
		 var btn=new $L.UI.Button(tools,text,width,height);
		 btn.setHandle(handle);
		 btn.moveTo(x,y);
		 return  btn;
	  }; 
	 this.getWindowX=function(){return boxRoot.getLeft();};
	 this.getWindowY=function(){return boxRoot.getTop();};
	 this.getView=function(){return view;}; 
	 this.getContainer=function(){return this.getView();};
	 this.init=function(pw){
	     this.setTitle("无标题窗口");
	     this.setCloseAble(false);this.setFullAble(false);
		 this.beforeHide=null;this.afterHide=null;
		 this.setParentWin(pw);
		 this.setValue=null;box.init();
		 winHref="";view.clear();
	 };
	 this.doLayout=function(){
	     var w=root.getWidth();var h=root.getHeight();
		 var th=tools.getHeight()+bottomMargin.getHeight(); 
		 view.setSize(w-2,h-th-26);_view.setSize(w-2,h-th-28);
		 rect.doLayout(); 
		 return true;
	 };  
	 this.show=function(){box.show();};
	 if(href){
	     this.setHref(href,parentWin);
	 } 
	 this.show();
	 this.setSize(w,h);
	 this.setCenter();
	
	 new $L.UI.AutoLayout(this,root);//自动布局的支持  
};


//Msg的支持
$L.UI.showMsg=function(title,msg,w,h){ 
   if($L.UI.messgaeBox){$L.UI.messgaeBox.show(title,msg,w,h);return;}
   $L.UI.messgaeBox=new function(){
        var messageBox=new $L.UI.Window(w,h);messageBox.setFullAble(false);
		var view=messageBox.getView();
		 
		messageBox.setModle(); 
		
		
		var ok=messageBox.addButton("确定",60,25);
		ok.setHandle(function(){messageBox.hide();});
		view.setClass('LWinView LFont_MsgBox'); 
		this.show=function(title,msg,w,h){
			
			if(!w||w<200)w=200;if(!h||h<110)h=110;messageBox.setSize(w,h);view.setText(msg);
			messageBox.setTitle(title); 
			ok.moveTo(parseInt((w-80)/2),0);
		};
   };
   $L.UI.messgaeBox.show(title,msg,w,h);
};

//对话框的支持
$L.UI.showDialog=function(title,msg,handle,w,h){
   if($L.UI.dialogBox){$L.UI.dialogBox.show(title,msg,handle,w,h);return;}
   $L.UI.dialogBox=new function(){
        var win=new $L.UI.Window(w,h);win.setFullAble(false);win.setCloseAble(false);
		var view=win.getView();win.setModle();var _self=this;
		var ok=win.addButton("确定",60,25,function(){
		     if(_self.callback)_self.callback(true);
			 win.hide();
		});
		var cancle=win.addButton("取消",60,25,function(){
		     if(_self.callback)_self.callback(false);
			 win.hide();
		},10); 
		view.setClass('LWinView LFont_MsgBox');
		this.show=function(title,msg,handle,w,h){
			_self.callback=handle;win.show();
			if(!w||w<250)w=250;if(!h)h=110;win.setSize(w,h);view.setText($L.SPAN+msg);
			win.setTitle(title);
			ok.moveTo(parseInt((w-160)/2),0);
			cancle.moveTo(parseInt((w-160)/2)+80,0);
			win.setCenter();
		};
   };
   $L.UI.dialogBox.show(title,msg,handle,w,h);
};

$L.UI.Tree=function(root,store){
	root=$L.DOM.getDom(root);var frame=$L.DOM.create("DIV",{},root);frame.setClass("LTree");frame.fbSelect();
	var tree=null;var frameId=frame.getId();var selectNode=null;var _self=this;var rootStore=null;
	//c1唯独一个 c2第一个  c3最后一个  c4中间的
	var _c={ 'c1plus':' 0 0','c2plus':' 0 0','c3plus':' 0 -19','c4plus':' 0 -32'
	        ,'c1minus':' -17 0','c2minus':' -17 0','c3minus':' -17 -19','c4minus':' -17 -32'
	        ,'c1line':' 0 -55','c2line':' 0 -55','c3line':' -17 -55','c4line':' 0 -73'
			,'f':' 0 -110','fopen':' -17 -110','d':' 0 -130' 
	};  
	function unselectAll(){
	     var ns=$L.DOM.tagName("DIV",frame);
		 for(var i=0;i<ns.length;i++){
		     if(ns[i].className!='LTreeNode')continue;
			 ns[i].selected=false;ns[i].setBgColor("#FFF");
		 }
		 selectNode=null;
	}
	function TrNode(p,r,rs){
		var node=$L.DOM.create("DIV",{},p);node.setClass("LTreeNode");node.record=r;node.records=rs;
		node.onmouseover=function(){if(this.selected)return;this.setBgColor("#EEEEEE");};
		node.onmouseout=function(){if(this.selected)return;this.setBgColor("#FFF");}; 
		var tp=p;var _nSelf=this;var sIcon="";var lines=new Array();
		for(var i=0;i<100;i++){ 
			if(tp==frame)break;
			var line=$L.DOM.create("DIV",{},node);line.setClass("LTIcon");		   
			line.tp=tp;lines.push(line);tp=tp.parentNode;
		}
		var tp=p;
		for(var i=0;i<lines.length;i++){
		    if(lines[i].tp.record&&!lines[i].tp.record.isEnd)
			    lines[lines.length-i-1].setBackground(_ThemeFactory.tree_bg,_c.c1line); 
		} 
		var statuIcon=$L.DOM.create("DIV",{},node);statuIcon.setClass("LTIcon"); 
		var icon=$L.DOM.create("DIV",{},node);icon.setClass("LTIcon");
		var text=$L.DOM.create("DIV",{},node);text.setClass("LTText LFont_Tree");
		var panel=$L.DOM.create("DIV",{},p);panel.setClass("LTPanel");panel.hide(); 
		panel.record=r;panel.records=rs; 
		this.open=function(){
		    var n=sIcon+'minus'; 
		    icon.setBackground(_ThemeFactory.tree_bg,_c.f); 
		    statuIcon.setBackground(_ThemeFactory.tree_bg,_c[n]);
		    this.opened=true;
		    var id=r.getValue(); 
		    updateTree(panel,id); 
		    panel.display(); 
		};
		this.close=function(){
		   var n=sIcon+'plus'; 
		   icon.setBackground(_ThemeFactory.tree_bg,_c.fopen); 
		   statuIcon.setBackground(_ThemeFactory.tree_bg,_c[n]);
		   this.opened=false;
		   panel.hide();
		};
		r.open=this.open;
		
		if(r.isEnd)sIcon="c3";
		else if(r.isFirst)sIcon="c2"; 
	    else sIcon="c4"; 
		if(r.hasSon){//有子 
		   statuIcon.setBackground(_ThemeFactory.tree_bg,_c[sIcon+'plus']);
		   icon.setBackground(_ThemeFactory.tree_bg,_c.f); 
		   
		   node.onclick=function(){
				unselectAll();
				this.selected=true;this.setBgColor("#D9E8FB");
				if(_nSelf.opened)_nSelf.close();
				else _nSelf.open();
				selectNode=this;
				if(_self.clickHandle)_self.clickHandle(r,rs);
		    }; 
		}else{//无子
		     statuIcon.setBackground(_ThemeFactory.tree_bg,_c[sIcon+'line']);
		     icon.setBackground(_ThemeFactory.tree_bg,_c.d);
			 node.onclick=function(){
				 unselectAll();this.selected=true;this.setBgColor("#D9E8FB");
				 selectNode=node;
				 if(_self.clickHandle)_self.clickHandle(r,rs,true);
				 
			 };
		}  
	    text.setText(r.getLabel());
	}
	this.getSons=function(){
	   if(!selectNode)return new Array();
	   var ts=tree.getSons(selectNode.record);
	   var ids="";
	   for(var i=0;i<ts.length;i++){if(ids.length>0)ids+=",";ids+=ts[i].getValue();}
	   return ids;
	};
	
	this.getSelect=function(){ 
	    if(!selectNode)return null;
	    return selectNode.record;
	}; 
	this.addHandle=function(clickHandle){
	    this.clickHandle=clickHandle; 
	};
	function updateTree(p,pid){
	    var rs=tree.getRecords(pid);p.clear();
		if(p==frame)$L.DOM.MarginTop(frame,10);
        for(var i=0;i<rs.length;i++){
	       var node=new TrNode(p,rs[i],rs);
		}
	}
	this.setStore=function(s,treeField){
		if(!s)return;
		store=s;
		if(treeField){
		   var ts=treeField.split(",");
		   s.setTree(ts[0],ts[1],ts[2]); 
		}
	    tree=s.getTree(rootStore); 
		updateTree(frame);
		selectNode=null;
	};
	
	function openTree(r){
	    if(!r)return;
		var pid=r.get("filter");
		var pr=tree.getRecord(pid);
		if(pr){
		   openTree(pr); 
		} 
		r.open();
	}
	
	this.openTo=function(key){
	     var r=tree.getRecord(key);
		 openTree(r);
	}; 
	this.setRootStore=function(s){rootStore=s;};
	 
	this.setStore(store);
};


//标题对象的支持
$L.UI.Title=function(root){
    var titleEl=$L.DOM.create("DIV",{},root);titleEl.setSize("100%",25);
	titleEl.setBackground(_ThemeFactory.bg);titleEl.setClass("LTitle"); 
	var titleIcon=$L.DOM.create("DIV",{},titleEl);titleIcon.setClass("LIcon");titleIcon.hide();
	var titleText=$L.DOM.create("DIV",{},titleEl);titleText.setClass("LTitleText LFont_PanelT");titleText.browserFont(12);
	var buttonsEl=$L.DOM.create("DIV",{},titleEl);buttonsEl.setClass("LButtons");
	buttonsEl=$L.DOM.create("DIV",{},buttonsEl);buttonsEl.setClass("LEL");
	this.setText=function(text){titleText.setText(text);};
	this.getHeight=function(){return titleEl.getHeight();};
	this.display=function(){titleEl.display();};
	this.hide=function(){titleEl.hide();};
	this.addIconButton=function(title,handle,toolIndex){
		 var iconBtn=new $L.UI.IconButton(buttonsEl,title,handle);
		 if(!toolIndex)toolIndex=0;iconBtn.setTools(toolIndex);
	     return iconBtn;
	}; 
};



$L.UI.Grid=function(root){
     root=$L.UI.dom(root);var _self=this;var store=null;var field=new Array();
	 var frame=$L.DOM.create("DIV",{},root);frame.setClass("LGrid");var targetRow=null;var headBox=null;
	 var title=new $L.UI.Title(frame);var openIndex=false,openSelect=false;
	 var tools=new $L.UI.ToolBar(frame);tools.hide();
	 var searchPanel=$L.DOM.create("DIV",{},frame);searchPanel.setSize("100%",70);searchPanel.setClass("LGSearch");
	 $L.DOM.MarginTop(searchPanel,10);searchPanel.hide();
	 var head=$L.DOM.create("DIV",{},frame);var headH=24;head.setBackground(_ThemeFactory.grid_hbg1);
	 var view=$L.DOM.create("DIV",{},frame);view.setClass("LGView");  
	 var pagingBar=new $L.UI.ToolBar(frame);pagingBar.hide();
	 var heads=new Array();var rows=new Array();
	 
	 frame.onmouseover=function(){$L.unSelect();};
	 frame.onmouseout=function(){$L.select();};
	 var hiddenPanel=title.addIconButton('shou.qi',function(){_self.hideSearch();},4);
	 var showPanel=title.addIconButton('zhan.kai',function(){_self.showSearch();},5); 
	 hiddenPanel.hide();showPanel.hide();
	 
//初始化	 
	 function init(){
	    head.clear();view.clear();heads=new Array();rows=new Array();targetRow=null;
	 }	  
//选择插件	 
	 function CheckBox(dom,isHead){
	     var box=$L.DOM.create("DIV",{},dom);box.setClass("LGVHeadBox");this.isCheck=false;
		 box.setBackground(_ThemeFactory.grid_rowbox);
		 if(isHead){
			headBox=this;
		    box.onclick=function(){
				 if(_self.singleSelect)return;
				 if(_self.isSelectAll()){
					 for(var i=0;i<rows.length;i++)rows[i].unSelect();
					 headBox.unChecked();
				 }else{
					 for(var i=0;i<rows.length;i++)rows[i].select(true);
					 headBox.checked();
				 }
			 }; 
		 } 
		 this.checked=function(){box.setBackground(_ThemeFactory.grid_rowbox," -25 0");this.isCheck=true;};
		 this.unChecked=function(){box.setBackground(_ThemeFactory.grid_rowbox);this.isCheck=false;}; 
	 }
//表头的支持
	 function Head(name,text,_w,locked){
		  this.name=name;heads.push(this);if(!_w)_w=100;var _hSelf=this;this.isDisplay=true;
	      var column=$L.DOM.create("DIV",{},head);column.setClass("LGHColumn");this.columns=new Array();
		  var textEl=$L.DOM.create("DIV",{},column);textEl.setClass("LGHText");
		  if(name=="l.checkbox")new CheckBox(textEl,true);
		  else if(name=="l.index")textEl.setText();
		  else textEl.setText(text);
		  var columnBtn=$L.DOM.create("DIV",{},column);columnBtn.setClass("LGHBtn");
		  columnBtn.setBackground(_ThemeFactory.grid_hbtn," 0 -10px");columnBtn.hide(); 
		  var line=$L.DOM.create("DIV",{},head);line.setClass("LGHLine");
		  line.getMin=function(){return column.getLeft()+20;};
		  line.moveAble=true;line.moveHeight=function(){return line.getHeight()+view.getHeight();};
		  if(!locked)new $L.MoveLine(line,"y",function(mw,mh){_w+=mw;column.lock(1000);head.doLayout();},frame);
		  else line.setClass("LGHLineLock");
		  column.onmouseover=function(){if(locked)return;this.setBackground(_ThemeFactory.grid_hbg2);columnBtn.display();};
		  column.onmouseout=function(){if(locked)return;this.setBackground(_ThemeFactory.grid_hbg1);columnBtn.hide();};
		  columnBtn.onmouseover=function(){this.setBackground(_ThemeFactory.grid_hbtn," -14 -10");};
		  columnBtn.onmouseout=function(){this.setBackground(_ThemeFactory.grid_hbtn," 0 -10");};
		  this.display=function(){_hSelf.isDisplay=true;column.display();line.display();};
		  this.hide=function(){_hSelf.isDisplay=false;column.hide();line.hide();};
		  this.getWidth=function(){if(!_hSelf.display)return 0;return _w;};
		  this.addWidth=function(aw){if(aw)_w+=aw;};
		  this.setWidth=function(w){if(w)_w=w;};
		  this.doLayout=function(){
			  column.setWidth(_w-1);textEl.setWidth(_w-1); 
			  for(var i=0;i<this.columns.length;i++)this.columns[i].doLayout();
		  };
		  this.isLocked=function(){return column.locked||locked;};
	 }
//列对象
	 function Column(head,row){
		  head.columns.push(this);var len=0;
	      var column=$L.DOM.create("DIV",{},row.getEl());column.setClass("LGVColumn");
	      var n=head.name;var record=row.record; var value=record.get(n);
		  if(record.get(n+".label"))value=record.get(n+".label");
		  
		  if(_self.rowHandle)value=_self.rowHandle(n,value); 
		  if(n=="l.index"){
			  var line=$L.DOM.create("DIV",{},row.getEl());line.setClass("LGHLine");
		      len=1;column.setBackground(_ThemeFactory.grid_index);
			  column.setText(row.index+1+$L.SPAN);column.style.textAlign="right";
			  row.addHandle(function(){
			      if(row.selected)column.setBackground(_ThemeFactory.grid_indexSel);
				  else column.setBackground(_ThemeFactory.grid_index);
			  });
		  }else if(n=="l.checkbox"){
		      var cbox=new CheckBox(column); 
			  row.addHandle(function(){
			      if(row.selected)cbox.checked();
				  else cbox.unChecked();
				  if(_self.isSelectAll()) headBox.checked();
				  else headBox.unChecked();
			  });
		  } else column.setText($L.SPAN+value); 
		  this.doLayout=function(){
			  column.setWidth(head.getWidth()-len);
		  };
		  this.doLayout();
	 }
//行对象
	 function Row(index,rs){
	      rows.push(this);var row=$L.DOM.create("DIV",{},view);row.setClass("LGVRow");var _rSelf=this;
		  row.index=index;row.record=rs[index];this.index=index;this.record=row.record;
		  row.bgcolor="#FAFAFA";if(index%2==0)row.bgcolor="#FFF";var handles=new Array();
		  row.setBgColor(row.bgcolor);
		  row.onmouseover=function(){
		      if(this.selected)this.setBackground(_ThemeFactory.grid_rbg3);else this.setBackground(_ThemeFactory.grid_rbg2);
		  };
		  row.onmouseout=function(){
			    if(this.selected){this.setBackground(_ThemeFactory.grid_rbg3);}else {this.setBackground(this.bgcolor);}
		  };
		  this.select=function(shifPress){row.select(shifPress);};
		  this.getEl=function(){return row;};
		  this.addHandle=function(handle){handles.push(handle);};
		  this.unSelect=function(){row.unSelect();};
		  row.select=function(shifPress){
			  if(!shifPress)for(var i=0;i<rows.length;i++)rows[i].unSelect();
			  this.selected=true;_rSelf.selected=true;
			  row.setBackground(_ThemeFactory.grid_rbg3); row.setClass("LGVRowSel");
			  for(var i=0;i<handles.length;i++)handles[i](true);
		  };
		  row.unSelect=function(){
			  this.selected=false;_rSelf.selected=false;
			  row.setBackground(row.bgcolor);row.setClass("LGVRow");
			  for(var i=0;i<handles.length;i++)handles[i]();
		  };
		  row.onclick=function(e){
			  $L.Event.copy(e); 
			  if(_self.singleSelected){//单选 
				  this.select();
				  if(_self.changeHandle)_self.changeHandle(_self.getSelectRecords()[0]);
				  return;
			  } 
			  if(event.ctrlKey){//Ctrl按键的支持
			       if(this.selected)this.unSelect();
				   else{this.select(true);}targetRow=_rSelf;return;
			  }
			  if(event.shiftKey&&targetRow){//shiftKey按键支持
			       var m1=targetRow.index;var m2=index;
			       var start=m1,end=m2;if(m1>m2){start=m2;end=m1;}
			       for(var i=start;i<end;i++){rows[i].select(true);}
				   return;
			  }
			  this.select();
			  targetRow=_rSelf; 
		  };
		  for(var i=0;i<heads.length;i++)new Column(heads[i],this);
	 } 
	 head.doLayout=function(){
	     var w=root.getWidth();var allLen=0;var num=0
		 for(var i=0;i<heads.length;i++){
			if(!heads[i].isDisplay)continue;
		    allLen+=heads[i].getWidth();
			if(!heads[i].isLocked())num++;
		 }
		 var len=parseInt((w-allLen-20)/num); 
		 for(var i=0;i<heads.length;i++){if(!heads[i].isLocked())heads[i].addWidth(len);}
		 for(var i=0;i<heads.length;i++){heads[i].doLayout();}
	 }; 
	 this.doLayout=function(){
		var w=root.getWidth();var h=root.getHeight();
		if(!w||!h)return false;
		frame.setSize(w,h);
		var ph=pagingBar.getHeight();
		var spH=searchPanel.getHeight();
		var th=title.getHeight();var bh=tools.getHeight();
		head.setSize(w,headH);view.setSize(w,h-headH-spH-ph-th-bh-2);
		head.doLayout();
		return true;
	 };   
	 this.setStore=function(s,f){
		 if(!s)return;store=s;init();
		 if(openIndex)new Head("l.index","",24,true);
		 if(openSelect)new Head("l.checkbox","",30,true);
		 if(f)field=f.split(",");
		 for(var i=0;i<field.length;i++){new Head(field[i],store.getLabel(field[i]));}
		 this.refreshView();
		 this.doLayout();
	 };
	 this.refreshView=function(){
	     var rs=store.getRecords();
		 for(var i=0;i<heads.length;i++)heads[i].columns=new Array();
		 for(var i=0;i<rs.length;i++)new Row(i,rs);
	 }; 
	 this.openIndex=function(){openIndex=true;this.setStore(store);};
	 this.openSelect=function(){openSelect=true;this.setStore(store);};
	 this.getRecords=function(){return store.getRecords();};
	 this.getSelectRecords=function(){var rs=new Array();for(var i=0;i<rows.length;i++){if(rows[i].selected)rs.push(rows[i].record);}return rs;};
	 this.isSelectAll=function(){for(var i=0;i<rows.length;i++)if(!rows[i].selected)return false;return true;};
     this.setTitle=function(text){title.setText(text);};
	 this.getPageTools=function(){return pagingBar;};
	 this.getSearchs=function(){if(!this.forms)this.forms=new Array();return this.forms;};
	 this.getSearchPanel=function(){return searchPanel;};
	 this.singleSelect=function(handle){_self.singleSelected=true;_self.changeHandle=handle;};
	 this.addButton=function(icon,text,handle,hasLine){
	     tools.display();
		 return tools.addButton(icon,text,handle,hasLine);
	 };
	 this.hideSearch=function(){hiddenPanel.hide();showPanel.show();searchPanel.hide();_self.doLayout();};
	 this.showSearch=function(){hiddenPanel.show();showPanel.hide();searchPanel.display();_self.doLayout();};
	 new $L.UI.AutoLayout(this,root);//自动布局的支持 
};


//from的支持
$L.UI.Form=new Object();
$L.UI.Form.hideDateBox=function(){if(this.dateBox){this.dateBox.hide();}};
//时间控件的支持
$L.UI.Form.showDateBox=function(dom,handle){
    if(this.dateBox){this.dateBox.show(dom,handle);return;}
	this.dateBox=new function(){
        var box=new $L.UI.Box();var root=box.getEl();box.setSize(175,200);
		var frame=$L.DOM.create("DIV",{},root);frame.setClass("LFormDate");var _self=this;
		var topFrame=$L.DOM.create("DIV",{},frame);topFrame.setClass("LFDateTop");topFrame.setBackground(_ThemeFactory.form_dateBg,' 0 -25');
		var lastMonth=$L.DOM.create("DIV",{},topFrame);lastMonth.setClass("LFDateLast");lastMonth.setBackground(_ThemeFactory.form_dateBtns,' 0 0');
		lastMonth.onmouseover=function(){this.setBackground(_ThemeFactory.form_dateBtns,' -25 0');};
		lastMonth.onmouseout=function(){this.setBackground(_ThemeFactory.form_dateBtns,' 0 0');clearInterval(this.intervalId);};
		lastMonth.onmousedown=function(){_self.lastMonth();this.intervalId=setInterval(function(){_self.lastMonth();},300);};
		lastMonth.onmouseup=function(){clearInterval(this.intervalId);};
		var nextMonth=$L.DOM.create("DIV",{},topFrame);nextMonth.setClass("LFDateNext");nextMonth.setBackground(_ThemeFactory.form_dateBtns,' 0 -25');
		nextMonth.onmouseover=function(){this.setBackground(_ThemeFactory.form_dateBtns,' -25 -25');};
		nextMonth.onmouseout=function(){this.setBackground(_ThemeFactory.form_dateBtns,' 0 -25');clearInterval(this.intervalId);};
		nextMonth.onmousedown=function(){_self.nextMonth();this.intervalId=setInterval(function(){_self.nextMonth();},300);};
		nextMonth.onmouseup=function(){clearInterval(this.intervalId);};
		var yearMonth=$L.DOM.create("DIV",{},topFrame);yearMonth.setClass("LFDateYearMonth LFont_DateBoxTitle");
		var weekBar=$L.DOM.create("DIV",{},frame);weekBar.setClass("LFDateWeek");weekBar.setBackground(_ThemeFactory.form_dateBg,' 0 0');
		for(var i=0;i<7;i++){
		    var weekLabel=$L.DOM.create("DIV",{},weekBar);weekLabel.setClass("LFDateWeekLabel");
			weekLabel.setText($L.UI.Local.get('week.'+i)); weekLabel.browserFont(12);
		}
		var content=$L.DOM.create("DIV",{},frame);content.setClass("LFDateContent");dayDoms=new Array();
		for(var i=0;i<6;i++){
		    var rowBar=$L.DOM.create("DIV",{},content);rowBar.setClass("LFDateContentBar");
			for(var j=0;j<7;j++){ 
			    var dayLabel=$L.DOM.create("DIV",{},rowBar);dayLabel.setClass("LFDateDay");dayLabel.browserFont(12);
				dayLabel.setText("");dayDoms.push(dayLabel);
				dayLabel.onclick=function(){
					if(_self.dom)_self.dom.value=_self.year+"-"+_self.month+"-"+this.day;
				    if(_self.callBack)_self.callBack(_self.year,_self.month,this.day);
					_self.hide();
				};
				dayLabel.setDay=function(day,dis){
					this.dis=dis;this.day=day;
					this.setText(day);
					if(dis)this.style.color="#CCC";else this.style.color="#000";
				};
			}

		}
		var bottomBar=$L.DOM.create("DIV",{},frame);bottomBar.setClass("LFDateBottom");bottomBar.setBackground(_ThemeFactory.form_dateBg,' 0 -60');
		var today=$L.DOM.create("DIV",{},bottomBar);today.setClass("LFDateTodayBtn");
		var btn=new $L.UI.Button(today,"当前日期",70,25);
		this.changeDays=function(year,month){
			 var d=new $L.Date(year,month,1);this.year=d.getYear();this.month=d.getMonth();
		     var text=this.year+" "+$L.UI.Local.get('month.'+this.month);yearMonth.setText(text);
			 var max1=d.getMaxDay();var max0=d.getMaxDay(-1);var k=d.getWeek();

			 for(var i=0;i<k;i++)dayDoms[i].setDay(max0-k+i+1,true);
			 for(var i=0;i<max1;i++,k++)dayDoms[k].setDay(i+1,false);
			 for(var i=0;k<dayDoms.length;i++,k++){dayDoms[k].setDay(i+1,true);}
		}; 
		this.lastMonth=function(){if(this.month!=1)this.changeDays(this.year,this.month-1);else this.changeDays(this.year-1,12);};
		this.nextMonth=function(){if(this.month!=12)this.changeDays(this.year,this.month+1);else this.changeDays(this.year+1,1);};
		box.moveTo(200,200);
		this.show=function(dom,callBack){
			  _self.dom=dom;
			  _self.callBack=callBack;box.show(dom);
			  this.changeDays();
		};
		this.hide=function(){box.hide();};
	}; 
	this.dateBox.show(dom,handle);
};


//下拉菜单框
$L.UI.Form.showComboBox=function(dom,w,store,handle){
	if(this.comboBox){this.comboBox.show(dom,w,store,handle);return this.comboBox;}
	this.comboBox=new function(){
	     var box=new $L.UI.Box();var root=box.getEl();
	     var frame=$L.DOM.create("DIV",{},root);frame.setClass("LFormComBobox");var _self=this;
		 this.show=function(dom,w,store,handle){ 
			 frame.clear();if(!store){return;}
			 var rs=store.getRecords();var h=rs.length*20+20;_self.callBack=handle;
		     box.setSize(w,h,dom);$L.DOM.MarginTop(frame,10);
			 for(var i=0;i<rs.length;i++){
			     var row=$L.DOM.create("DIV",{},frame);row.setClass("LFormComBoboxRow");
			     row.setText(rs[i].getLabel());
				 row.onmouseover=function(){this.setClass("LFormComBoboxRowOn");};
				 row.onmouseout=function(){this.setClass("LFormComBoboxRow");};
				 row.setWidth(frame.getWidth()-5);row.record=rs[i];
				 row.onclick=function(){box.hide();if(_self.callBack)(_self.callBack(this.record));};
				 row.unselectable="on";
			 }
			 box.show(dom);
		 };
	};
	this.comboBox.show(dom,w,store,handle); return this.comboBox;
}; 


$L.UI.Line=function(root,color,s,x,z,y){ 
     var line=$L.DOM.create("DIV",{},root);
	 line.setBackground(color);line.style.position="absolute";
	 if(s!=null)line.style.top=s+"px";
	 if(x!=null)line.style.bottom=x+"px";
	 if(z!=null)line.style.left=z+"px";
	 if(y!=null)line.style.right=y+"px";
	 this.setSize=function(w,h){line.setSize(w,h);};
	 this.getEl=function(){return line;};
	 this.hide=function(){line.hide();};
	 this.display=function(){line.display();};
};

//FORM的SET支持
$L.UI.Form.Set=function(root,w){
	root=$L.UI.dom(root);this.isContainer=true;var _self=this;
	var frame=$L.DOM.create("DIV",{},root);frame.setClass("LFORMSet"); 
	$L.DOM.MarginTop(frame,25);var o=5;var c=4;
	var content=$L.DOM.create("DIV",{},frame);content.setClass("LFSetContent");
	$L.DOM.MarginTop(frame,10);var hlen=10;
	var top=new $L.UI.Line(frame,"#CCC",hlen,null,0,null);top.setSize("100%",1); 
	var left=new $L.UI.Line(frame,"#CCC",hlen,null,0,null);left.setSize(1,1);
	var right=new $L.UI.Line(frame,"#CCC",hlen,null,null,0);right.setSize(1,1);
	var bottom=new $L.UI.Line(frame,"#CCC",null,0,0,null);bottom.setSize("100%",1);
	
	var textFrame=$L.DOM.create("DIV",{},frame);textFrame.setHeight(20);textFrame.moveTo(46,0);textFrame.setBackground("#FFF");
	textFrame.setStyles("line-height:22px; font-size:13px;color:#15428B;font-weight:bold;");
	var titleIcon=$L.DOM.create("DIV",{},frame); titleIcon.setSize(16,16);titleIcon.moveTo(30,3);
	var icon=new $L.UI.IconButton(titleIcon,'shou.qi',function(){},c);icon.hide();
	  
	titleIcon.onclick=function(){  
	     _self.statu=!_self.statu;
		 if(_self.statu)_self.close();
		 else _self.open(); 
	};
	   
	this.close=function(){
	   left.hide();right.hide();bottom.hide();
	   content.hide();
	   icon.setTools(o);
	   _self.statu=true;
	};
	
	this.open=function(){
	   left.display();right.display();bottom.display();
	   content.display();
	   icon.setTools(c);
	   _self.statu=false;
	};
	  
	this.doLayout=function(){
	   var width=w; 
	   if(width<1||width==1)width=parseInt(root.getWidth()*w)-20;
	   frame.setWidth(width);
	   left.setSize(1,frame.getHeight()-hlen);right.setSize(1,frame.getHeight()-hlen);
	   
	};
	
	this.setTitle=function(title){textFrame.setText($L.SPAN+title);};
	this.closeAble=function(oi,ci){icon.show();if(oi)o=oi;if(ci)c=ci;};
	this.getEl=function(){return content;};
	this.getContainer=function(){return this.getEl();}; 
	 
	new $L.UI.AutoLayout(this,root);//自动布局的支持 
};
//FORM面板的支持
$L.UI.Form.FormPanel=function(mainBox){
     var set=null;var textArrays=new Array();
	 this.createSet=function(root,title,closeAble,percentage){
		 if(!root)root=mainBox;if(!percentage)percentage=1;
	     set=new $L.UI.Form.Set(root,percentage);
		 if(closeAble)set.closeAble();set.setTitle(title,true); 
		 return set;
	 };
	 if(name=="l.checkbox")new CheckBox(textEl,this);
	 this.setMargin=function(height){$L.DOM.MarginTop(root,height);}; 
	 this.addText=function(label,name,width,lw){
		 var text=new $L.UI.Form.Text(label,name,width,set.getEl(),null,lw);
	     textArrays.push(text);
		 set.doLayout();
		 return text;
	 };
	 this.addNumber=function(label,name,width,lw){
	     var text=this.addText(label,name,width,lw);
		 text.addKeyUp(function(el){el.value=el.value.replace(/\D/,"");});
		 set.doLayout();
		 return text;
	 };
	 this.addTextArea=function(text,name,width,height,lw){
	     var text=new $L.UI.Form.TextArea(text,name,width,height,set.getEl(),lw);
		 textArrays.push(text);
		 set.doLayout();
		 return text;
	 };
	 this.addEdit=function(name,w,h){
	     var edit=new $L.UI.QQEdit(name,set.getEl(),w,h);
		 textArrays.push(edit);
	 };
	 this.addHidden=function(name,value){
	     var hidden=new $L.UI.Form.Hidden(name,value,set.getEl());
		 textArrays.push(hidden);
		 set.doLayout();
		 return hidden;
	 };
	 this.addPassword=function(label,name,width,lw){
		 var psw=new $L.UI.Form.Text(label,name,width,set.getEl(),'psw',lw);
	     textArrays.push(psw);
		 set.doLayout();
		 return psw;
	 };
	 this.addDate=function(label,name,width,lw){
		 var date=new $L.UI.Form.DateText(label,name,width,set.getEl(),lw);
		 var input=date.getInput();
	     textArrays.push(input);
		 set.doLayout();
		 return input;
	 };
	 this.reSet=function(){for(var i=0;i<textArrays.length;i++)textArrays[i].setValue("");};
	 this.addComboBox=function(label,name,width,store,lw){
		 var comboBox=new $L.UI.Form.ComboBox(label,name,width,set.getEl(),store,lw); 
		 var input=comboBox.getInput();
	     textArrays.push(input);
		 set.doLayout();
		 return comboBox;
	 };
	 this.addSearch=function(label,name,width,src,lw){
		 var search=new $L.UI.Form.SearchBox(label,name,width,set.getEl(),src,lw);
		 var input=search.getInput();
	     textArrays.push(input);
		 set.doLayout();
		 return search;
	 };
	 this.addUpload=function(label,name,width,lw){
		 var uload=new $L.UI.Form.UploadBox(label,name,width,set.getEl(),lw);
		 var input=uload.getInput();
	     textArrays.push(input);
		 set.doLayout();
		 return uload;
	 };
	 this.addRadioBox=function(label,name,width,store,lw,Columns){ 
	    var box=new $L.UI.Form.RadioBox(label,name,width,set.getEl(),store,lw,'radio');
		if(Columns)box.setColumns(Columns);
		textArrays.push(box);
		set.doLayout();
		return box;
	 };
	 this.addCheckBox=function(label,name,width,store,lw,Columns){ 
	    var box=new $L.UI.Form.RadioBox(label,name,width,set.getEl(),store,lw,'checkBox');
		if(Columns)box.setColumns(Columns);
		textArrays.push(box);
		set.doLayout();
		return box;
	 }; 
	 this.getValues=function(){
	    var ps={};
		for(var i=0;i<textArrays.length;i++){
		   var ta=textArrays[i];
		   ps[ta.getName()]=ta.getValue();
		} 
		return ps;
	 }; 
	 this.load=function(ps){
	    for(var i=0;i<textArrays.length;i++){
		   var n=textArrays[i].getName();
		   textArrays[i].setValue(ps[n]); 
		}
	 }; 
	 this.getAllText=function(){return textArrays;};
};


// 
$L.UI.Form.Hidden=function(name,value,dom){
	 name=name.toLowerCase();
     var inputEl=$L.DOM.create("INPUT",{'name':name,'type':'hidden'},dom);
	 if(value)inputEl.value=value;
     this.getValue=function(){return inputEl.value;};
	 this.setValue=function(value){inputEl.value=value;};
	 this.getName=function(){return name;};
};
//单选框
$L.UI.Form.RadioBox=function(label,name,width,dom,store,lw,type){
	  name=name.toLowerCase();
	  if(typeof store=='string')store=$Store(store);if(!type)type="radio";var arrays=new Array();
      var textFrame=$L.DOM.create("DIV",{},dom);textFrame.setClass("LFORMRadio");textFrame.setWidth(width);
	  var labelEl=$L.DOM.create("DIV",{},textFrame);labelEl.setClass("LFormlabel");labelEl.setText(label+":");
	  var inputEl=$L.DOM.create("INPUT",{'name':name,'type':'hidden'},textFrame);this.columns=1;var _self=this;
	  var inputDiv=$L.DOM.create("DIV",{},textFrame);inputDiv.setClass("LFormInput"); 
	  function Box(r){
	      var box=$L.DOM.create("DIV",{},inputDiv);box.setClass("LFormBox");
		  var selFrame=$L.DOM.create("DIV",{},box);selFrame.setClass("LFormBoxFrame");
	      var sel=$L.DOM.create("INPUT",{'name':name+"-box",'type':type},selFrame);sel.value=r.get("value");
		  var label=$L.DOM.create("LABEL",{'for':sel.getId()},box);label.setText(r.get("label"));
		  arrays.push(sel);
		  box.onclick=function(){checkValues();};
	  } 
	  function checkValues(){
		  var values="";
	      for(var i=0;i<arrays.length;i++){
			 if(!arrays[i].checked)continue;
		     if(values.length>0)values+=",";
			 values+=arrays[i].value; 
		  }
		  inputEl.value=values;
	  }
	  function selectCheck(){
		  for(var i=0;i<arrays.length;i++)arrays[i].checked=false;
	      for(var i=0;i<arrays.length;i++){
			  var msg=","+inputEl.value+",";var itemValue=arrays[i].value;
			  if(msg.indexOf(","+itemValue+",")!=-1)arrays[i].checked=true;
		  }
	  }
	  function loadItem(rs){
	     inputDiv.clear();arrays=new Array();
	     for(var i=0;i<rs.length;i++)new Box(rs[i]); 
		 _self.setColumns();
	  }  
	  this.getValue=function(){checkValues();return inputEl.value;};
	  this.getName=function(){return name;};
	  this.setValue=function(value){if(!value)value="";inputEl.value=value;selectCheck();};
	  this.doLayout=function(){
		 var labelWidth=dom.labelWidth;if(lw)labelWidth=lw;if(!labelWidth)labelWidth=55;labelEl.setWidth(labelWidth);
		 for(var i=0;i<arrays.length;i++){
			 if(this.columns<2)arrays[i].parentNode.parentNode.setWidth("100%");
			 else{
			    var w=parseInt((width-labelWidth)/this.columns)-1;arrays[i].parentNode.parentNode.setWidth(w);
				
			 }
		 } 
	  };
	  this.setColumns=function(c){if(c)this.columns=c;this.doLayout();};
	  loadItem(store.getRecords());
};
//文本输入框
$L.UI.Form.Text=function(text,name,width,dom,type,lw){
	 name=name.toLowerCase();
	 var inputType='text';if(type=='psw')inputType='password';var _self=this;var nullAble=true; 
     var textFrame=$L.DOM.create("DIV",{},dom);textFrame.setClass("LFORMField");textFrame.setWidth(width);
	 var labelEl=$L.DOM.create("DIV",{},textFrame);labelEl.setClass("LFormlabel");if(text)labelEl.setText(text+":");
	 
	 var inputDiv=$L.DOM.create("DIV",{},textFrame);inputDiv.setClass("LFormInput"); 
	 var inputEl=$L.DOM.create("INPUT",{'name':name,'type':inputType},inputDiv);inputEl.setClass("LFormInputText");
	 inputEl.setBackground(_ThemeFactory.form_textbg1," 0 0");inputEl.browserFont(12);
	
	 inputEl.onfocus=function(){_self.checkInput();if(_self.isError)this.setClass("LFormInputTextError");else this.setClass("LFormInputTextOn");};
	 inputEl.onblur=function(){_self.checkInput();if(_self.isError)this.setClass("LFormInputTextError");else this.setClass("LFormInputText");};
	 inputEl.onkeyup=function(){_self.checkInput();if(_self.keyDownHandle)_self.keyDownHandle(inputEl);}; 
	 var iconBtn=$L.DOM.create("DIV",{},textFrame);iconBtn.setClass("LFormInputIcon");iconBtn.hide();
	 var statuIcon=$L.DOM.create("DIV",{},textFrame);statuIcon.setClass("LFormInputStatuIcon");statuIcon.hide();
	 this.doLayout=function(){
		 var labelWidth=dom.labelWidth;if(lw)labelWidth=lw;if(!labelWidth)labelWidth=55;var iconWidth=0;
		 if(iconBtn.isDIsplay)iconWidth=17;labelEl.setWidth(labelWidth);
		 inputEl.setWidth(width-labelWidth-iconWidth-8-statuIcon.getWidth());
	 };
	 this.checkInput=function(){
	     if(nullAble)return;
		 if(inputEl.value=="")this.error("不能为空");
		 else this.ok();
	 };
	 this.notNull=function(){nullAble=false;};
	 this.setValue=function(value){if(!value)value="";inputEl.value=value;};
	 this.setMaxLen=function(size){inputEl.maxLength=size;};
	 this.setReadOnly=function(){inputEl.readOnly=true;};
	 this.addKeyUp=function(handle){this.keyDownHandle=handle;};
	 this.getValue=function(){return inputEl.value;};
	 this.getName=function(){return name;};
	 this.setIconBtn=function(c,handle,beforeHandle){
	      iconBtn.display();iconBtn.setBackground(c.bg,c.c1);iconBtn.isDIsplay=true;iconBtn.unselectable="on";
		  iconBtn.onmouseover=function(){this.setBackground(c.bg,c.c2);};
		  iconBtn.onmousedown=function(){this.setBackground(c.bg,c.c3);if(beforeHandle)beforeHandle();};
		  iconBtn.onmouseup=function(){this.setBackground(c.bg,c.c2);if(handle)handle(inputEl,iconBtn);};
		  iconBtn.onmouseout=function(){this.setBackground(c.bg,c.c1);};
		  this.doLayout(); 
	 };
	 this.getEl=function(){return inputEl};
	 this.error=function(msg,w,h){
	     statuIcon.display();statuIcon.setBackground($L.UI.Theme.iconUrl,$L.UI.Theme.Icons["l.error"]);this.doLayout();
		 this.isError=true;inputEl.setClass("LFormInputTextError");
		 inputEl.setBackground(_ThemeFactory.form_textError," 0 17");
		 inputEl.ondblclick=function(){_self.ok();};
		 statuIcon.onmouseover=function(){
			 statuIcon.px=0;statuIcon.py=0;
			 if(window.$TopWin){
			     statuIcon.px=$TopWin.getWindowX();
				 statuIcon.py=$TopWin.getWindowY();
			 } 
			 $Top.UI.ShowErrorMsg(msg,statuIcon,w,h,($Top==$L));
	     };
		 statuIcon.onmouseout=function(){$Top.UI.HiddenErrorMsg();};
	 };
	 this.ok=function(msg){
	     statuIcon.display();statuIcon.setBackground($L.UI.Theme.iconUrl,$L.UI.Theme.Icons["l.yes"]);this.doLayout();
		 this.isError=false;inputEl.setClass("LFormInputText");inputEl.setBackground(_ThemeFactory.form_textbg1," 0 0");
		 statuIcon.onmouseover=function(){};
	 };
	 this.doLayout(); 
};
//日期控件
$L.UI.Form.DateText=function(label,name,width,dom,lw){
	      name=name.toLowerCase();
         var input=new $L.UI.Form.Text(label,name,width,dom,null,lw);
		 input.setIconBtn({'bg':_ThemeFactory.form_dateBtn,'c1':' 0 0 ','c2':' -17 0','c3':' -34 0'},
		 function(text){
		      $L.UI.Form.showDateBox(text,function(y,m,d){input.setValue(y+'-'+m+'-'+d);});
		 },function(text){
		      $L.UI.Form.hideDateBox(text);
		 });
	     this.getInput=function(){return input;};
};
//下拉菜单框
$L.UI.Form.ComboBox=function(label,name,width,dom,store,lw){
	     name=name.toLowerCase();
         var input=new $L.UI.Form.Text(label,name,width,dom,null,lw);var _self=this;
		 input.setIconBtn({'bg':_ThemeFactory.form_combox,'c1':' 0 0 ','c2':' -17 0','c3':' -34 0'},
		 function(text,btn){ 
		      $L.UI.Form.showComboBox(text,text.getWidth()+20,store,function(record){
			       input.setValue(record.getLabel());
				   if(_self.afterChange)_self.afterChange(record.getValue(),record.getLabel());
			  }); 
		 });
	     this.getInput=function(){return input;};
		 this.setReadOnly=function(){input.setReadOnly();};
};
//搜索框
$L.UI.Form.SearchBox=function(label,name,width,dom,href,lw){
	     name=name.toLowerCase();
         var labelInput=new $L.UI.Form.Text(label,name+".label",width,dom,null,lw);
		 labelInput.setIconBtn({'bg':_ThemeFactory.form_search,'c1':' 0 0 ','c2':' -17 0','c3':' -34 0'},
		 function(text,btn){ 
		     if(!href){return;} 
			 var win=$L.UI.getWindow(700,300,$L.checkHref(href));
			 win.setValue=function(label,value){
			    labelInput.setValue(label);
				input.setValue(value);
			 }; 
			 win.setModle(true);
		 });
		 var input=$L.DOM.create("INPUT",{type:'hidden','name':name}); 
	     this.getInput=function(){return input;};
		 labelInput.setReadOnly();
};



 

//资源管理器
$L.UI.FilePanel=function(root,w,h){
    var panel=new $L.UI.Panel(root,w,h);var _self=this;var files=new Array();
	for(var n in panel){
	     _self[n]=new function(){
			   var name=n;
			   return function(a1,a2,a3,a4,a5,a6,a7){
			      panel[name](a1,a2,a3,a4,a5,a6,a7);
			   };
		};
		_self[n].methodName=n;
	} 
	var frame=$L.DOM.create("DIV",{},panel.getView()); frame.setClass("FilePanel");
	frame.onclick=function(){if(this.locked)return;_self.unselect();};
	var ctrlKey=false,shiftKey=false;var lastDom=null;var selArray=new Array();
	function showNote(title,content){
		if(!this.node)this.note=new $L.UI.NoteBook(1000,400);
		this.note.show();this.note.setModle(true);
		this.note.setTitle(title+"-记事本");
		this.note.setReadOnly();if(!content)content="";
		this.note.setValue(content);
	}
	
	function getDomIndex(dom){for(var i=0;i<files.length;i++)if(files[i]==dom)return i;};
	
	function File(thrumb,name,handle,record){
	   files.push(this);var fileSelf=this;
	   var fileDom=$L.DOM.create("DIV",{},frame);fileDom.setClass("FileDom");fileDom.fbSelect();
	   var thrumbDom=$L.DOM.create("DIV",{},fileDom);thrumbDom.setClass("ThrumbDom");
	   var textDom=$L.DOM.create("DIV",{},fileDom);textDom.setClass("TextDom");
	   textDom.setText(name); $L.unSelect();
	   this.moveTo=function(x,y){fileDom.moveTo(x,y);};
	   fileDom.onclick=function(e){if($L.isIE)e=window.event;ctrlKey=e.ctrlKey;shiftKey=e.shiftKey;frame.lock(200);_self.select(fileSelf);};
	   var img=new Image();var imgDom=$L.DOM.create("DIV",{},thrumbDom);imgDom.setClass("FileDomImg");
	   img.onload = function(){
		  var w=img.width;var h=img.height;var mw=thrumbDom.getWidth();var mh=thrumbDom.getHeight();
		  if(w>mw)w=mw;if(h>mh)h=mh;img.left=parseInt((mw-w)/2); 
		  img.top=parseInt((mh-h)/2);
		  img.xSel=img.left-2;img.ySel=img.top-2;
		  imgDom.setSize(w,h);imgDom.setBackground(img.src);imgDom.moveTo(img.left,img.top);
       }; 
	   
	   
	   this.select=function(){
		   fileDom.setClass("FileDomSel");if(!shiftKey)lastDom=this;selArray.push(record);
		   imgDom.moveTo(img.xSel,img.ySel);
	   };
	   this.unSelect=function(){
		   fileDom.setClass("FileDom");if(!shiftKey)lastDom=null;
		   imgDom.moveTo(img.left,img.top);
	   };
	   fileDom.ondblclick=function(){if(typeof handle=='string')showNote(name,handle);else if(handle) handle(fileSelf);}; 
	   img.src=thrumb;
	};
	this.select=function(dom){ 
		if(!ctrlKey&&!shiftKey)this.unselect(); 
		if(shiftKey){ 
		   if(!lastDom)return;
		   var start=getDomIndex(dom);var end=getDomIndex(lastDom);
		   var max=end;var min=start;if(start>end){max=start;min=end;}
		   this.unselect(); 
		   for(;min<=max;min++)files[min].select();	
		}
		dom.select(); 
	};
	this.unselect=function(){selArray=new Array();for(var i=0;i<files.length;i++)files[i].unSelect();};
	
	this.getSelectRecord=function(){return selArray;};
	this.doLayout=function(){
		var width=frame.getWidth();
	    for(var i=0,c=0,r=0;i<files.length;i++,c++){
		    var x=c*120+20;if(c>width-100){r++;c=0;x=20;}
			var y=r*120+10;files[i].moveTo(x,y);
		}
	}; 
	this.addFile=function(thrumb,name,handle,record){
	    new File(thrumb,name,handle,record);
		this.doLayout();
	};
};

//记事本
$L.UI.NoteBook=function(w,h){
    var ui=new $L.UI.Window(w,h);var _self=this;ui.showBorder();
	for(var n in ui){
		_self[n]=new function(){ var name=n; 
		   return function(a1,a2,a3,a4,a5,a6,a7){ui[name](a1,a2,a3,a4,a5,a6,a7);};
	};_self[n].methodName=n;}  
	var frame=$L.DOM.create("DIV",{},ui.getView());frame.setClass("NoteBook");
	var content=$L.DOM.create("TEXTAREA",{},frame);content.setClass("NBContent");
	_self.doLayout=function(){
        var w=frame.getWidth();
		content.setWidth(w-1);
	};
	this.setReadOnly=function(){content.readOnly=true;};
	this.setValue=function(value){content.value=value;};
	this.getValue=function(){return content.value;};
};
//双树形菜单
$L.UI.TreePanel=function(root,w,h){
    var ui=new $L.UI.Panel(root,w,h);var _self=this;var frame=ui.getView();
	for(var n in ui){
		_self[n]=new function(){ var name=n; 
		   return function(a1,a2,a3,a4,a5,a6,a7){ui[name](a1,a2,a3,a4,a5,a6,a7);};
	};_self[n].methodName=n;}
	var leftFrame=$L.DOM.create("DIV",{},frame);leftFrame.setClass("TreePanelLeft");
	var rightFrame=$L.DOM.create("DIV",{},frame);rightFrame.setClass("TreePanelRight");
	var leftTree=null;var rightTree=null;
	//左边的树形菜单
	this.setLeftTree=function(store){
		leftFrame.clear();
	    leftTree=new $L.UI.Tree(leftFrame,store);
	};
	this.setRightTree=function(store){
		rightFrame.clear();
	    rightTree=new $L.UI.Tree(rightFrame,store);
	};
	this.getLeftSelect=function(){
	    return leftTree.getSelect();
	};
	this.getRightSelect=function(){
	    return rightTree.getSelect();
	};
	this.refresh=function(record){
	   rightTree.refresh(record);
	};
};

/**QQ编辑器**/
$L.UI.QQEdit=function(name,root,w,h){
	 root=$L.UI.dom(root);
     var frame=$L.DOM.create("DIV",{},root);frame.setClass("QQEdit");var isSource=false;
	 if(w)frame.setWidth(w);if(h)frame.setHeight(h);
	 $L.DOM.create("INPUT",{type:'hidden','name':name},frame);	 
	 var toolBars=$L.DOM.create("DIV",{},frame);toolBars.setClass("ToolsBar");$L.DOM.MarginTop(toolBars,5);
	 var content=$L.DOM.create("DIV",{},frame);content.setClass("EContent"); 
	 var contentIframe=$L.DOM.create("IFRAME",{frameborder:0},content);contentIframe.setClass("contentFrame");
	 if(w)contentIframe.setWidth(w-10);
	 var e=contentIframe.contentWindow.document;e.open();e.designMode='on';var ew=contentIframe.contentWindow;
	 var m='<html><head><style>P,BODY{margin:0;padding:0;} BODY{font-size:13px;line-height:23px;}</style></head><body>'+$L.SPAN+'</body></html>';
	 e.write(m); e.close();
	 var source=$L.DOM.create("TEXTAREA",{},frame);source.setClass("EContent");source.hide();

	 this.doLayout=function(){ 
	     content.setHeight(root.getHeight()-40);content.setWidth(frame.getWidth()-8); 
		 source.setHeight(root.getHeight()-40);source.setWidth(frame.getWidth()-10);
	 };
     this.setAutoLayout=function(layout){
	   if(!layout)layout=root;
	   if(!layout.addLayout)new $L.SupposeLayout(layout);layout.addLayout(function(){_self.doLayout()}); 
     }; 
	 this.getName=function(){return name;};
	 this.getValue=function(){return e.body.innerHTML;};
	 this.setValue=function(value){source.value=value;e.body.innerHTML=value;};
	 
	 
	 
	 
	 var fm=new $L.UI.Form.ComboBox("","fontFamm",110,toolBars,$L.UI.FontFamily,10);
	 var fs=new $L.UI.Form.ComboBox("","fontSize",100,toolBars,$L.UI.FontSize,5);
	 fm.afterChange=function(v,l){e.execCommand("FontName",false,v); };
	 fs.afterChange=function(v,l){e.execCommand("FontSize",false,v); }; 
	 function Line(){
	    var line=$L.DOM.create("DIV",{},toolBars);line.setClass("QQBarLine");  
	 };
	  
	 function Icon(cls,title,handle,hasLine){
          var iconFrame=$L.DOM.create("DIV",{},toolBars);iconFrame.setClass("QQEIconFrame");iconFrame.unselectable="on";
		  iconFrame.setBackground(_ThemeFactory.qqEdit,cls);iconFrame.title=title;
		  iconFrame.onmouseover=function(){iconFrame.setClass("QQEIconFrameSel");};
		  iconFrame.onmouseout=function(){iconFrame.setClass("QQEIconFrame");};
		  iconFrame.onmousedown=function(){
			  if(!handle)return; 
			  handle();
		  };
	      if(hasLine)new Line(); 
		  this.getEl=function(){return iconFrame;};
	 };
	 
	 function setColor(icon,type){
	    $L.UI.showColorPanel(icon.getEl(),function(color){
		    e.execCommand(type,false,color);
		});
	 }
	 
	 new Icon(" 0 0","加粗",function(){e.execCommand("bold",0,false);});
	 new Icon(" -23 0","倾斜",function(){ e.execCommand("italic",0,false);});
	 new Icon(" -45 0","下划线",function(){ e.execCommand("underline",0,false); });
	 var fontColor= new Icon(" -67 0","字体颜色",function(){setColor(fontColor,"ForeColor");});
	 new Icon(" -179 0","插入超链接",function(){e.execCommand('CreateLink');});
	 new Icon(" -89 0","背景色",function(){setColor(fontColor,"BackColor");},true);
	 new Icon(" -111 0","剧左",function(){e.execCommand("justifyleft");});
	 new Icon(" -133 0","居中",function(){e.execCommand("justifycenter");});
	 new Icon(" -155 0","居右",function(){e.execCommand("justifyright");},true);
	 
	 new Icon(" 0 -23","插入图片",function(){    
			contentIframe.contentWindow.focus();
	 		var oRng =e.selection.createRange();
		        var upload=$Top.UI.showUpload(function(src){
		       	var CaretPos = 0;	// IE Support
				if (document.selection) {
					var Sel = document.selection.createRange ();
					Sel.moveStart ('character', -source.value.length);
					CaretPos = Sel.text.length;
				}
				// Firefox support
				else if (source.selectionStart || source.selectionStart == '0')
					CaretPos = source.selectionStart;
		        
				oRng.pasteHTML("<IMG src='"+src+"'>");
				oRng.collapse(false);
				oRng.select(); 
		   },true); 
		   upload.setAction(LAOPOCMS_UPLOAD_ACTION);
	 });
//	 new Icon(" -23 -23","上传音乐",function(){  });
	 new Icon(" -45 -23","上传视频",function(){ 
	 	
	 	var oRng =e.selection.createRange();
	 	var str=window.prompt("输入视频地址!","视频的代码.");
	 	if(str!=null)
	 	oRng.pasteHTML(str);
		oRng.collapse(false);
		oRng.select(); 
	 });
//	 new Icon(" -67 -23","添加视频",function(){ });
//	 new Icon(" -88 -23","表情图片",function(){  },true);
	 
	 new Icon(" -110 -23","显示源码",function(){  
	     if(isSource){
 
			 if(root.setStatu)root.setStatu("");
		     content.display();source.hide();isSource=!isSource;
			 e.body.innerHTML=source.value;
		 }else{
			 if(root.setStatu)root.setStatu("源代码");
		     source.display();content.hide();
			 source.value=e.body.innerHTML;isSource=!isSource;
		 }
	 });
};  
 
//编辑器的支持
$L.UI.FullEdit=function(){
     var ui=new $L.UI.Window(1000,500);var _self=this;ui.show();ui.setModle();ui.setTitle("文本编辑器");
     var root=ui.getView();new $L.UI.QQEdit(root);
	 root.setStatu=function(text){
		if(text)text="("+text+")";
	    ui.setTitle("文本编辑器"+text);
	 }; 
};
$L.refresh=function(){
	location.href=location.href;
};

$L.UI.showUpload=function(handle,isImage){
	if(this.uploadPanel){this.uploadPanel.show(handle,isImage);return this.uploadPanel;} 
	this.uploadPanel=new function(){
		 var msg="";var type="";var action="";var handle=null;
	     var win=new $L.UI.Window(600,400); 
		 win.setModle(true);
		 this.show=function(handleFun,isImage){
			 handle=handleFun;
			 win.show();
		     if(isImage){msg="图片";type=/.jpg$|.png$|.gif$/;}
			 else{msg="文件";type=/.txt$|.jpg$|.png$|.gif$|.doc$|.zip$|.ppt$|.xsl$,.wps$|.rar$/;}
		 };
		 this.hide=function(){win.hide();};
		 this.setAction=function(path){action=path;};
		 
		 var panel=new $L.UI.TabPanel(win.getView(),null,null,win);
		 var local=panel.add("本地上传");
		 //var source=panel.add("资源管理器");  
		 //var photoShop=panel.add("编辑图片");
		// var bs=new $L.UI.BorderView(source.getEl());
		// bs.openView("z");bs.moveAble("z"); 
		 var hiddenFrame="uploadFrame",uploadId="uploadInput",formId="uploadForm";
	     var content="<IFRAME name='"+hiddenFrame+"' style='display:none;'></IFRAME>";
	     content+="<FORM id='"+formId+"' method=post enctype=multipart/form-data  action='"+action+"' target='"+hiddenFrame+"'>";
	     content+='<div style="width:578px; height:250px; overflow:hidden; ">';
	     content+='<div style="width:470px; height:55px; overflow:hidden; float:left; padding-top:35px; padding-left:25px;">';
	     content+='<div style="font-size:12px; color:#666;">点击浏览从电脑选择一张图片或者文件</div>';
	     content+='<div style="padding-top:10px;">';
	     content+='<input id="'+uploadId+'" type="file" name="file1" style="width:450px; height:22px; border:1px solid #CCCCCC;" />';
	     content+='</div></div>';
	     content+='<div style="width:100%; height:20px; overflow:hidden; float:left;"></div>';
	     content+='<div style="width:360px; overflow:hidden; float:left; padding-left:25px;">';
	     content+='<h4 style="font-size:12px;color:#656563; float:left;">提示：</h4>  ';
	     content+='<ul style="width:355px; overflow:hidden; float:left; padding-left:5px; font-size:12px; color:#626260;">';
	     content+='<li style=" width:355px; line-height:20px;font-family:Verdana, Geneva, sans-serif;">●&nbsp;&nbsp;图片仅支持JPG、BMP、PNG、GIF 格式。</li>';
	     content+='<li style=" width:355px; line-height:20px;font-family:Verdana, Geneva, sans-serif;">●&nbsp;&nbsp;文件仅支持doc、rar、zip 格式。</li>';
	     content+=' <li style=" width:355px; line-height:20px;font-family:Verdana, Geneva, sans-serif;">●&nbsp;&nbsp;大小不能操过2MB。</li>';
	     content+=' </ul></div></div></FORM>';
	     local.getEl().innerHTML+=content;
	     var upload=$L.DOM.getDom(uploadId); var form=$L.DOM.getDom(formId);
	     var bar=$L.DOM.create("DIV",{},local.getEl());
	     bar.setStyles("margin-left:200px;");
	     var button=new $L.UI.Button(bar,"上  传",100,30,function(){
	         var path=upload.value; 
		     if(path==""){alert("请选择您要上传的"+msg+"!");;return;}
		     path=path.toLowerCase();
		    // if(!type.test(path)){alert("请上传合法的"+msg+"!");return;}
			 form.action=action;
			 form.submit();
			 window.uploadCallBack=function(src){
			     win.hide();
				 if(handle)handle(src);
			 }; 
	     }); 
		  
    }; 
    this.uploadPanel.show(handle,isImage);  
	return this.uploadPanel;
};
 
var $Top=$L; 
$Top=parent.$Top;
  
