﻿//是否调试模式
var DEBUG=false;

//无任何操作
function _void(){}

//根据ID得到对象
function $(id){
	if(document.all){
		return document.all(id);
	}else{
		var obj=document.getElementById(id);
		if(obj==null){
			var obj1=document.getElementsByName(id);
			if(obj1!=null&&obj1.length==1){
				obj=obj1[0];
			}
		}
		return obj;
	}
}

//多语言资源
var Lang={
	defaultLang:'BIG',
	p:'ssolang',
	resource:new Array(),//多语言资源
	a:function(id,lang,val){
		this.resource[id+'.'+lang]=val;
	},
	g:function(id){
		return this.resource[id+'.'+this.l()];
	},
	l:function(){
		var lang=top.Cookie.get(this.p);
		if(lang==null) lang=this.defaultLang;
		return lang;
	},
	s:function(lang){
		try{
			top.Cookie.set(this.p,lang);
		}catch(e){
			Cookie.set(this.p,lang);
		}
	}
}
Lang.a('sysmsg','BIG','提示');
Lang.a('sysmsg','GB','提示');
Lang.a('sysmsg','EN','notice');

//日期处理
var D={
	days:new Array('星期日','星期一','星期二','星期三','星期四','星期五','星期六','星期日','星期一','星期二','星期三','星期四','星期五','星期六','Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'),
	dayOfToday:function(){
		var lang=Lang.l();
		var nowT=new Date();
		var dayNo=nowT.getDay();
		nowT=null;
		
		var day='';
		if(lang=='BIG') day=this.days[dayNo];
		if(lang=='GB') day=this.days[dayNo+7];
		if(lang=='EN') day=this.days[dayNo+14];
		return day;
	},
	
	dayOfDate:function(nowT){
		var lang=Lang.l();
		var dayNo=nowT.getDay();
		nowT=null;
		
		var day='';
		if(lang=='BIG') day=this.days[dayNo];
		if(lang=='GB') day=this.days[dayNo+7];
		if(lang=='EN') day=this.days[dayNo+14];
		return day;
	}	
}


//窗口操作
var W={
	t:function(){
		if (document.body) {   
			return document.body.scrollTop;         
		}else if (document.documentElement && document.documentElement.scrollTop) {       
			return document.documentElement.scrollTop;            
		}  
	},
	l:function(){
		if (document.body) {       
			return document.body.scrollLeft;   
		}else if (document.documentElement && document.documentElement.scrollLeft) {    
			return document.documentElement.scrollLeft;           
		}  
	},
	w:function(){
		if (document.body) {      
			return document.body.scrollWidth;   
		}else if (document.documentElement && document.documentElement.scrollWidth) {         
			return document.documentElement.scrollWidth;    
		} 
	},
	h:function(){
		if(document.body) {  
			return document.body.scrollHeight;   
		}else if (document.documentElement && document.documentElement.scrollHeight) {      
			return document.documentElement.scrollHeight;     
		}  
	}
}

