﻿// JavaScript Document
String.prototype.trim = function() 
{ 
   try{return this.replace(/(^\s*)|(\s*$)/g, ""); }catch(e){}
   return this;
};
String.prototype.endWith=function(str){
   var r=new RegExp(str+"$","gi");
   return r.test(this);
};
String.prototype.startWith=function(str){
   var r=new RegExp("^"+str,'gi');
   return r.test(this);
};
String.prototype.replaceAll=function(o,n,noSkip){
   try{
	   var r=new RegExp(o,"gi");
	   if(noSkip)r=new RegExp(o,"g");
	   return this.replace(r, n); 
   }catch(e){}
   return this;
};
String.prototype.isEmail=function(){//邮箱的认证
    return /^[\w\d_]+@[\w\d_]+\.[\w]+$/.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,12}$/.test(this);};
String.prototype.parseInt=function(){return parseInt(this);};
//Object.prototype._=function(n){n=n.toLowerCase();if(this[n])return this[n];return "";};

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;
   }
};

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];};


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="";//程序的上下文
var $L=new Object();//对象集合
$L.Index=new Object();
$L.Index.getWidth=function(){return $L.getWidth();};
$L.Index.getHeight=function(){return $L.getHeight();};
//正则的支持
$L.Regx=new Object();
$L.Regx.Integer=function(msg){msg=msg.replace(/\D+/,"");return msg;};
$L.tabPanel=function(tabs,on,out,times,type){return new $L.TabPanel(tabs,on,out,times,type);};
$L.TabPanel=function(tabs,on,out,times,type){
	if(!type)type='onclick';
	var ts=tabs.split(",");var autoIndex=0;var isLock=false;
	function _(i,el){if(!el)el='';return $L.ID(ts[i]+el)}
	function show(i){
	    init();
		_(i).className=on;
		_(i,"_el").style.display="";
	}
	function init(){
	    for(var i=0;i<ts.length;i++){
		    _(i).className=out;
			_(i,"_el").style.display="none";
		}
	}
	for(var i=0;i<ts.length;i++){
		if(i==0)_(i).className=on;
		else{
		   _(i).className=out;
		   _(i,"_el").style.display='none';
		} 
		if(_(i,"_el").tabTitle)_(i).innerHTML=_(i,"_el").tabTitle;
	    _(i).index=i;_(i).style.cursor='pointer';
		if(type=='onmouseover')_(i).onmouseover=function(){show(this.index);}
		else if(type=='onclick')_(i).onclick=function(){show(this.index);}
		_(i,"_el").onmouseover=function(){isLock=true;}
		_(i,"_el").onmouseout=function(){isLock=false;}
	}
	this.setMenu=function(el){
	   var index=$L.el(el).index;
	   show(index);
	}; 
/*循环自动切换*/	
	if(!times||times<1000||ts.length==1)return;
	setInterval(function(){
		if(isLock)return;
	    autoIndex++;
		if(autoIndex>ts.length-1)autoIndex=0;
		show(autoIndex);
	},times); 
};
$L.Input=new Object();
$L.Input.Integer=function(obj){
	obj.onkeyup=function(){this.value=$L.Regx.Integer(this.value);}
};

$L.tranceStore=function(msg){
	try{
	   var store=eval("["+msg+"]");
	   if(store[0])return store[0];
	}catch(e){}
	if(!$L.storeDiv){$L.storeDiv=$L.create("DIV",{},document.body);$L.hide($L.storeDiv);}
	$L.storeDiv.innerHTML="["+msg+"]";var store=eval($L.storeDiv.innerHTML);return store[0];
};
$L.checkHiddenFrame=function(){
    var id="hiddenIFrame";
	if($L.ID(id))return id;
	var frame=$L.create("DIV",{},document.body);
	frame.setStyles("display:none;overflow:hidden;");
	var iframe=$L.create("IFRAME",{},frame);
	iframe.id=id;iframe.name=id;
	return id;
};

