﻿// JavaScript Document
String.prototype.Trim = function() 
{ 
   try{return this.replace(/(^\s*)|(\s*$)/g, ""); }catch(e){}
   return this;
}

String.prototype.LTrim = function() 
{ 
   try{return this.replace(/(^\s*)/g, ""); }catch(e){}
   return this;
   
}

String.prototype.RTrim = function() 
{ 
   try{return this.replace(/(\s*$)/g, "");  }catch(e){}
   return this;
   
}

var $config=new Object();
$config.context="";//程序的上下文
$config.adminContext="/admin";
var $Error={
   'u1003':'用户名不存在','p1002':'密码不正确','no-account':'缺少用户名','no-account':'缺少用户名','no-psw':'密码没有发现'
   ,'no-psw1':'密码确认没有发现','account-has':'用户名已经被注册','c1001':'验证码不正确','c1002':'验证码不正确'
}
$Error.get=function(name){
  if(!name)return false;
  var codeName=$Error[name];
  if(!codeName)return false;
  return codeName;
}
var $L=new Object();//对象集合
 
//=====统计代码------点击次数-------例如{pojo:'',id:''}======
$L.Click=function(ps){
   if(!ps)ps={};
   JAVA.清空监听();
   JAVA.调用成功=function(message){
	   
   }
   JAVA.调用("com.jcms.company.ajax.Click",ps);//用户登录
}




//=======================================================================================================================

//---浏览器事件模型
$L.Event=new function(){
	var events={};
//-------添加事件-------------------------------------------
	this.addEvent=function(type,name,fun){//添加事件类型和函数
        events[type+"-"+name]=fun;
    }
	this.removeEvent=function(type,name){events[type+"-"+name]=null;}
	document.onmouseup=function(){doEvent("onmouseup");}
	document.onmousedown=function(){doEvent("onmousedown");}
	document.onmousemove=function(){doEvent("onmousemove");}
	function doEvent(type){
	   for(var n in events){
		  if(n.indexOf(type)==0)try{if(events[n])events[n]();}catch(e){}
	   }	
	}
}
//逻辑对象
$L.logic=new Object();//逻辑对象
$L.logic.isLineX=function(left,right,y,top,bottom,x){
　return (top < y) && (bottom > y)&& (left < x) && (right > x);
}
 