//iframe相关操作
var IFrame={
	minHeight:300,
	adjustSize:function(id){
		try{		
			var obj=$(id);		
		
			if (obj.document && obj.document.body.scrollHeight){ //如果用户的浏览器是IE
				var h=eval(id).document.body.scrollHeight;
				obj.height = (h>this.minHeight?h:this.minHeight); 
			}else if (obj.contentDocument && obj.contentDocument.body.offsetHeight){//如果用户的浏览器是NetScape
				var h=eval(id).document.body.offsetHeight;
				obj.height = (h>this.minHeight?h:this.minHeight); 
			}
		}catch(e){
			//if(DEBUG){
			//	alert('There are errors in calling IFrame.adjustSize:function('+id+'):'+e);
			//}
			//if(obj)	obj.height = this.minHeight;			
		}
	},
	
	adjustSizeXY:function(id){
		try{		
			var obj=$(id);		
		
			if (obj.document && obj.document.body.scrollHeight){ //如果用户的浏览器是IE
				var h=eval(id).document.body.scrollHeight;
				obj.height = (h>this.minHeight?h:this.minHeight); 
				
				
				var w=eval(id).document.body.scrollWidth;
				obj.width = w; 
			}else if (obj.contentDocument && obj.contentDocument.body.offsetHeight){//如果用户的浏览器是NetScape
				var h=eval(id).document.body.offsetHeight;
				obj.height = (h>this.minHeight?h:this.minHeight); 
				
				var w=eval(id).document.body.offsetWidth;
				obj.width = w; 
			}
		}catch(e){
			//if(DEBUG){
			//	alert('There are errors in calling IFrame.adjustSize:function('+id+'):'+e);
			//}
			//if(obj)	obj.height = this.minHeight;			
		}
	},
	
	adjustSizeX:function(id){
		try{		
			var obj=$(id);		
		
			if (obj.document && obj.document.body.scrollHeight){ //如果用户的浏览器是IE
				var h=eval(id).document.body.scrollHeight;
				obj.height = h; 
			}else if (obj.contentDocument && obj.contentDocument.body.offsetHeight){//如果用户的浏览器是NetScape
				var h=eval(id).document.body.offsetHeight;
				obj.height = h; 
			}
		}catch(e){
			//if(DEBUG){
			//	alert('There are errors in calling IFrame.adjustSize:function('+id+'):'+e);
			//}
			//if(obj)	obj.height = this.minHeight;			
		}
	},

	//往iframe窗口中写如内容
	setContent:function(frm,content){
		if(frm.contentDocument){
			frm.contentDocument.write(content);
			frm.contentDocument.close();
		}else{
			frm.document.write(content);
			frm.document.close();
		}
	},

	//frm: iframe对象
	//elementId: iframe窗口中的对象id
	//content: 往ifame窗口中id为elementId的对象中写入内容
	setElementContent:function(frm,elementId,content){
		if(frm.contentDocument){
			frm.contentDocument.getElementById(elementId).innerHTML=content;
		}else{
			frm.document.all(elementId).innerHTML=content;
		}	
	}
}

//字符串操作
var Str={
	//全部替换
	replaceAll:function(str,original,alternative){
		var tokens=new Array();
		var index=str.indexOf(original);
		while(index>=0){
			tokens.push(str.substring(0,index)+alternative);
			str=str.substring(index+original.length);
			index=str.indexOf(original);

			if(str=='') break;
		}
		if(str!='') tokens.push(str);
		var newstr=tokens.join('');
		tokens=null;
		return newstr;
	},

	//去掉首尾空格
	trimAll:function(str){
		for(;str.indexOf(' ')==0;){
			str=str.replace(' ','');
		}
		for(;str!=''&&str.lastIndexOf(' ')==str.length-1;){
			str=str.substring(0,str.length-1);
		}	
		return str;
	},
	
	//计算字符串长度（字节数）
	bytes:function(str,encoding){
		var len=0;
		for(var i=0;i<str.length;i++){
			var sub=str.substring(i,i+1);
			if(sub.match(/[\u4E00-\u9FA5]/)){
				if(encoding==undefined||encoding.toUpperCase()=='UTF-8'){
					len+=3;
				}else{
					len+=2;
				}
			}else{
				len+=1;			
			}
		}
		return len;
	},
	
	//我们是<font color="red" id="3.8">中国人</font>xxx<font color=\'red\'>些某</font>yyy<font color=\'red\'/>x
	delTag:function(src,tagName){	
		var re=new RegExp('<'+tagName+'[^<]*>','gm');
		src=src.replace(re,'');
		
		re=new RegExp('</'+tagName+'>','gm');
		src=src.replace(re,'');
		
		return src;
	}
}