//
$L.getForm=function(form){
    form=$L.el(form);var ps={};
	for(var i=0;i<form.length;i++){
        var key=form[i].name;
		if(!key)continue;
		if(form[i].type=='radio'){
			if(form[i].checked){ps[key.toLowerCase()]=form[i].value;}
			continue;
		}
		else
			ps[key.toLowerCase()]=form[i].value; 
	}
	return ps;
}; 
$L.autoSize=function(el){
   var autoLayout=new Object();
   autoLayout.el=el;
   autoLayout.doLayout=function(){
	   this.el.doLayout($L.Index.getWidth(),$L.Index.getHeight());
   };
   $L.autoLayout(autoLayout);
};
$L.layoutPools=new Array();
$L.autoLayout=function(obj){$L.layoutPools.push(obj);};
$L.removeLayout=function(o){$L.layoutPools.remove(o);};
setInterval(function(){for(var i=0;i<$L.layoutPools.length;i++){try{$L.layoutPools[i].doLayout();}catch(e){}}},100);
$L.addUnloadEvent=function(fun){
    if(!$L.unLoadPools){
	    $L.unLoadPools=new Array();
	    document.onunload=function(){for(var i=0;i<$L.unLoadPools.length;i++){try{$L.unLoadPools[i]();}catch(e){}}};
	}
    $L.unLoadPools.push(fun);
}; 
$L.setValues=function(form,store){ 
    form=$L.el(form);
	var inputs=document.getElementsByTagName("INPUT");
	for(var i=0;i<inputs.length;i++){
	    var n=inputs[i].name;if(!n)continue;n=n.toLowerCase();var sv=store[n];var type=inputs[i].type;if(!type)type='text';
		if(!sv)continue;type=type.toLowerCase();if(type=='radio'){inputs[i].checked=inputs[i].value==sv;continue;}
		if(type=='checkbox'){if(!sv)continue;sv=","+sv+",";inputs[i].checked=(sv.indexOf(","+inputs[i]+",")!=-1);continue;}
		inputs[i].value=sv;
	}
	var selects=document.getElementsByTagName("SELECT");
	for(var i=0;i<selects.length;i++){
	    var ops=selects[i].options;var n=selects[i].name;if(!n)continue;n=n.toLowerCase();var v=store[n];if(!v)continue;
		for(var j=0;j<ops.length;j++){if(ops[j].value==v)ops[j].selected=true;}
	}
};
//---浏览器事件模型
$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;};
	this.add=this.addEvent;
	this.addClick=function(name,fun){this.add('onclick',name,fun);};
	this.removeClick=function(name){this.removeEvent('onclick',name);};
	document.onmouseup=function(){doEvent("onmouseup");};
	document.onmousedown=function(){doEvent("onmousedown");};
	document.onclick=function(){doEvent("onclick");};
	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.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.Ajax=new Object();//Ajax对象