$L.getDate=function(str){
   var date=new Date();
   try{
	   var d=/(\d+)-(\d+)-(\d+)/.exec(str);
	   date.setYear(parseInt(d[1]));date.setMonth(parseInt(d[2])-1);date.setDate(parseInt(d[3]));
	   d=/(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/.exec(str);
	   if(d){date.setHours(parseInt(d[4]));date.setMinutes(parseInt(d[5]));date.setSeconds(parseInt(d[6]));}
   }catch(e){}
   return date;
}
$L.trim=function(str){ try{ str=str.trim(); }catch(e){} return str;}
$L.hide=function(el){el=$L.el(el);el.style.display='none';}
$L.show=function(el,isNear){
	el=$L.el(el);el.style.display='';
    if(isNear){
		var t=event.y-$L.getBoxHeight(el)-100;
		if(t<10)t=10;
		el.style.top=t+'px';
    }
}
$L.sAc=function(s,h){$L.hide(h);$L.show(s);}
$L.setText=function(el,text){el=$L.el(el);el.innerHTML=text;}
$L.tagName=function(tag,source){if(!source)return document.getElementsByTagName(tag);return source.getElementsByTagName(tag);}
$L.addZero=function(n){if(n<10)return "0"+n;return n;}
$L.getContext=function(){return $config.context;}
$L.check=function(r){var ua = navigator.userAgent.toLowerCase();return r.test(ua);}
$L.isChrome=$L.check(/chrome/);
$L.isOpera =$L.check(/opera/);
$L.isIE=!$L.isOpera&&$L.check(/msie/);
$L.isIE7 =$L.isIE &&$L.check(/msie 7/);
$L.openQQ=function(qq){ window.open("tencent://message/?uin="+qq);}
$L.isIE8 =$L.isIE &&$L.check(/msie 8/);
$L.isWindows=$L.check(/windows|win32/);
$L.isLinux =$L.check(/linux/);
$L.replaceAll=function(str,newStr,oldStr){while(str.indexOf(oldStr)!=-1)str=str.replace(oldStr,newStr);return str;}
$L.getLeft=function(el){var left=0; while(el.offsetParent){left+=el.offsetLeft;el=el.offsetParent;}return left;}
$L.getTop=function(el){var top=0;while(el.offsetParent){top+=el.offsetTop;el=el.offsetParent;}return top;}
$L.getBoxWidth=function(el){return el.offsetWidth;}
$L.getBoxHeight=function(el){return el.offsetHeight;}
$L.getBrother=function(obj,index){return obj.parentNode.childNodes[index];}
$L.endChCss=function(el,css){if(typeof el=='string')el=$L.ID(el);el=el.childNodes;el[el.length-1].className=css;}
$L.changeCss=function(el,len,css){el=$L.ID(el);text=el.innerHTML;var n1=text.substring(0,len);n2=text.substring(len);
                      el.innerHTML="<span class='"+css+"'>"+n1+"</span>"+n2;}
$L.getNodes=function(el){
	   var ns=el.childNodes;var n=new Array();
       for(var i=0;i<ns.length;i++){
		   if(!ns[i].style)continue;n.push(ns[i]);
	   }
	   return n;
}

$L.closeAll=function(ns){for(var i=0;i<ns.length;i++)ns[i].style.display='none';}

$L.doWhile=function(ns,call){
	for(var i=0;i<ns.length;i++){if(call(ns[i],i))return;}
}
$L.el=function(el){if(typeof el=='string')el=$L.ID(el);return el;}
$L.joinArray=function(c1,c2){for(var n in c2){if(!c2[n])continue;c1[n]=c2[n];}}
$L.clearSelect=function(sel){while(sel.options.length>0)sel.remove(0);}
$L.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.removeData=function(array,o){for(var i=0;i<array.length;i++){if(array[i]==o){if(i==0)array.splice(i,i+1);else array.splice(i,i);return true;}}return false;}
$L.callPage=function(url,isPost){/*偷偷访问指定页面*/
    var name="privateCallFormDiv";
    var el=$L.ID(name);
	
	if(!el){
	    var root=$L.create("DIV",{'id':name},document.body);
		//root.style.display='none';
		var form=$L.create("FORM",{'id':name+"-form"},root);
		var frame=$L.create("IFRAME",{'name':name+"-frame"},root);
		form.target=name+"-frame";
	}
	var form=$L.ID(name+"-form");
	 
	form.action=url;
	form.method="get";if(isPost)form.method="post";
	form.submit();
}
$L.getHeight=function(){var h=document.documentElement.clientHeight;if(h)return h;return document.body.clientHeight;}
$L.setCenter=function(el){
     if(typeof el=='string')el=$L.ID(el);
	 var pel=el.parentNode;
	 el.style.marginLeft=parseInt(($L.getBoxWidth(pel)-$L.getBoxWidth(el))/2)+"px";
	 if(pel!=document.body)
	     el.style.marginTop=parseInt(($L.getBoxHeight(pel)-$L.getBoxHeight(el))/2)+"px";
	 else
		 el.style.marginTop=parseInt(($L.getHeight()-$L.getBoxHeight(el))/2)+"px";
}
//#==========================================
$L.createTable=function(rows,cols,obj,w,h){
   alert("对不起该方法已经被注销----lang.js  $L.createTable");
}

$L.CloseAndOpen=function(btn,target,isOpen,cssOpen,cssClose){
     btn=$L.el(btn);target=$L.el(target);
	 btn.onclick=function(){
	     if(isOpen){//如果是打开的
		     target.style.display="none";
			 if(cssClose)btn.className=cssClose;
		 }else{
		     target.style.display="";
			 if(cssClose)btn.className=cssOpen;
		 }
		 isOpen=!isOpen;
	 }
}
//
$L.createTable=function(rows,cols,obj,w,h){
    var ds=new Array();
    var tab=document.createElement('table');
	if(!w){
       w=$L.getBoxWidth(obj);
	   if(w==0)w=$L.getBoxHeight(obj.parentNode);
	}
	if(!h){
	   h=$L.getBoxHeight(obj);
	   if(h==0)h=$L.getBoxHeight(obj.parentNode);
	}
	tab.width=w; tab.height=h;
	tab.vAlign="middle";tab.style.textAlign="center";
	tab.background="#CCC";
	for(var i=0;i<rows;i++){
	    var tr=tab.insertRow();
		ds[i]=new Array();
	    for(var j=0;j<cols;j++){var td=tr.insertCell();ds[i][j]=td;}
	}
    obj.appendChild(tab);
	ds.get=function(){return tab};
	ds.width=w; ds.height=h;
	
    return ds;
}

/*表对象*/
$L.Table=function(el){
    el=$L.el(el);
    this.addRow=function(attr){
	   if(!attr)attr={};
	   var tr=el.insertRow();
	   for(var n in attr)tr[n]=attr[n];
	   return new $L.TRow(tr);
	}   
}
//行对象
$L.TRow=function(el){
   el=$L.el(el);
   this.addCell=function(attr,text){
      if(!attr)attr={};
	  var td=el.insertCell();
	  for(var n in attr)td[n]=attr[n];
	  if(text)td.innerHTML=text;
	  return new $L.TD(td);
   }
}
//列对象
$L.TD=function(el){
	el=$L.el(el);
	var code='';
	this.setText=function(text){
	    el.innerHTML=text;
	}
	this.put=function(text,isFlush){code+=text;if(isFlush){el.innerHTML+=code;code='';}}
}


$L.transData=function(names,ids){
   var d0=ids.split(",");var d1=names.split(",");
   if(d0.length!=d1.length){return null;}
   var d=new Array();
   for(var i=0;i<d0.length;i++){
      var temp=new Array();temp[1]=d0[i];temp[0]=d1[i];
	  d.push(temp);
   }
   return d;
}


$L.getRequest=function(name){
   name=name.toLowerCase()
   var href=location.href;
   href=href.toLowerCase()
   var start=href.indexOf(name+'=');
   if(start==-1)return '';
   href=href=href.substring(start+(name+'=').length);
   var end=href.indexOf("&");
   if(end==-1)return href;
   return href.substring(0,end);
}
$L.closeOpenSlide=function(el,btn,max,min){
	var self=this;
	self.change=function(){
      var h=$L.getBoxHeight(el);
      if(h<max){if(self.openBefore)self.openBefore(btn,el);self.openTools();}
	  else{if(self.closeBefore)self.closeBefore(btn,el);self.closeTools();}
    }
	
	btn.onclick=function(){self.change();}
	this.openTools=function(obj){
	  btn.onclick=function(){}
	  var intervalId=setInterval(function(){
	     var h=$L.getBoxHeight(el);
	     if(h<max)h+=10;
		 else{
			clearInterval(intervalId);
			btn.onclick=function(){self.change();}
		 }
		 el.style.height=h+"px";
	  },10);
   }
   this.closeTools=function(){
	  btn.onclick=function(){}
	  var intervalId=setInterval(function(){
	     var h=$L.getBoxHeight(el);
	     if(h>min)h-=10;
		 else{
			clearInterval(intervalId);
			btn.onclick=function(){self.change();}
		 }
		 if(h<min)h=min;
		 el.style.height=h+"px";
	  },10);
   }
}
//页面可被选择
$L.bodySelect=function (con){
	   var el=null;
	   var self=this;
	   var name="bodySelect-"+parseInt(Math.random()*10000);
	   var cancleName="bodySelectcancle-"+parseInt(Math.random()*10000);
	   if(typeof con=='string')con=$L.ID(con);
	   var chs=con.childNodes;
	   this.unSelectAll=function(){
		   chs=con.childNodes;
		   for(var i=0;i<chs.length;i++){
			   if(!chs[i].isCH)continue;
			   if(self.unSelect)self.unSelect(chs[i]);
		   }    
	   }
	   
	   
       this.singSelect=function(){
		    for(var i=0;i<chs.length;i++){
				if(!chs[i].isCH)continue;
				chs[i].onmousedown=function(){
					if(event.button==2){if(self.onSelect)self.onSelect(this);return;} 
					if(!event.ctrlKey){self.unSelectAll();}
					if(self.onSelect)self.onSelect(this);
					var kg=true;
					$L.Event.addEvent('onmousedown',cancleName,function(){ 
					    if(kg||event.button==2||self.cancleCheck())return;self.unSelectAll();
				    });
					setTimeout(function(){kg=false;},100);
			 	} 
		    }
	   }
	   
       con.onmousedown=function(){
		  if(event.button==2){return;} 
	      if(el==null){
		     el=$L.create("DIV",{},con);
			 el.setStyles({'position':'absolute','border':'1px dotted #000','width':'1px','height':'1px'});
		     el.setStyles({'display':'none','backgroundColor':'#06F'});
		  }
		  el.style.backgroundColor='#06F'; 
	      var x=event.x;var y=event.y;
		  $L.css.setAlpha(el,50);
		  el.style.left=x+"px";el.style.top=y+"px";var w=1,h=1;
		  con.onmousemove=function(){ 
			 el.style.display="";w=event.x-x;h=event.y-y;
			 if(w>0)el.style.width=w+"px";
			 else{el.style.width=(0-w)+"px";el.style.left=(x+w)+"px";}
			 if(h>0)el.style.height=h+"px";
			 else{el.style.height=(0-h)+"px";el.style.top=(y+h)+"px";}
			 selectCheck();
		  }
		  $L.Event.addEvent('onmouseup',name,function(){
		      if(event.button==2){return;} 
			  el.style.display="none";con.onmousemove=null;selectCheck();
		  });
		  
		  function selectCheck(){
			  if(!w||Math.abs(w)<10)return;
			  var x3=x;var x4=x+w;var y3=y;var y4=y+h;
			  if(!con||!x3||!x4)return;
			  if(w<0){x3=x+w;x4=x;}if(h<0){y3=y+h;y4=y;}chs=con.childNodes;
			  function c(n,n1,n2){return n>n1&&n<n2;}
			  for(var i=0;i<chs.length;i++){
				  if(!chs[i].isCH)continue;
			      var x1=$L.getLeft(chs[i])-$L.getLeft(con);var y1=$L.getTop(chs[i])-$L.getTop(con);
				  var x2=x1+$L.getBoxWidth(chs[i]);var y2=y1+$L.getBoxHeight(chs[i]);
				  if((c(x1,x3,x4)&&(c(y1,y3,y4)||c(y2,y3,y4)))||(c(x2,x3,x4)&&(c(y1,y3,y4)||c(y2,y3,y4)))){
				     if(self.onSelect)self.onSelect(chs[i]);
				  }else{if(self.unSelect)self.unSelect(chs[i]);}
			  }
			  $L.Event.addEvent('onmousedown',cancleName,function(){
				   if(self.cancleCheck()||event.button==2){return}
				   for(var i=0;i<chs.length;i++){
					   if(!chs[i].isCH)continue;
					   if(self.unSelect)self.unSelect(chs[i]);
				   }
				  $L.Event.removeEvent('onmousedown',cancleName);
			  });
		  }
       }
}


$L.getSystemSeconds=function(){
   var myDate = new Date();
   var ys=myDate.getYear()-2010;
   //年份的处理
   var days=ys*365+parseInt(ys/4);
   //月份的处理
   var ms=myDate.getMonth();
   if(ms==1)days+=31;
   if(ms==2)days+=59;
   if(ms==3)days+=90;
   if(ms==4)days+=120;
   if(ms==5)days+=151;
   if(ms==6)days+=181;
   if(ms==7)days+=212;
   if(ms==8)days+=243;
   if(ms==9)days+=273;
   if(ms==10)days+=304;
   if(ms==11)days+=334;
   //润年的处理---以2010为参照那么4的0和1不需要考虑  4的2和3需要考虑
   if((ys%4)==3)days++;//去年是润年
   if(ys%4==2&&ms>1){days++;}//今年是润年 闰月已经过去
   days+=myDate.getDate()-1;
   var hs=days*24;//小时
   hs+=myDate.getHours();
   var ms=hs*60;//分钟
   ms+=myDate.getMinutes();
   var ss=ms*60;
   ss+=myDate.getSeconds();
   return ss;
}
 
$L.Date=function(myDate){
     if(!myDate)myDate = new Date();
	 if(typeof myDate=='string')myDate=$L.getDate(myDate);
     var yy=myDate.getYear();  
     var yyyy=myDate.getFullYear();   
     var mm=myDate.getMonth()+1;  
     var dd=myDate.getDate();   
     var day=myDate.getDay();     
     var HH=myDate.getHours();     
     var MM=myDate.getMinutes();     
     var SS=myDate.getSeconds();
	 switch(day){case 0:day="日";break;  case 1:day="一";break; case 2:day="二";break;
		 case 3:day="三";break; case 4:day="四";break; case 5:day="五";break; case 6:day="六";break;}
	 this.getString=function(str){
			str=str.replace("yyyy",yyyy); str=str.replace("yy",$L.addZero(yy));
			str=str.replace("mm",$L.addZero(mm)); str=str.replace("dd",$L.addZero(dd));
			str=str.replace("day",day); str=str.replace("HH",$L.addZero(HH));
			str=str.replace("MM",$L.addZero(MM)); str=str.replace("SS",$L.addZero(SS));
			return str;
	 }
	 
	 this.getHtmlCode=function(){
        var code="";
        var max=30;if(mm==2)max=28;
		if(mm==1||mm==3||mm==5||mm==7||mm==8||mm==10||mm==12)max=31;
		var start=myDate.getDay()-dd%7;
		if(start<0)start+=7;
		for(var i=0;i<=start;i++)code+="<LI></LI>\n";
		for(var i=1;i<=max;i++){
			if(dd!=i)code+="<LI>"+i+"</LI>\n"
			else code+="<LI class='on-day'>"+i+"</LI>\n"
		}
		return code; 
	 }
	 
}
$L.date=$L.Date;//向下兼容





$L.updateTime=function(el,str,isOn){
	var d=new $L.date();
   	el=$L.el(el);el.innerHTML=d.getString(str);
	if(isOn){setInterval(function(){d=new $L.date();el.innerHTML=d.getString(str);},1000)}
}

$L.localPath=function(path){var href=location.href;href=href.substring(0,href.lastIndexOf("/"))+"/"+path;return href;}
$L.parseInt=function(val,dVal){if(!dVal)dVal=0;try{val=parseInt(val);if(isNaN(val))return dVal;return val}catch(e){return dVal}}
$L.ID=function(id){return document.getElementById(id);}
$L.removeCh=function(el){el.parentNode.removeChild(el);}
$L.removeChs=function(hs){for(var i=0;i<hs.length;i++)$L.removeCh(hs[i]);}
$L.Map=function(config){
   if(!config)config={};
   var keys=new Array();//关键字集合
   var map={};//数据集合
//关键字的判断
   function _(key){if(!key)return key;return key.toLowerCase();}
//检查关键字是否唯一
   function isOney(key){key=_(key);for(var i=0;i<keys.length;i++){if(key==keys[i])return false;}return true;}
//------插入数据-------------------------   
   this.put=function (key,value){ key=_(key);if(isOney(key)){keys.push(key);}map[key]=value; }
   this.update=function(m){for(var n in m){this.put(n,m[n]);}}
//-----删除数据--------------------------
   this.remove=function (
		key){key=_(key);for(var i=0;i<keys.length;i++){if(keys[i]==key){keys.splice(i,i);map[key]=null;return true;}}return false;
   }
//获取数据   
   this.get=function(key){key=_(key);return map[key];}
   this.size=function(){return keys.length;}
   this.find=function(index){return map[keys[index]];}
}
//列表的支持
$L.List=function(config){
  if(!config)config={};
  var list=new Array();//数据集合

//插入数据  
  this.insert=function(data){
     var row=new $L.Map(config);//创建一行数据
	 for(var n in data){row.put(n,data[n]);}
	 list.push(row);
  }
  this.insertMap=function(map){list.push(map);}
  this.updateAt=function(index,map){list[index]=map;}
//删除num行数据从index开始默认删除1行
  this.remove=function(index,num){if(!num)num=1;num--;list.splice(index,index+num);}
//获取大小
  this.size=function(){return list.length;}
//获取集合
  this.getMap=function(index){return list[index];}
//获取集合数据  
  this.getMapValue=function(index,key){return list[index].get(key);}
//对集合进行排序--支持中文   
  this.orderChinese=function(key,isDesc){return this.order(key,isDesc,true)}
//对集合进行排序  
  this.order=function(key,isDesc,isCh){
      var orderKeys=new Array();//排序字段数组
	  var temp={};
	  for(var i=0;i<list.length;i++){
	     var ov=list[i].get(key)+"_"+i;
		 if(isCh)ov=$PinYin.search(ov);
		 orderKeys.push(ov);
		 temp[ov]=list[i];
	  }
	  orderKeys.sort();//排序
	  var newList=new $L.List();//创建新的对象
	  for(var i=0;i<orderKeys.length;i++){
		 var index=i;
		 if(isDesc)index=orderKeys.length-i-1;
	     newList.updateAt(index,temp[orderKeys[i]]);
	  }
	  return newList;
  }
}
//树根
$L.TreeRoot=function(dataSource,deep){
   	var treePool={};//树数据池
	var sons=new Array();//子节点
	for(var i=0;i<dataSource.length;i++){
	    var m=new $L.Map();
		m.update(dataSource[i]);
		treePool[m.get("id")]=new $L.Tree(m);
	}
	for(var n in treePool){
	    var tree=treePool[n];
	    var pid=tree.getPId();//获取父编号
	 
	    var pTree=treePool[pid];
	    if(pTree){//父节点存在
		   pTree.addSon(tree);
		   tree.setParentNode(pTree);
		}else{//父亲节点
		   sons.push(tree);
		}
	}
	this.getRoots=function(){return sons;}
	this.findNode=function(id){return treePool[id]}
}
//树形数据集合
$L.Tree=function(data){
   var parentNode=null;//父节点
   var sons=new Array();//子节点
   var id=data.get("id");
   this.setParentNode=function(pNode){parentNode=pNode;}
   this.addSon=function(son){sons.push(son);}
   this.getSons=function(){return sons;}
   this.hasSon=function(){return sons.length>0;}
   this.getSon=function(index){return sons[index];}
   this.getId=function(){return id;}
   this.get=function(key){return data.get(key);}
   this.getPId=function(){return data.get('pid');}
   this.getDeep=function(){if(!parentNode)return 1;return parentNode.getDeep()+1;}
   this.isGrandson=function(pid){if(!parentNode)return false;}
}
//鼠标右键
$L.contextmenu=function(eventObject,w,h){
	eventObject.oncontextmenu=function(){return false;}
	var sourcePools={};//事件源的池
	var itemPools=new Array();
	var self=this; var name="menu-"+parseInt(Math.random()*10000);
    var menuBox=$L.create("DIV",{},eventObject);
	menuBox.setStyles({'width':w+'px','height':h+'px','position':'absolute','border':'2px solid #CCC','display':'none'});
	menuBox.setStyles({'backgroundColor':'#FFF','overflow':'hidden'});
	this.show=function(x,y){
	   var ww=document.body.clientWidth;
	   var wh=document.body.clientHeight;
	   if(!wh)wh=document.documentElement.clientHeight;
	   if(!ww)ww=document.documentElement.clientWidth;
	   if(w+x>ww)x-=w; if(h+y>wh)y-=h;
	   menuBox.setStyle('left',x+"px");  menuBox.setStyle('top',y+"px"); menuBox.setStyle('display',"");
	}
	this.isShow=function(){return menuBox.style.display!="none";}
	this.setSize=function(w,h){ menuBox.style.width=w+"px"; menuBox.style.height=h+"px";}
	this.hide=function(){menuBox.style.display="none";}
	this.addItem=function(text,handle,hasLine){
	   var itemBox=$L.create("SPAN",{},menuBox);
	   itemBox.setStyles({'display':'block','width':'100%','lineHeight':'23px','height':'23px','overflow':'hidden'});
	   itemBox.setStyles({'paddingLeft':'15px','fontSize':'12px'});
	   itemBox.innerHTML=text;
	   if(hasLine){
		  var line=$L.create("SPAN",{},menuBox);itemBox.line=line;
		  line.setStyles({'display':'block','width':'100%','height':'5px','borderBottom':'2px solid #F0F0F0'});
	   }
	   itemPools.push(itemBox);
	   itemBox.checkFunction=function(){return true;}
	   itemBox.enable=function(){
	      itemBox.onmousedown=function(){self.itemForce=true;setTimeout(function(){self.itemForce=false;},100);}
		  itemBox.onmouseup=function(){self.hide();handle();}
		  itemBox.onmouseover=function(){this.style.backgroundColor="#009";this.style.color="#FFF";}
	      itemBox.onmouseout=function(){this.style.backgroundColor="";this.style.color="";}
		  itemBox.style.color="#000";
	   }
	   itemBox.disable=function(){
	      itemBox.onmouseup=function(){}
		  itemBox.style.color="#CCC";
		  itemBox.onmouseover=function(){this.style.backgroundColor="#009";this.style.color="#CCC";}
	      itemBox.onmouseout=function(){this.style.backgroundColor="";this.style.color="#CCC";}
		  itemBox.onmousedown=function(){self.itemForce=true;setTimeout(function(){self.itemForce=false;},100);}
	   }
	   return itemBox;
	}
	
    function getDisTag(el){
	   for(var i=0;el&&i<100;i++){
		  if(el.disTag)return el.disTag;
		  el=el.parentNode;
	   }
	   return "ogw";
	}
	
	$L.Event.addEvent('onmousedown',name,function(){if(!self.itemForce)self.hide();});
	eventObject.onmouseup=function(){
        if(event.button!=2){return}
		//var disLabel=getDisTag(event.srcElement);
		for(var i=0;i<itemPools.length;i++){
		   if(itemPools[i].checkFunction()){ itemPools[i].enable(); }
		   else{ itemPools[i].disable();}
		}
		self.show(event.x,event.y);
	};
}
//表单JS对象
$L.FormObject=function(){
     var el=$L.create("DIV",{},document.body);	
	 el.style.display="none";
	 var form=$L.create("FORM",{},el);	
	 this.add=function(name,value){
	     form.innerHTML+="<INPUT TYPE='hidden' name='"+name+"' value='"+value+"'>";
	 }
	 this.clear=function(){form.innerHTML="";}
	 this.submit=function(method,targt){if(method)form.method=method;if(targt)form.targt=targt;form.submit();}
}

/**设为首页**/
$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.setStyle=function(el,attr){
	if(typeof attr=='string'){
		var as=attr.split(";");
		attr={};
		for(var i=0;i<as.length;i++){
			as[i]=$L.trim(as[i]);
			var start=as[i].indexOf(":");
			var n=as[i].substring(0,start);
			var v=as[i].substring(start+1);
			n=$L.trim(n);v=$L.trim(v);n=$L.cssUpp(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){}}
}
//创建节点对象
$L.create=function(tag,attr,parent,attrCode){
	 tag=tag.toUpperCase();
     var tagObj=document.createElement(tag);
	 if(tag=="INPUT"){
		 if(!attrCode)attrCode="";
		 if(attr&&attr['name']){attrCode="name='"+attr['name']+"' "}
		 tagObj=document.createElement("<input "+attrCode+">");
	 }
	 for(n in attr){
		tagObj.setAttribute(n,attr[n]);
		tagObj[n]=attr[n];
     }
	 tagObj.setStyles=function(attr){
		 $L.setStyle(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);}
	 return tagObj;
}
$L.getLeft=function(el){var left=0; while(el.offsetParent){left+=el.offsetLeft;el=el.offsetParent;}return left;}
$L.getTop=function(el){var top=0;while(el.offsetParent){top+=el.offsetTop;el=el.offsetParent;}return top;}
$L.getBoxWidth=function(el){return el.offsetWidth;}
$L.getBoxHeight=function(el){return el.offsetHeight;}
$L.cssUpp=function(str){
  str=str.replace(/-\w+/g,function(word) {
	  return word.substring(1,2).toUpperCase( )+
	  word.substring(2);
  });
  return str;
}
$L.simpleOrder=function(array,name,orderby){
     var newArray=new Array();
	 var os=orderby.split(",");
	 for(var j=0;j<os.length;j++){
		 for(var i=0;i<array.length;i++){
			 if(array[i][name]!=os[j])continue;
			 newArray.push(array[i]);
		 }
	 }
     return newArray;
}


$L.eval=function(message){
  try{message=$L.replaceAll(message,'/','\\');}catch(e){}
  try{var data=eval(message);return data;}catch(e){
     message=$L.replaceAll(message,'','\'');
	 message=$L.replaceAll(message,'','{');
	 message=$L.replaceAll(message,'','}');
 
	 var ms=message.split(",");
	 var data={};
	 for(var i=0;i<ms.length;i++){
        var start=ms[i].indexOf(":");
		if(start==-1)continue;
		var key=ms[i].substring(0,start);
		var value=ms[i].substring(start+1);
		data[key]=value;
	 }
	  
	 return data;
  }
}

/**跳转***/
$L.sendRedirect=function(url){
   url=encodeURI(url);
   location.href=url;
} 
 
//----百分百刷新-------------------
$L.refresh=function(){
    var href=location.href;
	href=$L.refreshHref(href);
	$L.sendRedirect(href);
}
$L.refreshTo=function(config){
    var href=location.href;
	var start=href.indexOf("?");
	var url=href;
	if(start!=-1){
	   
	
	}
	
	 
}

$L.refreshHref=function(href){
	var d=parseInt(Math.random()*1000);
    if(href.indexOf("timeRandomJcms=")!=-1)href=href.replace("timeRandomJcms=","timeRandomJcms="+d);
	else if(href.indexOf("?")==-1)href+="?timeRandomJcms="+d;
	else href+="&timeRandomJcms="+d;
	return href;
}
//延时执行
$L.DelayExe=function(config,time){
	if(!time)time=100;
	var self=this;
	self.exe=function(){}
	self.clear=function(){clearInterval(intervalId);}
    var intervalId=null;
	setTimeout(function(){
		intervalId=setInterval(function(){
			self.exe(config,self);							
		},time);		
	},100);
}
/*****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.el=function(el){if( typeof el=='string')return $L.ID(el); return el;}
//
$L.SingleSelect=function(el,cssOn,cssOut,eType,targetFun){
	 if(typeof el=='string')el=$L.ID(el);
	 var self=this;
	 var cNodes=el.childNodes;
	 var tab=new $L.ComplexSingleSelect(cNodes,cssOn,cssOut,eType,targetFun);
	 this.goTo=function(index){
		 tab.goTo(index);
	 }
     this.getFocusObject=function(){return tab.getFocusObject();}
	 this.goTo(0);//默认相应第一个
	 this.setAutoChange=function(times,el){
		 var lock=false;
		 setInterval(function(){
			if(lock)return;
		    var index=tab.getIndex()+1;
			if(index>=cNodes.length)index=0;
			self.goTo(index);
		 },times);
		 if(el)el=$L.ID(el);
		 el.onmouseover=function(){lock=true;}
		 el.onmouseout=function(){lock=false;}
	 }
	 
}
/**复杂的单选***/
$L.ComplexSingleSelect=function(cNodes,cssOn,cssOut,eType,targetFun){
	 var focusObj=null;
	 for(var i=0;i<cNodes.length;i++){
		 cNodes[i]['on'+eType]=function(){changeFocus(this);}
		 cNodes[i].index=i;
	 }
//----------改变焦点----------------------------------
	 function changeFocus(obj){
		 if(!obj||obj.disable)return;
		 if(targetFun){targetFun(obj,focusObj);focusObj=obj;return;};
		 
		 for(var i=0;i<cNodes.length;i++){
	        cNodes[i].className=cssOut;
			try{$L.ID(cNodes[i].SID).style.display="none";}catch(e){}
		 }
		 focusObj=obj;
		 obj.className=cssOn;
		 try{$L.ID(obj.SID).style.display="block";}catch(e){}
		 
	 }
	 this.getIndex=function(){return focusObj.index;}
	 this.getFocusObject=function(){return focusObj;}
	 this.goTo=function(index){
		  changeFocus(cNodes[index]);
	 }
}

//========================移动的支持
$L.MoveWorker=function(config,scope){
	var target=config["target"];//响应对象
	if(target.parentNode==document.body){//
	   new $L.documentMove(config,this,scope);
	}else{
	  new $L.localMove(config,this,scope);
	}
}
//全局移动
$L.documentMove=function(config,work,scop){
    var name="move_work_"+parseInt(Math.random()*99999);
	var source=config["source"];//事件源 也就是触发对象
	var target=config["target"];//响应对象
	target.style.position="absolute";
	source.onmousedown=function(){
		$L.Mask.show();
		var x=event.clientX-$L.getLeft(target);
		var y=event.y;
		$L.Event.addEvent('onmousemove',name,function(){
	        target.style.left=event.x-x+"px";
			target.style.top=event.y-y+"px";
		})
		$L.Event.addEvent('onmouseup',name,function(){
	        $L.Event.removeEvent('onmousemove',name);
			if(!config['masklock'])$L.Mask.hide();
		}); 	
	}
}
//局部移动
$L.localMove=function(config,work,scop){
    var name="move_work_"+parseInt(Math.random()*99999);
	var source=config["source"];//事件源 也就是触发对象
	var target=config["target"];//响应对象
	target.style.position="absolute";
	scop.style.position="relative";
	source.onmousedown=function(){
		$L.Mask.show();
		var x=event.x-$L.getLeft(target)+$L.getLeft(scop);
		var y=event.y-$L.getTop(target)+$L.getTop(scop);
		$L.Event.addEvent('onmousemove',name,function(){
	        target.style.left=event.x-x+"px";
			target.style.top=event.y-y+"px";
		})
		$L.Event.addEvent('onmouseup',name,function(){
	        $L.Event.removeEvent('onmousemove',name);
			if(!config['masklock'])$L.Mask.hide();
		}); 	
	}
}


//遮罩层的支持
$L.Mask=new Object();
$L.Mask.show=function(deep){
  if(!deep)deep=40;
  if(!$L.Mask.el){
	  var el=$L.create("DIV",{},document.body);
	  el.setStyles({'position':'absolute','zIndex':9999,'left':'0px','top':'0px',backgroundColor:'#CCC'});
	  el.setStyles({width:'100%',height:'100%'});
	  el.style.cursor='move';
	  $L.Mask.el=el;
  }
  $L.css.setAlpha($L.Mask.el,deep);
  $L.Mask.el.style.height=document.body.offsetHeight+"px";
  $L.Mask.el.style.display="";
  
}	 
$L.Mask.hide=function(){
	try{$L.Mask.el.style.display="none";}catch(e){}
}	 
//CSS的基本操作
$L.css=new Object();
$L.css.Select=function(objs,onCss,outCss,isMore){
	var self=this;
    for(var i=0;i<objs.length;i++){
		 objs[i].index=i;
	     objs[i].onclick=function(){
			  var o=self.getSelect();
			  on(this);
			  if(isMore&&event.ctrlKey)return;
			  
	          for(var j=0;j<objs.length;j++){
				  if(objs[j]==this)continue;
				  out(objs[j]);
			  }
			  if(isMore&&event.shiftKey&&!event.ctrlKey){
			      var s2=this.index;
				  var s1=0;if(o)s1=o.index;
				  var start=s1;var end=s2;
				  if(s1>s2){start=s2;end=s1;}
				  for(var j=start;j<=end;j++){on(objs[j]);}
			  }
		 }
	}
	function on(o){o.className=onCss;o.isSelect=true;}
	function out(o){o.className=outCss;o.isSelect=false;}
	this.getSelect=function(){//获取被选中的对象
	   for(var i=0;i<objs.length;i++){
	      if(objs[i].isSelect)return objs[i];
	   }
	   return null;
	}
}
$L.css.setAlpha=function(el,max){
	el=$L.el(el);
	if($L.isIE){
		if(!el.style.filters){el.style.filter="alpha(opacity:"+max+")";return;}
		el.style.filters["alpha"].opacity=max;
	}
}
/**循环延时**/
$L.delayShow=function(max,time,handle){
   	var intervalId=setInterval(function(){
		max--;
		if(max<0){clearInterval(intervalId);return;}
		handle(max);					
	},time);
}
/****/
$L.imgScan=function(img,w,h){
	if(img.width<=w&&img.height<=h)return [img.width,img.height];
	var pw=img.width/w;
    var ph=img.height/h;
	 
	if(pw>ph){
	   return [parseInt(img.width/ph),parseInt(img.height/ph)];
	}else{
 
	   return [parseInt(img.width/pw),parseInt(img.height/pw)];
	}
}
/*********************************************************************/
$L.ui=new Object();
//左右滑动的移动效果
$L.ui.MoveSlide=function(config){
	var self=this;
	var leftBtn=$L.ID(config['L_BTN']);//左边按钮
	var rightBtn=$L.ID(config['R_BTN']);//右边按钮
	var content=$L.ID(config['content']);//中间的内容
	var chs=content.childNodes;
    content.style.position="absolute";
    content.parentNode.style.position="relative";
	var maxL=config['maxL'];var startX=0;
	var maxR=0;var pl=0-config['pl']; var lock=false;
	this.move=function(){
		 var i=0;
		 var max=config['times'];
		 var intervalId=setInterval(function(){
				 i++;
				 startX+=pl;
				 if(startX>0){startX=0-config['pl'];}
				 if(startX<maxL){startX=maxL+config['pl'];}
				 if(i>max){clearInterval(intervalId);}
				 content.style.left=startX+"px";
	     },50);
	}  
	leftBtn[config['etype']]=function(){
		 if(startX==maxL){return;}
		 pl=0-config['pl'];
		 self.move();
	}
    rightBtn[config['etype']]=function(){
		 if(startX==0){return;}
		 pl=config['pl'];
		 self.move();
    }
 
}
//窗口对象
$L.ui.Window=function(w,h,config){
   var win=$L.create("DIV",{},document.body);//创建窗口对象
   win.setStyles({display:'none',backgroundColor:'#FFF',width:w+'PX', height:h+'PX', border:'3PX solid #999', position:'absolute'});
   var ul=$L.create("UL",{},win);//创建标题
   ul.setStyles({width:'100%', height:'30px',lineHeight:'30px',fontSize:'13px',textIndent:'10px',margin:0,padding:0,
				borderBottom:'3PX solid #999',backgroundColor:'#CCC'});
   var title=$L.create("LI",{},ul);//
   title.setStyles({listStyle:'none'});
   this.setXY=function(x,y){win.style.left=x+"px";win.style.top=y+"px";}
   this.setTitle=function(msg){title.innerHTML=msg;}
   this.getPanel=function(){return win;}
   new $L.MoveWorker({'source':title,'target':win,'masklock':true});
   this.show=function(){$L.Mask.show();win.style.display="block";win.style.zIndex=10000;}
   this.hide=function(){win.style.display="none";$L.Mask.hide();}
}
 
/***常用方法***/
$L.doUpdate=function(path,ids,ps,callBack){
	 if(!ps)ps={};
	 ps.mapping=path;
	 ps.key=ids;
	 JAVA.清空监听();
	 JAVA.调用成功=function(message){
		if(message=='404'){alert("路径没有被发现!");return;}
		if(message=='500'){alert("参数缺省或者配置错误!");return;}
		if(message=='error'){alert("修改失败!");return;}
		callBack(message);
	 }
	 JAVA.调用("com.jcms.plugins.tools.Update",ps); 

}
/**获取内容***/
$L.doGet=function(path,key,ps,callBack){
	 if(!ps)ps={};
	 ps.mapping=path;
	 ps.key=key;
	 
	 JAVA.清空监听();
	 JAVA.调用成功=function(message){
		 if(message=='404'){alert("路径没有被发现!");return;}
		 if(message=='500'){alert("参数缺省或者配置错误!");return;}
		 if(message=='error'){alert("获取失败!");return;}
		 callBack(message);
	 }
	 JAVA.调用("com.jcms.plugins.tools.Get",ps); 
}
/**获取视图**/
$L.getTableView=function(path,ps,callBack){
	 if(!ps)ps={};
	 ps.mapping=path;
	 JAVA.清空监听();
	 JAVA.调用成功=function(message){
		if(message=='404'){alert("路径没有被发现!");return;}
		if(message=='500'){alert("参数缺省或者配置错误!");return;}
		if(message=='error'){alert("修改失败!");return;}
		callBack(message);
	 }
	 JAVA.调用("com.jcms.plugins.tools.TableView",ps); 
}

/****多线程AJAX**********/
$L.threadAjax=function(className,ps,callBack){
	var config={'className':className,'ps':ps,'callBack':callBack}
    var delay=new $L.DelayExe(config,3000);
	delay.exe=function(config,obj){
	    JAVA.清空监听();
	    JAVA.调用成功=function(message){
			var c=$L.eval(message);
			if(c.over)obj.clear();
		    config.callBack(c);
		}
		JAVA.调用(config.className,config.ps); 
	}
}


/****延时程序***/
$L.Timeout=function(times){
    var self=this;
	var funs=new Array();
	this.exe=function(config,fun){
	   funs.push(fun);
	   fun.config=config;
	}
	this.start=function(){
	    var delay=new $L.DelayExe({},times);
		delay.exe=function(config,obj){
		    if(funs.length==0){obj.clear();self.callBack();}
			var fun=funs[0];
			funs.splice(0,1);
			if(fun){fun(fun.config);}
		}
	}
	
	this.end=function(callBack){
	   self.callBack=callBack;
	}
	
}
 
function checkObject(code){
      var obj=null;
	  try{eval("obj="+code);}catch(e){}
	  if(obj)return obj;
	  return null;
 }

function createNewAjax(){
         var AjaxJcms=new Object();//AjaxJcms对象
		 //AjaxJcms数据源
		 AjaxJcms.initialize=function(){this.dataSource=new Array();}//初始化数据源
		 AjaxJcms.initialize();
		 AjaxJcms.alert=function(message){
			 var MessageObj=checkObject("Msg");
			 if(MessageObj)MessageObj.remind("友情提示",message);
			 else alert(message);
		 }
/***************************************************************/		 
		 AjaxJcms.getRequest=function(){
		     if(this.xmlHttp)return this.xmlHttp;
			 try{ this.xmlHttp=new XMLHttpRequest();}catch(e){//火狐
			   try{ this.xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){//IE浏览器
			     try{ this.xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}//其他浏览器
			   }
			 }finally{AjaxJcms.configOnreadystatechange();return this.xmlHttp;}
		 }
//-------配置AJAX响应支持
		 AjaxJcms.configOnreadystatechange=function(){
		    var request=this.getRequest();
		    request.onreadystatechange=function(){
				try{
				   if(request.readyState==4){//交易完成
					   if(request.status==200){//交易成功
						   var result=request.responseText;
						   AjaxJcms.handle.success(result);
					   }
				   }
				}catch(e){if(AjaxJcms.handle.catchError)AjaxJcms.handle.catchError(e);}
             }
		 }
		 
/********common公共方法调用*******************************************************/
//设置参数
         AjaxJcms.setRequest=function(name,value){
		     //if(value)this.dataSource.push(escape(escape(name))+"="+escape(escape(value)));
			 if(value)this.dataSource.push(name+"="+value);
			 //url=encodeURI(url);
	     }
//解析参数
		 AjaxJcms.parseRequest=function(index){
		    var data=this.dataSource[index];
		    if(!data)return null;
			if(data.indexOf("=")==-1)return null;
			while(data.indexOf("&")!=-1)data=data.replace("&","-*-");
			return data;
		 }
//设置路径		 
		 AjaxJcms.setAction=function(url){
		     this.action=url;
		 }
//设置响应监听
		 AjaxJcms.setHandle=function(handle){
		    this.handle=handle;
		 }
//----------GET提交响应		 
		 AjaxJcms.sendByGet=function(){
		     var request=this.getRequest();
			 if(!request){this.alert("XML请求不存在--操作意外终止关闭!");return;}
			 if(!this.action){this.alert("请求路径不存在!");return;}
			 if(!this.handle){this.alert("监听不存在!");return;}
			 request.open("GET",this.action,true);//
			 request.send(); 
		 }
//----------POST提交响应-------------------------------------------------------------------------------------------------------------------	
		 AjaxJcms.sendByPost=function(){
		     var request=this.getRequest();
			 if(!request){this.alert("XML请求不存在--操作意外终止关闭!");return;}
			 if(!this.action){this.alert("请求路径不存在!");return;}
			 if(!this.handle){this.alert("监听不存在!");return;}
 
			 request.open("POST",this.action,false);//
			 var ps="";
			 for(var i=0;i<this.dataSource.length;i++){
			     var value=this.parseRequest(i);
				 if(!value)continue;
				 if(ps.length>0)ps+="&";
				 ps+=value;
			 }
			 request.setRequestHeader('Content-type','application/x-www-form-urlencoded;'); 
			 ps=encodeURI(ps);
			 request.send(ps); 
			 
		 }	
	     return AjaxJcms;
}
 
		 
		 
		 
/**********************************************************************************************/
          
		  var JAVA=new Object();
		  
		  JAVA.清空监听=function(){
		     this.调用成功=null;
			 this.调用失败=null;
		  }
//-----------------------------------------------------------------------------------
          JAVA.调用=function(className,parammers){
			  var AjaxJcms=createNewAjax();
		      AjaxJcms.setRequest("className",className);
			  AjaxJcms.setRequest("encoding2","UTF-8");
			  for(var n in parammers){
				// alert(n+"=="+parammers[n]);
			    AjaxJcms.setRequest(n,parammers[n]);
			  }
			 // AjaxJcms.setRequest("type","1");//执行方法
			  var handle=new Object();
			  handle.success=function(message){
				  try{while(/^\s/.test(message))message=message.substring(1);while(/\s$/.test(message))message=message.substring(0,message.length-1);}catch(e){}
			      if(JAVA.调用成功)JAVA.调用成功(message);
			  }
			  handle.catchError=function(result){
			      if(JAVA.调用失败)JAVA.调用失败();
			  }
			  AjaxJcms.setHandle(handle);
		      AjaxJcms.setAction("jcms-ajax.jcms");
		      AjaxJcms.sendByPost();
		  }
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
 /*******老版本的支持----请不要使用************************/
//简单的UI对象
var SimpleUI=new Object();
SimpleUI.Form=new Object();
/**简单的单选***/
SimpleUI.SingleSelect=function(el,cssOn,cssOut,eType){
	 $L.SingleSelect(el,cssOn,cssOut,eType);
}
/**复杂的单选***/
SimpleUI.ComplexSingleSelect=function(cNodes,cssOn,cssOut,eType){
	$L.ComplexSingleSelect(cNodes,cssOn,cssOut,eType);
}