//解析当前url中的参数
var Paras={
	paras:new Array(),

	//初始化,解析并保持参数
	init:function(){
		var parastr=window.location.href;
		while(parastr.lastIndexOf('#')==parastr.length-1){
			parastr=parastr.substring(0,parastr.length-1);
		}
		var pos = parastr.indexOf('?');
		if(pos>0){
			parastr = parastr.substring(pos+1);
			if (parastr.indexOf('&')>0){
				var para = parastr.split('&');
				for(i=0;i<para.length;i++){
					pos = para[i].indexOf('=');
					this.paras[para[i].substring(0,pos)]=para[i].substring(pos+1);
				}
			}else{
				pos = parastr.indexOf('=');
				this.paras[parastr.substring(0,pos)]=parastr.substring(pos+1);
			}
		}	
	},	
	
	//得到参数
	getPara:function(name){
		return this.paras[name];
	},
	
	//得到参数拼串，不包括sso参数
	getParasExSSO:function(){
		var url='';
		for(var i in this.paras){
			if(i.indexOf('sso')>-1){
				continue;
			}
			if(url==''){
				url+='?'+i+'='+this.paras[i];
			}else{
				url+='&'+i+'='+this.paras[i];
			}
		}
		return url;
	},
	
	//得到参数拼串
	getParas:function(){
		var url='';
		for(var i in this.paras){
			if(url==''){
				url+='?'+i+'='+this.paras[i];
			}else{
				url+='&'+i+'='+this.paras[i];
			}
		}	
		return url;
	},
	
	//将字符串转换为各字符的整形编码值，用.分割
	encodeInt:function(val){
		if(val==null){
			return null;
		}
		if(val.length==0){
			return '';
		}
		var ret='';
		for(var i=0;i<val.length;i++){
			ret+=val.charCodeAt(i)+'.';
		}
		return ret.substring(0,ret.length-1);
	},
		
	//encodeInt的反向操作
	decodeInt:function(val){
		if(val==null){
			return null;
		}
		if(val.length==0){
			return '';
		}
		var ret='';
		var values=val.split('.');
		for(var i=0;i<values.length;i++){
			if(values[i]==''||values[i]*1==NaN){
				continue;
			}
			ret+=String.fromCharCode(values[i]*1);
		}
		return ret;
	}
}


//============================
//图片处理
//============================
var IMG={
	images:new Array(),
	
	//添加一个需要预加载的图片
	add:function(src,id,_onload,_onerr){	
		if(!id){
			if(this.images[src]==null){
				var img=new Image();
				img.src=src;
				this.images[src]=img;
			}			
		}else if(this.images[src]==null){
			var img=new Image();
			img.src=src;
			img.id=id;
			
			if(_onload){
				var appname = navigator.appName.toLowerCase();
				if (appname.indexOf("netscape") == -1){			       
					img.onreadystatechange = function () {//IE
				    	if(img.readyState == "complete"||img.readyState == "loaded") {
				        	_onload.call(img);
				    	}
					};
				}else{//FF
					img.onload = function () {
						if(img.complete == true){
							_onload.call(img);
						}
					};
				}
			}
			
			if(_onerr){
				img.onerror = function () {
				    _onerr.call(img);
				};
				img.onabort = function () {
				    _onerr.call(img);
				};
			}
		
			this.images[src]=img;	
		}	
	},
	
	//根据url得到image对象
	get:function(src){
		return this.images[src];
	},
	
	//把预加载的图片的src赋给指定的对象
	set:function(obj,src){
		obj.src=this.images[src].src;
	}
}