$L.Ajax.Request=function(ps){
    if(!ps)ps={};
	this.add=function(n,v){ps[n]=v;};
	this.addPlugin=function(n,v){ps[n+".plugin"]=v;};
    this.get=function(){return ps;};
};
//保存资源
$L.save=function(key,obj){
   if(!$L.sourceArray)$L.sourceArray={};
   $L.sourceArray[key.toLowerCase()]=obj;
};
//获取资源
$L.get=function(key){
	 if(!$L.sourceArray)$L.sourceArray={};
     return $L.sourceArray[key.toLowerCase()];
}; 
$L.trim=function(str){ try{ str=str.trim();}catch(e){} return str;};
$L.show=function(el){el=$L.el(el);el.style.display='';};
$L.hide=function(el){el=$L.el(el);el.style.display='none';};
$L.isHide=function(el){return el.style.display=='none';};
$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.SimpleStore=function(label,value){this.getLabel=function(){return label;};this.getValue=function(){return value;};}
$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.getTestStore=function(){return [{label:'易尚互联',value:'易尚互联'},{label:'JAVA联盟',value:'JAVA联盟'}];};
$L.random=function(max){if(!max)max=10000;return parseInt(Math.random()*max);};
$L.pxInt=function(px){if(/px/.test(px))px=px.substring(0,px.length-2);return parseInt(px);};
$L.isOpera =$L.check(/opera/);
$L.isIE=!$L.isOpera&&$L.check(/msie/);
$L.isIE7 =$L.isIE &&$L.check(/msie 7/);
$L.hand=function(el){el.style.cursor='pointer';};
$L.openQQ=function(qq){window.open("tencent://message/?uin="+qq);};
$L.el=function(el){if( typeof el=='string')return $L.ID(el); return el;};
$L.isIE8 =$L.isIE &&$L.check(/msie 8/);
$L.isWindows=$L.check(/windows|win32/);
$L.isLinux =$L.check(/linux/);
$L.copy=function(ps,a){if(!a)a=new Array();for(var  n in ps)a[n]=ps[n];return a;};
$L.SPAN="&nbsp;";
$L.Enter=function(form,fun){//回车支持
    form=$L.el(form);
	for(var i=0;i<form.length;i++){
	   form[i].onkeypress=function(){ 
	       if(event.keyCode==13)fun();
	   }
	}
};
$L.setForm=function(form,ds){//设置表单
    form=$L.el(form);var inputs=document.getElementsByTagName("INPUT");
	for(var i=0;i<inputs.length;i++){//输入框对象集合
	     var n=inputs[i].name;if(n)n=n.toLowerCase(); 
		 if(inputs[i].type=='radio'&&inputs[i].value==ds[n])inputs[i].checked=true;
		 else if(inputs[i].type=='checkbox'&&inputs[i].value==ds[n])inputs[i].checked=true;
		 else inputs[i].value=ds[n]; 
	}
};
$L.getScrollTop=function(){
   var t1=document.documentElement.scrollTop;
   var t2=document.body.scrollTop;
   if(t1)return t1;if(t2)return t2;
   return 0;
};

$L.getScrollLeft=function(){
   var l1=document.documentElement.scrollLeft;
   var l2=document.body.scrollLeft;
   if(l1)return l1;if(l2)return l2;
   return 0;
};
//设置剧中
$L.setCenter=function(el){
     if(typeof el=='string')el=$L.ID(el);
	 var t=$L.getScrollTop();var l=$L.getScrollLeft();
	 var w=parseInt(($L.getWidth()-$L.getBoxWidth(el))/2)+l;
	 var h=parseInt(($L.getHeight()-$L.getBoxHeight(el))/2)+t;
	 el.style.top=h+"px";
	 el.style.left=w+"px";
};
$L.startSearch=function(form){
    form=$L.el(el);
    if(form.method=='POST')form.method="GET";
	for(var n in form){
	   if(!form[n].value)continue;
	   form[n].value=encodeURIComponent(form[n].value);
	}
	form.submit();
};
$L.User=function(store){
   this.isLogin=function(){return store.id!='';};
   this.getAccount=function(){return store.account;};
   this.getId=function(){return store.id;};
   this.getStore=function(){return store;};
   this.load=function(){
       for(var n in store){
	      try{
			 $L.ID(n).innerHTML=store[n];  
		  }catch(e){}
	   }
   };   
};
$L.replaceAll=function(str,newStr,oldStr){while(str.indexOf(oldStr)!=-1)str=str.replace(oldStr,newStr);return str;};
$L.getBoxWidth=function(el){try{return el.offsetWidth;}catch(e){}return 0;};
$L.getBoxHeight=function(el){try{return el.offsetHeight;}catch(e){};return 0;};
$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.clearAll=function(ch){try{ch=$L.el(ch);ch.innerHTML="";}catch(e){}};
$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.parseFloat=function(val,dVal){if(!dVal)dVal=0;try{val=parseFloat(val);if(isNaN(val))return dVal;return $L.float(val,2)}catch(e){return dVal}};
$L.float=function(src,pos){if(!pos)pos=2;return Math.round(src*Math.pow(10, pos))/Math.pow(10, pos);}; 
$L.ID=function(id){return document.getElementById(id);};
$L.removeCh=function(el){el.parentNode.removeChild(el);}; 
$L.Car=function(store){//购物车对象
   this.getTotle=function(){
	   var totle=0;
	   for(var i=0;i<store.length;i++)totle+=this.getMyPrice(i);
	   return $L.parseFloat(totle,0);
   }; 
   this.getPrice=function(i){
       var p=$L.parseFloat(store[i].price,0);if(p)return p;
	   var p0=$L.parseFloat(store[i].p0,0);
	   var pnum=$L.parseInt(store[i].pnum,1);
	   p=p0*pnum; return $L.parseFloat(p,0);
   };
   this.getMyPrice=function(i){//获取实际价格
        var zk=this.getZk(i);
		return $L.parseFloat(this.getPrice(i)*zk,0);
   };
   this.getZk=function(i){//获取折扣率
       var zknum=this.getZkNumber(i);
	   var pnum=$L.parseInt(store[i].pnum,1);
	   if(pnum>=zknum)return store[i].zk;
       return 1;
   };
   this.getZkNumber=function(i){//获取折扣数
	   var zknum=$L.parseInt(store[i].zknum,1);
	   return zknum;
   };
   this.setPNumber=function(i,number){
      if(store[i].minnum){ 
	     if(parseInt(number)<parseInt(store[i].minnum)){alert("对不起，该产购买量不能低于【"+store[i].minnum+"】");number=store[i].minnum;}
	  }
	  store[i].pnum=number;return number;
   };
   this.size=function(){return store.length;};
   this.get=function(i,key,d){if(!d)d="";key=key.toLowerCase();if(!store[i][key])return d;return store[i][key];};
   this.getRequest=function(){//请求对象
       var ps={};
	   for(var i=0;i<this.size();i++){
	       var pnum=$L.parseInt(store[i].pnum,1);
	       ps["NUM-"+store[i].id]=pnum;
	   }
	   return ps;
   };
}; 
$L.sendUrl=function(url,target){
    if(!this.hideForm){
		 var div=this.create("DIV",{},document.body);
		 div.style,display="none";   
	     this.hideForm=this.create("FORM",{method:'GET'},div);
	}
	this.hideForm.action=url;
	this.hideForm.target=target;
	this.hideForm.submit();
};
$L.removeChs=function(hs){for(var i=0;i<hs.length;i++)$L.removeCh(hs[i]);};
$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.chsCallBack=function(el,fun){var chs=el.childNodes;for(var i=0;i<chs.length;i++)fun(chs[i]);};
$L.unTranse=function(value){value=value.replaceAll("/n/n/n","\n");value=value.replaceAll("/n/n","\n");value=value.replaceAll("/n","\n");return value;};
$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);
	}
};
$L.tranStore=function(msg,fields){
   var array=new Array();if(!fields)fields="label,value,filter";
   fields=fields.toLowerCase();var fs=fields.split(",");
   try{
      var ms=msg.split("\n");
      for(var i=0;i<ms.length;i++){
	     var vs=ms[i].split(",");var ds={};
		 for(var j=0;j<vs.length;j++){
		     if(!fs[j])continue;ds[fs[j]]=vs[j];
		 }
		 array.push(ds);
	  }
   }catch(e){throw e;}
   return array;
};
 