//============================
//Cookie处理
//============================
var Cookie={
	//设置cookie，值使用escape编码，默认实效时间30天
	set:function(name,value,hours){
	    if(!hours){
	    	hours = 30*24;
	    }
	    var exp  = new Date();
	    exp.setTime(exp.getTime() + hours*60*60*1000);
	    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
	    exp=null;
	},
	
	//使用正则表达式得到cookie值
	get:function(name){
		//字符串开始或空格+cookie名+'='+不是分号的字母（即cookie的值）零次或多次+分号或者字符串结尾
	    var reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
	    var arr=document.cookie.match(reg);
	    if(arr){
	    	return unescape(arr[2]);
	    }else{
			return null;
		}
	},
	
	//将超时时间设置为当前时间以前的的时间，自然cookie就超时了
	del:function(name){
	    var exp = new Date();
	    exp.setTime(exp.getTime() - 1);
	    var cval=this.get(name);
	    if(cval!=null){
	    	document.cookie= name + "="+cval+";expires="+exp.toGMTString();
	    }
	    exp=null;
	}
}

//============================
//XML操作
//============================
function XML(){
	this.nodes=null;
}

//根据url加载xml
XML.prototype.load=function(url){
	var doc;
	if(typeof(ActiveXObject)!='undefined'){
		doc=new ActiveXObject('Microsoft.XMLDOM');
	}else{
		doc=document.implementation.createDocument("","",null);
	}
	doc.async=false;
	doc.load(url);	
	return doc;
};
	
//将字符串解析成xml
XML.prototype.parse=function(str){
	var doc;
	if(typeof(ActiveXObject)!='undefined'){
		doc=new ActiveXObject('Microsoft.XMLDOM');
		doc.async=false;
		doc.loadXML(str);
	}else{
		doc = (new DOMParser()).parseFromString(str,'text/xml') 
	}
	return doc;
};
	
//得到根节点
XML.prototype.getRoot=function(doc){
	if(doc.getDocumentElement){
		return doc.getDocumentElement();
	}else{
		return doc.documentElement;
	}
};

//得到属性值
XML.prototype.getAttr=function(attr){
	if(typeof(attr.text)!='undefined'){
		return attr.text;
	}else{
		return attr.textContent;
	}
};

/*
得到节点topElement的子节点
如下xml：
<root>
	<p>
		<c>...</c>
		<c>...</c>
		<c>...</c>
	</p>
</root>

可用如下代码得到三个c节点
var x=new XML();
var doc=x.parse(str);
var children=x.selectNodes(x.getRoot(doc),'root/p/c');
*/
XML.prototype.selectNodes=function(topElement,path,level){
	if(!level){
		level=0;
	}
	
	if(level==0){
		this.nodes=new Array();
	}
	
	var names=path.split('/');
	var children=topElement.childNodes;
	if(children==null||children.length==0){
		return null;
	}
	
	if(level==names.length-1){			
		for(var i=0;i<children.length;i++){
			if(children[i].nodeName!=names[level]){
				continue;
			}else{
				this.nodes[this.nodes.length]=children[i];
			}
		}
	}else{	
		for(var i=0;i<children.length;i++){
			if(children[i].nodeName!=names[level]){
				continue;
			}

			this.selectNodes(children[i],path,level+1);
		}
	}
	return (this.nodes==null||this.nodes.length==0)?null:this.nodes;		
};

//得到selectNodes返回得第一个节点
XML.prototype.selectSingleNode=function(topElement,path){
	var ret=this.selectNodes(topElement,path);
	if(ret==null||ret.length==0){
		return null;
	}
	return ret[0];
}


//============================
//Ajax
//============================
function Ajax(method,callback){	
	//XMLHttpRequest
	this.request=null;
	this.method=method;
	this.callback=callback;
}

//与XMLHttpRequest对应的getter和setter
Ajax.prototype.getReadyState=function(){
	return this.request.readyState;
}

Ajax.prototype.getStatus=function(){
	return this.request.status;
}

Ajax.prototype.getStatusText=function(){
	return this.request.statusText;
}

Ajax.prototype.getResponseXML=function(){
	return this.request.responseXML;
}

Ajax.prototype.getResponseText=function(){
	return this.request.responseText;
}

Ajax.prototype.getAllHeaders=function(){
	return this.request.getAllResponseHeaders();
}