//获取文件路径
$L.getFilePath=function(obj){if(obj){if(window.navigator.userAgent.indexOf("MSIE")>=1){obj.select();return document.selection.createRange().text;}else if(window.navigator.userAgent.indexOf("Firefox")>=1) {if(obj.files){return obj.files.item(0).getAsDataURL();}return obj.value;}return obj.value;}};
//分页对象
$L.Paging=function(start,record,max,href){
    

};
//锁定对象
$L.lock=function(obj,time){new $L.LockWorker(obj,time);};
$L.LockWorker=function(obj,time){
	var lckId="LOCK-"+$L.random(50000);
	obj.lockId=lckId;
    if(!time)time=1000;obj.lock=true;setTimeout(function(){if(obj.lockId==lckId)obj.lock=false;},time);
};

$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.getHeight=function(){var h=document.documentElement.clientHeight;if(h)return h;return document.body.clientHeight;};
$L.getWidth=function(){var h=document.documentElement.clientWidth;if(h)return h;return document.body.clientWidth;};
$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;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;
};
$L.getTableContent=function(tab){ var chs=tab.childNodes;  for(var i=0;i<chs.length;i++) if(chs[i].tagName=='TBODY')return chs[i]; var tbody=$L.create("TBODY",{},tab); return tbody;};


$L.showPhoto=function(src,isMask,host){
	if(!host)host="";
	if(!$L._vsel){
       $L._vsel=$L.create("DIV",{},document.body);
	   $L._vsel.setStyles("width:100px;height:100px;border:10px solid #999999;position:absolute;display:none;text-align:center;z-index:100000;");
	   $L._vsel.setStyles("background-color:#FFFFFF;overflow:hidden;");
	   $L._vsel.content=$L.create("DIV",{},$L._vsel);
	   $L._vsel.content.setStyles("width:100%;height:100%;position:relative;");
	   $L._vsel.closeBtn=$L.create("IMG",{src:host+'/testIcons/closelabel.gif'},$L._vsel.content);
	   $L._vsel.closeBtn.setStyles("position:absolute;right:10px;top:10px;");
	   $L._vsel.closeBtn.onclick=function(){$L.hide($L._vsel);if(isMask)$L.Mask.hide();}
   }
   $L._vsel.setStyles("width:100px;height:100px;");
   var lightBox=new $L.PhotoLightBox(src,isMask);
};

$L.PhotoLightBox=function(src,isMask){
   var w=100;var h=100;var alpha=30;var alphaStemp=1;
   var dImgWidth=20;var dImgHeight=20;var dImgSrc="";
   var image=new Image();image.src=src;
   $L.css.setAlpha($L._vsel,alpha);
   function show(noSlide){
	   $L.show($L._vsel);
       var width=$L.getBoxWidth($L._vsel);var height=$L.getBoxHeight($L._vsel);
       var x=parseInt(($L.getWidth()-width)/2);
	   var y=parseInt(($L.getHeight()-height)/2);
	   if(x<0)x=0;if(y<0)y=0;
	   $L._vsel.style.left=x+"px";
	   $L._vsel.style.top=y+$L.getScrollTop()+"px";
	   if(!noSlide)doLoad();
   }
   function doLoad(){$L._vsel.setStyles("background:url("+dImgSrc+") no-repeat");}
   show(); if(isMask)$L.Mask.show();
   if($L._vsel.clearInd)return;
   var clearInd=setInterval(function(){
      if(!$L._vsel)return;if($L.isHide($L._vsel))return; 
	  if(image.width==0){doLoad();return;}
	  dImgWidth=image.width;dImgHeight=image.height;dImgSrc=image.src;
	  w=image.width; h=image.height;
	  var width=$L.getBoxWidth($L._vsel);var cw=false;var ch=false;
	  var height=$L.getBoxHeight($L._vsel);
	  if(width<w){
	     width+=30;cw=true;
	  }else if(height<h){
	     height+=30;ch=true;
	  }else if(alpha<100){alpha+=5;}
	   else{clearInterval(clearInd);alpha=100;}
	  $L.css.setAlpha($L._vsel,alpha);
	  if(width>w){width=w;cw=true;}if(height>h){height=h;ch=true;}
	  if(width)$L._vsel.style.width=width+"px";
	  if(ch)$L._vsel.style.height=height+"px";
	  show();
	},20);
};
 
//漂浮的支持
$L.Float=function(el){
	el.style.position="absolute";
	el.x=$L.getLeft(el);
	el.y=$L.getTop(el);
    setInterval(function(){
						 
						 
    },50);
};
/**设为首页**/
$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.Pa=function(start,max,record){
   this.getStart=function(){return start;};
   this.getRecord=function(){return record;};
   this.getMax=function(){return max;};
   this.getPages=function(){
       var pages=parseInt(record/max);
	   if(record%max==0)return pages;
	   return pages+1;
   };
   this.getLast=function(){
        var last=start-max;
		if(last<0)last=0;
	    return last;
   };
   this.getNext=function(){
        var next=start+max;
		return next;
   };
   this.getEnd=function(){
       if(record%max==0)return record-max;
	   return record-record%max;
   };
   this.getCurrentPage=function(){
       return (parseInt(start/max))+1;
   };
   this.getStartRecord=function(pages){
       return (page-1)*this.getMax();
   };
   this.loadStore=function(){};
};
//----百分百刷新-------------------
$L.refresh=function(){
    var href=location.href;
	href=$L.refreshHref(href);
	$L.sendRedirect(href);
};
$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);
};

$L.showLine=function(obj,type,target){
	var self=this;
	var id="-OGW-RESIZE-LINE";
	var name="-OGW-RESIZE-LINENAME";
    var line=$L.ID(id);
	if(!line){line=$L.create("DIV",{'id':id},document.body);}
	line.setStyles("background-color:#CCCCCC;position:absolute;z-index=10000;");
	if(!target)target=obj.parentNode;
	
	obj.onmousedown=function(){
		$L.show(line);
		var h=$L.getBoxHeight(obj.parentNode);//父容器的高度
	    var w=$L.getBoxWidth(obj.parentNode);//父容器的宽度 
		if(type=='|'){
		   line.style.width="5px";
		   line.style.height=h+"px";
		}
		if(type=='-'){
		   line.style.height="5px";
		   line.style.width=w+"px";
		}
		var ps=new Object();
	    $L.Event.addEvent('onmousemove',name,function(){
			var y=$L.getTop(target);
			var x=$L.getLeft(target);
			if(type=='-'){
				ps.y=event.clientY;
				y=event.clientY;
			}
			
			if(type=='|'){
				ps.x=event.clientX;
				x=event.clientX;
			}
		    line.style.left=x+"px";
			line.style.top=y+"px"; 
		});
		$L.Event.addEvent('onmouseup',name,function(){
		     $L.Event.removeEvent("onmousemove",name);
		     $L.Event.removeEvent("onmouseup",name);
			 $L.hide(line);
			 if(self.after)self.after(ps);
		});
	}
};























 