Ajax.prototype.getHeader=function(headerName){
	return this.request.getResponseHeader(headerName);
}

Ajax.prototype.setHeader=function(headerName,headerValue){
	this.request.setRequestHeader(heaerName,headerValue);
}

Ajax.prototype.abort=function(){
	this.request.abort();
}

//创建XMLHttpRequest
Ajax.prototype.createXMLHttpRequest=function(){
    try{
    	return new ActiveXObject('Msxml2.XMLHTTP');
	}catch(e1){
		try{
    		return new ActiveXObject('Microsoft.XMLHTTP');
		}catch(e2){
			try{
	    		return new XMLHttpRequest();
			}catch(e3){
				return false;
			}			
		}
	}
}
	
//创建XMLHttpRequest,发送请求
Ajax.prototype.send=function(url){
	if(this.request!=null){	
		try{		
			this.request.abort();
		}catch(e){}
	}
	if(this.request==null){
		this.request=this.createXMLHttpRequest();
	}
	this.request.onreadystatechange=this.callback;
	this.request.open(this.method,url,true);
    this.request.setRequestHeader("If-Modified-Since","0");	
	this.request.send(null);
}

//清除对象
Ajax.prototype.clear=function(){	
	try{
		this.abort();
		Sys.clearObjects(this.request);
	}catch(e){}
}