/**图片缩放**/
$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.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.IconManager=function(){
	var self=this;var pools=new Array(); 
    this.add=function(o){pools.add(o);};
	this.select=function(o){
	    if(!event.ctrlKey)this.unselect();
		o.selected();
	 
	};
	this.unselect=function(){
	    try{for(var i=0;i<pools.length;i++)pools[i].unselect();}catch(e){}
	}
//自动排列的支持
	this.doLayout=function(cols,w,h){
	    for(var i=0;i<pools.length;i++){
			pools[i].index=i;
			if(pools[i].doLayout)pools[i].doLayout();
		}
	};
	this.getSize=function(){return pools.length;};
	this.moveAt=function(index,o){
		pools.moveAt(index,o);
	};
//获取选择的对象
	this.getRecord=function(){
	    var rs=new Array();//被选中的数据
		for(var i=0;i<pools.length;i++){
		   if(pools[i].isSelected)rs.push(pools[i]);
		}
		return rs;
	};
};
//#==========================================
$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.transData=function(names,ids){
   if(!ids)ids=names;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;
};
//获取location.href的参数值
$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.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.disabled=function(){$L.lock(self);};
       con.onmousedown=function(){
		  con.onmousemove=function(){} ;
		  if(self.lock)return;
		  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,40);
		  el.style.left=x+"px";el.style.top=y+"px";var w=5,h=5;
		  con.onmousemove=function(){ 
		     el.style.display="";w=event.x-x;h=event.y-y;
		     self.width=w;self.x=x;self.height=h;self.y=y;
			 if(w<=0){self.width=0-w;self.x=x+w;}
			 el.style.width=self.width+"px";
			 el.style.left=self.x+"px";
			 if(h<=0){self.height=0-h;self.y=y+h;}
			 el.style.height=self.height+"px";
			 el.style.top=self.y+"px";
			 if(self.handle)self.handle();
			// el.innerHTML ="<BR/>el.style.left:"+self.x;
			// el.innerHTML+="<BR/>el.style.top:"+self.y;
			// el.innerHTML+="<BR/>el.style.width:"+self.width;
			// el.innerHTML+="<BR/>el.style.height:"+self.height;
		  }
		  $L.Event.addEvent('onmouseup',name,function(){
			  
			  el.style.display="none";con.onmousemove=null;selectCheck();
			  
		  });
       }
}


$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;
   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.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);
	};
}
//设置样式
$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,ss){
	 tag=tag.toUpperCase();
     var tagObj=document.createElement(tag);
	 if(tag=="INPUT"){
		 if(attrCode=='undefinde')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);}
	 tagObj.clear=function(){this.innerHTML="";}
	 return tagObj;
}
//CSS名称转换大写
$L.cssUpp=function(str){
  str=str.replace(/-\w+/g,function(word) {
	  return word.substring(1,2).toUpperCase( )+
	  word.substring(2);
  });
  return str;
}
/**跳转***/
$L.sendRedirect=function(url){
   url=encodeURI(url);location.href=url;
} 
/*****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].startWith(name))
		return msg[i].substring(name.length+1);
	}
	return "";
	
}



//简单的切换
$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){
	var target=config["target"];//响应对象
	if(target.parentNode==document.body){//
	   new $L.documentMove(target,config.source,this);
	}else{
	  new $L.localMove(config,this);
	}
}

//全局移动
$L.documentMove=function(target,source,work){
	 
	var name="move_work_"+$L.random(99999);
	target.style.position="absolute";
	source.onmousedown=function(){
	    if(event.button==2){return}
		if(target.beforeMouseDown)target.beforeMouseDown();
	    if(work.lock)return;
		$L.Mask.show();
		var x=event.x;
		var y=event.y;
		$L.Event.addEvent('onmousemove',name,function(){
			if(work.moveHandle)work.moveHandle();
		    var left=event.clientX-x;
			var top=event.clientY-y;
			if(top<0)top=0;
			if(left<0)left=0;
	        target.style.left=left+"px";
			 
			target.style.top=top+$L.getScrollTop()+"px";
			 
		})
		$L.Event.addEvent('onmouseup',name,function(){
	        $L.Event.removeEvent('onmousemove',name);
			$L.Event.removeEvent('onmouseup',name);
			if(work.stopmove)work.stopmove();
			if(!target.isModle){
			   $L.Mask.hide();
			}
		});
	}
}
//局部移动
$L.localMove=function(config,work){
    var name="move_work_"+parseInt(Math.random()*99999);
	var source=config["source"];//事件源 也就是触发对象
	var target=config["target"];//响应对象
	target.style.position="absolute";
	source.onmousedown=function(){
		if(event.button==2){return}
		if(target.beforeMouseDown)target.beforeMouseDown();
	    if(work.lock)return;
		var x=event.offsetX ;
		var y=event.offsetY;
		var mw=$L.getBoxWidth(target.parentNode);
		var mh=$L.getBoxHeight(target.parentNode);
		var tw=$L.getBoxWidth(target);
		var th=$L.getBoxHeight(target);
		if(target.mask)$L.Mask.show();
		work.isMoved=false;
		$L.Event.addEvent('onmousemove',name,function(){
			work.isMoved=true;
			if(work.moveHandle)work.moveHandle();
			var left=event.x-x;
			var top=event.y-y;
			if(left<0)left=0;if(top<0)top=0;
			if(left>mw-tw)left=mw-tw;
			if(top>mh-th)top=mh-th;
			target.x=left;target.y=top;
	        target.style.left=left+"px";
			target.style.top=top+target.parentNode.scrollTop+"px";
		})
		$L.Event.addEvent('onmouseup',name,function(){
	         $L.Event.removeEvent('onmousemove',name);
			 $L.Event.removeEvent('onmouseup',name);
			 if(!work.isMoved)return;
			 if(work.stopmove)work.stopmove();
			 $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.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.readGroupView=function(view,name,handle){//分组读取
    var map={};
	for(var i=0;i<view.length;i++){
	   	var v=view[i][name];
		var g=map[v];if(!g){g=new Array();map[v]=g;}
		g.push(view[i]);
	}
	for(var n in map){handle(map[n]);}
};
$L.Tree=function(store,idName,pidName,deep){
	var deeps=new Array();for(var i=0;i<deep;i++)deeps[i]=",";
	function _id(o){return o[idName];}
	function _pid(o){return o[pidName];} 
	function _find(id){for(var i=0;i<store.length;i++){if(id==_id(store[i]))return store[i];}return null;}
	function check(o){
		var id=_id(o);var pid=_pid(o); 
		if(!pid){o._root=true;return;}var po=_find(pid);
		if(!po){o._root=true;return;}o._parent=po;
		po._hasSon=true;
		check(po);
	}
    for(var i=0;i<store.length;i++){check(store[i]);}
	for(var i=0;i<store.length;i++){//第一级别
	   if(!store[i]._root)continue;
	   deeps[0]+=_id(store[i])+",";
	}
	for(var i=1;i<deep;i++){
	   var lastDeep=deeps[i-1];
	   if(lastDeep.length==1)continue;
	   for(var j=0;j<store.length;j++){ 
		   var pid=_pid(store[j]);
		   if(lastDeep.indexOf(','+pid+",")==-1)continue;
		   deeps[i]+=_id(store[j])+",";
	   }
	} 
	this.getDeep=function(d){return deeps[d-1];};
	this.exe=function(d,handle){
		d=this.getDeep(d);
	   d=d.substring(1).split(',');
	   for(var i=0;i<d.length;i++){
	      var o=_find(d[i]);
		  if(o)handle(o);
	   }
	}; 
};



 
 
 
 
 
 
 
 
 
/******AJAX的支持*******/
$L.createNewAjax=function(){
         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=$L.createNewAjax();
  AjaxJcms.setRequest("className",className);
  AjaxJcms.setRequest("encoding2","UTF-8");
  for(var n in parammers){ 
	 if(typeof parammers[n]=='function')continue; 
	 AjaxJcms.setRequest(n,parammers[n]); 
  }
  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();
};
//获取Store数据源
$L.Ajax.getStore=function(className,ps,fun){
	$L.Ajax.getResult(className,ps,function(msg){
	     var store=eval(msg);
		 fun(store);
	});
};
//获取数据源
$L.Ajax.getSource=function(className,ps,fun){
	$L.Ajax.getResult(className,ps,function(msg){
		  fun($L.tranceStore(msg));return;
	});
};
//获取结果
$L.Ajax.getResult=function(className,ps,fun){
    JAVA.清空监听(); 
	JAVA.调用成功=function(msg){  
		if(msg=='error.user.nologin'){alert("用户未登录或者登录超时,请重新登录!");return;}
		msg=msg.replaceAll("'\\+'   '\\+'","/n");fun(msg); 
	}
    JAVA.调用(className,ps);
};