//系统进度框/提示框——弹出时，背景为整个窗口大小，半透明
//调用时，使用top.Loading.open(左边距，上边距，宽度，高度，callback，当前window对象)
//左边距，上边距，宽度，高度如不指定，设置为-1
var Loading={
	openType:'',
	win:null,
	onClose:null,
	canClose:true,
	w:300,
	h:100,
	wMini:500,
	hMini:18,
	currentMsg:'',
	
	initI18N:function(){//初始化多语言资源
		Lang.a('loading.no_close','BIG','請稍候......');
		Lang.a('loading.no_close','GB','请稍候......');
		Lang.a('loading.no_close','EN','Please wait......');
	},
	
	setTitle:function(tit){
		 if($('loadingTitle')) $('loadingTitle').innerHTML=tit;
	},
	
	close:function(){//关闭
		if(!$('loadingBg')) return;
		
		if(this.canClose==false){
			this.currentMsg=$('loadingMsg').innerHTML;
			//alert(Lang.g('loading.no_close'));
			return;
		}
		this.currentMsg='';

		//$('loadingBg').style.height='30px';
		//$('loading').style.visibility='hidden';
		//$('loadingBg').style.visibility='hidden';
		
		$('loadingBg').parentNode.removeChild($('loadingBg'));
		$('loading').parentNode.removeChild($('loading'));

		if(this.onClose!=null){
			try{
				this.onClose.call(this.win?this.win:window);
			}catch(e){}
		}
	},

	open:function(_l,_t,_w,_h,_onClose,_win){
		if(_l==undefined||_t==undefined||_w==undefined||_h==undefined) return;
		if(this.openType!=''){
			var obj1=$('loadingBg');
			var obj2=$('loading');			
			if(obj1) obj1.parentNode.removeChild(obj1);
			if(obj2) obj2.parentNode.removeChild(obj2);
		}
		this.openType='';
		
		this.onClose=null;
		this.win=null;
		
		if(_onClose) this.onClose=_onClose;
		if(_win) this.win=_win;
			
		this.init();
	
		
		if(_w!=-1){
			$('loading').style.width=_w+'px';
			$('loadingBg').style.width=_w+'px';
		}
		if(_h!=-1){
			$('loading').style.height=_h+'px';
			$('loadingBg').style.height=_h+'px';
		}
		if(_l!=-1){
			$('loading').style.left=_l+'px';
			$('loadingBg').style.left=_l+'px';
		}else if(_w!=-1){
			$('loading').style.left=Math.floor((W.w()-_w)/2)+'px';
			$('loadingBg').style.left=Math.floor((W.w()-_w)/2)+'px';
		}else{
			$('loading').style.left=Math.floor((W.w()-this.w)/2)+'px';
			$('loadingBg').style.left=Math.floor((W.w()-this.w)/2)+'px';
		}
		
		if(_t!=-1){
			$('loading').style.top=_t+'px';	
			$('loadingBg').style.top=_t+'px';	
		}else{
			$('loading').style.top=(W.t()+30)+'px';
			$('loadingBg').style.top=(W.t()+30)+'px';
		}
	
		$('loading').style.visibility='visible';	
		$('loadingBg').style.visibility='visible';
	},
	
	move:function(_l,_t,_w,_h){
		if(_l==undefined||_t==undefined||_w==undefined||_h==undefined) return;
		if(this.openType!='') return;
		if(!$('loadingBg')||!$('loading')) return;
		
		if(_w!=-1){
			$('loading').style.width=_w+'px';
			$('loadingBg').style.width=_w+'px';
		}
		if(_h!=-1){
			$('loading').style.height=_h+'px';
			$('loadingBg').style.height=_h+'px';
		}
		if(_l!=-1){
			$('loading').style.left=_l+'px';
			$('loadingBg').style.left=_l+'px';
		}else if(_w!=-1){
			$('loading').style.left=Math.floor((W.w()-_w)/2)+'px';
			$('loadingBg').style.left=Math.floor((W.w()-_w)/2)+'px';
		}else{
			$('loading').style.left=Math.floor((W.w()-this.w)/2)+'px';
			$('loadingBg').style.left=Math.floor((W.w()-this.w)/2)+'px';
		}
		
		if(_t!=-1){
			$('loading').style.top=_t+'px';	
			$('loadingBg').style.top=_t+'px';	
		}else{
			$('loading').style.top=(W.t()+30)+'px';
			$('loadingBg').style.top=(W.t()+30)+'px';
		}
	
		$('loading').style.visibility='visible';	
		$('loadingBg').style.visibility='visible';
	},

	openTip:function(_l,_t,_w,_h,_onClose,_win){
		if(_l==undefined||_t==undefined||_w==undefined||_h==undefined) return;
		if(this.openType!='tip'){
			var obj1=$('loadingBg');
			var obj2=$('loading');			
			if(obj1) obj1.parentNode.removeChild(obj1);
			if(obj2) obj2.parentNode.removeChild(obj2);
		}
		this.openType='tip';
		
		this.onClose=null;
		this.win=null;
		
		if(_onClose) this.onClose=_onClose;
		if(_win) this.win=_win;
			
		this.initTip();
	
		
		if(_w!=-1){
			$('loading').style.width=_w+'px';
			$('loadingBg').style.width=_w+'px';
		}
		if(_h!=-1){
			$('loadingMsg').style.height=_h+'px';
			$('loadingBg').style.height=_h+'px';
			$('loadingFrame').style.height=_h+'px';
		}
		if(_l!=-1){
			$('loading').style.left=_l+'px';
			$('loadingBg').style.left=_l+'px';
		}else if(_w!=-1){
			$('loading').style.left=Math.floor((W.w()-_w)/2)+'px';
			$('loadingBg').style.left=Math.floor((W.w()-_w)/2)+'px';
		}else{
			$('loading').style.left=Math.floor((W.w()-this.w)/2)+'px';
			$('loadingBg').style.left=Math.floor((W.w()-this.w)/2)+'px';
		}
		
		if(_t!=-1){
			$('loading').style.top=_t+'px';	
			$('loadingBg').style.top=_t+'px';	
		}else{
			$('loading').style.top=(W.t()+50)+'px';
			$('loadingBg').style.top=(W.t()+50)+'px';
		}
	
		$('loading').style.visibility='visible';	
		$('loadingBg').style.visibility='visible';
	},
	
	openMini:function(_l,_t,_w,_h,_onClose,_win){
		if(_l==undefined||_t==undefined||_w==undefined||_h==undefined) return;
		
		if(this.openType!='mini'){
			var obj1=$('loadingBg');
			var obj2=$('loading');			
			if(obj1) obj1.parentNode.removeChild(obj1);
			if(obj2) obj2.parentNode.removeChild(obj2);
		}
		this.openType='mini';
		
		this.onClose=null;
		this.win=null;
		
		if(_onClose) this.onClose=_onClose;
		if(_win) this.win=_win;
			
		this.initMini();
	
		$('loadingBg').style.height=W.h()+'px';
		$('loadingBg').style.width=W.w()+'px';
		$('loadingBg').style.top='0px';
		$('loadingBg').style.left='0px';	
		$('loadingBg').style.visibility='visible';
		
		if(_w!=-1) $('loading').style.width=_w+'px';
		if(_h!=-1) $('loading').style.height=_h+'px';
		if(_l!=-1){
			$('loading').style.left=_l+'px';
		}else if(_w!=-1){
			$('loading').style.left=Math.floor((W.w()-_w)/2)+'px';
		}else{
			$('loading').style.left=Math.floor((W.w()-this.wMini)/2)+'px';
		}
		
		if(_t!=-1){
			$('loading').style.top=_t+'px';		
		}else{
			$('loading').style.top=(W.t()+30)+'px';
		}
		this.setTitle(Lang.g('sysmsg'));
		$('loading').style.visibility='visible';
	},
	
	openMini2:function(_l,_t,_w,_h,_onClose,_win){
		if(_l==undefined||_t==undefined||_w==undefined||_h==undefined) return;
		if(this.openType!='mini2'){
			var obj1=$('loadingBg');
			var obj2=$('loading');			
			if(obj1) obj1.parentNode.removeChild(obj1);
			if(obj2) obj2.parentNode.removeChild(obj2);
		}
		this.openType='mini2';
		
		this.onClose=null;
		this.win=null;
		
		if(_onClose) this.onClose=_onClose;
		if(_win) this.win=_win;
			
		this.initMini2();
	
		$('loadingBg').style.height=W.h()+'px';
		$('loadingBg').style.width=W.w()+'px';
		$('loadingBg').style.top='0px';
		$('loadingBg').style.left='0px';	
		$('loadingBg').style.visibility='visible';
		
		if(_w!=-1) $('loading').style.width=_w+'px';
		if(_h!=-1) $('loading').style.height=_h+'px';
		if(_l!=-1){
			$('loading').style.left=_l+'px';
		}else if(_w!=-1){
			$('loading').style.left=Math.floor((W.w()-_w)/2)+'px';
		}else{
			$('loading').style.left=Math.floor((W.w()-this.wMini)/2)+'px';
		}
		
		if(_t!=-1){
			$('loading').style.top=_t+'px';		
		}else{
			$('loading').style.top=(W.t()+30)+'px';
		}
	
		$('loading').style.visibility='visible';
	},

	setMsg:function(msg){ 
		$('loadingMsg').innerHTML=msg;
		this.currentMsg=msg;
	},
	
	displayCurrentMsg:function(){
		this.setMsg(this.currentMsg);
	},
	
	init:function(){
		if($('loadingBg')){
			return;
		}	
		var str='<div style="z-index:200;position:absolute;float:left; visibility:hidden; top:0px; left:0px; background-color:#ffffff;" id="loadingBg" align="center"></div>';
		str+='<div style="z-index:201;position:absolute;float:left; top:0px; left:0px; visibility:hidden;" id="loading" align="center">';		
		str+=' 		<div id="loadingMsg"></div>';
		str+='</div>';	
		if(document.body.insertAdjacentHTML){
			document.body.insertAdjacentHTML('afterBegin', str);
		}else{
			document.body.innerHTML=str+document.body.innerHTML;
		}
	},
	
	initTip:function(){
		if($('loadingBg')){
			return;
		}	
		var str='<div style="z-index:101;position:absolute; visibility:hidden; width:280px; top:0px; left:0px;filter:alpha(opacity=10);" id="loadingBg"><iframe id="loadingFrame" name="loadingFrame" src="about:blank" width="100%" frameborder="0" scrolling="no"></iframe></div>';
		str+='<div style="z-index:102;position:absolute; visibility:hidden; width:280px; top:0px; left:0px; background-color:#ffffff; border:#cccccc 1px outset;" id="loading">';	
		str+='<div style="width:100%; text-align:left;"><div style="margin:6px;" id="loadingMsg"></div></div>';
  		str+='</div>';
		if(document.body.insertAdjacentHTML){
			document.body.insertAdjacentHTML('afterBegin', str);
		}else{
			document.body.innerHTML=str+document.body.innerHTML;
		}
	},
	
	initMini:function(){
		if($('loadingBg')){
			return;
		}	
		var str='<div style="z-index:101;position:absolute; visibility:hidden;filter:alpha(opacity=70); background-color:#ffffff;" id="loadingBg" align="center"><iframe id="loadingFrame" name="loadingFrame" src="about:blank" width="100%"  height="100%" frameborder="0" scrolling="no"></iframe></div>';
		str+='<div style="width:'+this.wMini+'px; line-height:'+this.hMini+'px; z-index:102;position:absolute; visibility:hidden;background-color:#ffffff;border:#bd9c42 2px solid;overflow:hidden;" id="loading" align="center">';
		str+='	<div style="width:100%;height:24px;line-height:24px;font-size:12px; background-color:#502d0a;">';
		str+='		<div style="float:left; height:24px;text-align:left;color:#fff;margin-left:3px;" id="loadingTitle">&nbsp;&nbsp;'+Lang.g('sysmsg')+'</div>';
		str+='		<div style="float:right; height:24px; margin-right:3px;"><font style="cursor:pointer;font-family:webdings;font-size:12px;color:#fff;" onClick="Loading.close();">r</font></div>';
		str+='	</div>';
		str+='	<div style="width:100%;text-align:center;background-color:#ffffff;color:#000000;"><div style="margin:3px;margin-top:9px;" id="loadingMsg"></div></div>';
		str+='</div>';
		if(document.body.insertAdjacentHTML){
			document.body.insertAdjacentHTML('afterBegin', str);
		}else{
			document.body.innerHTML=str+document.body.innerHTML;
		}
	},
	
	initMini2:function(){
		if($('loadingBg')){
			return;
		}	
		var str='<div style="z-index:101;position:absolute; visibility:hidden;" id="loadingBg" align="center"><iframe id="loadingFrame" name="loadingFrame" src="about:blank" width="100%"  height="100%" frameborder="0" scrolling="no"></iframe></div>';
		str+='<div style="width:'+this.wMini+'px; line-height:'+this.hMini+'px; z-index:102;position:absolute; text-align:left; visibility:hidden;" id="loading">';
		str+='	<div style="width:100%;height:30px;line-height:30px;font-size:12px;" id="loadingMsg"></div>';
		str+='</div>';
		if(document.body.insertAdjacentHTML){
			document.body.insertAdjacentHTML('afterBegin', str);
		}else{
			document.body.innerHTML=str+document.body.innerHTML;
		}
	}
}


//系统方法
var Sys={
	//内存回收
	clearObjects:function(obj1,obj2,obj3,obj4,obj5,obj6){
		if(obj1) obj1=null;
		if(obj2) obj2=null;	
		if(obj3) obj3=null;	
		if(obj4) obj4=null;	
		if(obj5) obj5=null;	
		if(obj6) obj6=null;	
		try{
			CollectGarbage();
		}catch(e){}
	}
}

//调用需要的初始化
Paras.init();
Loading.initI18N();
var lang=Paras.getPara(Lang.p);
if(lang) Lang.s(lang);
