	Object.extend_old= function(destination, source) {
		  for (var property in source){
	      	  if(destination[property]&&source[property]&&typeof source[property]=='object'&&property!="dom"){
	      	      Object.extend_old(destination[property],source[property]);
	      	  }else{
	      		  destination[property] = source[property];
	      	  }
		  }
		  return destination;
	};	
 		function modalView(){
 			this.scrollBarShow=false;
			this.scroll=true;
			this.nTop=true;
			this.nLeft=true;
			this.alignCenter=false;
			this.nContent=true;
			this.scrollBarHide=false;
			this.contentClass=true;
			this.contentTop=0;
			this.contentLeft=0;
			this.lazyClose=false;
			this.lazyShow=false;
			this.speed=10;
			this.autoClose=false;
			this.timeout = 3*1000;
			this.iframe=false;
 		}
    	modalView.prototype={
    		shadowDivs:null,
    		initflag:false,
    		setCfg:function(o){
    			var _self=this;
      			if(navigator.userAgent.indexOf('MSIE')>=0) this.MSIE = true;
    			Object.extend_old(this,o);
				this.creatDivs();
				if(this.lazyClose){
					this.transparentDivs.onmousedown=function(){
						_self.modalClose();
					}
				}
   			},
    		modalShow:function(w,h){
    			var _self=this;
    			if(this.scroll){
					this.contentDivs.style.top=parseInt(this.contentTop.replace("px"))+document.body.scrollTop+"px";
					this.contentDivs.style.left=parseInt(this.contentLeft.replace("px"))+document.body.scrollLeft+"px";
    			}
				else{
					if(this.nTop)this.contentDivs.style.top=this.contentTop;
					if(this.nLeft)this.contentDivs.style.left=this.contentLeft;
					if(this.alignCenter){
						this.contentDivs.style.top="50%";
						this.contentDivs.style.left="50%";
					}
				}
				var arr=this._getElementsByClassName("modalDialog_contentDiv",document);
				var maxIndex=2000;
				for(var i=0;p=arr[i];i++){
					if(arr[i].style.display=="block"){
						if(maxIndex<arr[i].style.zIndex){
							maxIndex=arr[i].style.zIndex;
						}
					}
				}
				this.transparentDivs.style.zIndex = parseInt(maxIndex)+1;
				this.contentDivs.style.zIndex = parseInt(maxIndex)+2;
    			this.transparentDivs.style.display="block";
    			//this.contentDivs.style.display="block";
				if(this.lazyShow){
					var _index=0;
					this.intval=setInterval(function(){_index=_index+_self.speed;_self.lazyLoad(_index)},20);
				}else{
					this.contentDivs.style.display="block";
				}
    			modalUtil.setBjSize(this.transparentDivs);
				document.body.style.overflowY='hidden';
				if(this.autoClose){
					setTimeout(function(){_self.modalClose()},_self.timeout)
				}
    		},
    		getFnName:function(method,name){
    			var res=method.match(/function\s+([^(]+)/);
    			if(res==null||!(name==res[1])) return false;
    			else return true;
    		},
    		creatDivs:function(){
    			this.transparentDivs.className='modalDialog_transparentDivs';
    			this.transparentDivs.style.left = '0px';
    			this.transparentDivs.style.top = '0px';
    			document.body.appendChild(this.transparentDivs);
    			if(this.contentClass)this.contentDivs.className = 'modalDialog_contentDiv';
    			if(this.nTop)this.contentDivs.style.top=this.contentTop;
    			if(this.nLeft)this.contentDivs.style.left=this.contentLeft;
    			modalUtil.setBjSize(this.transparentDivs);
    			document.body.appendChild(this.contentDivs);
    		},
    		modalClose:function(){
    			this.transparentDivs.style.display='none';
    			if(this.nContent)this.contentDivs.style.display='none';
				document.body.style.overflowY='auto';
    		},
    		_getElementsByClassName:function (className, parentElement){
				var elems = (parentElement||document.body).getElementsByTagName("*");
				var result=[];
				for (i=0; j=elems[i]; i++){
					if ((" "+j.className+" ").indexOf(" "+className+" ")!=-1){
						result.push(j);
					}
				}
				return result;
			},
			lazyLoad : function(_index){
				if(_index>=100){
					clearInterval(this.intval);
				}else if(_index==this.speed){
					this.contentDivs.style.display="block";
				}
				this.contentDivs.style.opacity=_index/100;
				this.contentDivs.style.filter='alpha(opacity='+_index+')';
			}
		};
		var mv=null;
		var Imba={};
		Imba.modal=function(){
			var alignCenter,ct,bj;
			var bjCls='bj',ctCls='ct',zIndex=2000,width=200,height=200,_self=this,index=0,btnIndex=0;
	    	try{
	    		var infoObj = new dpmInfo();
				infoObj.addInfo({
					'zh-cn': {
						ok:'是!'
					},
					'en': {
						ok:'Ok'
					}
				});
	    	}catch(e){
	    		var infoObj={
	    			getInfo:function(val){
	    				return val;
	    			}
	    		}
	    	};
			return {
				render:function(opt){
					_self.setModCls(opt);
    				opt.bj.style.top = opt.bj.style.left='0px';
    				modalUtil.setBjSize(opt.bj);
    				_self.renderCenter(opt);
				},
				renderCenter:function(opt){
					this.setWidth(opt.ct,function(dom){
	    				_self.contentWidth=opt.ct.offsetWidth;
	    				_self.contentHeight=opt.ct.offsetHeight;
					});
	    			_self.resetCt(opt);				
				},
	    		resetCt:function(opt){
	    			var topNum=document.body.scrollTop+(document.body.clientHeight-_self.contentHeight)/2;
	    			var tpTop=topNum>=0?topNum:0;
	    			var tpLeft=(window.screen.width-this.contentWidth)/2;
	    			if(typeof opt.left!="undefined")tpLeft+=opt.left;
	    			if(typeof opt.top!="undefined")tpTop+=opt.top;
	    			opt.ct.style.left=tpLeft;
	    			opt.ct.style.top=tpTop;
    			},
    			rgtClose:function(opt){
       				opt.bj.onclick=function(){
       					if(typeof opt.beforeClose=="function")opt.beforeClose();
       					_self.close(_self,opt);
       					if(typeof opt.afterClose=="function")opt.afterClose();
       				};
    			},
				show:function(opt){
					document.body.style.overflowY="hidden";
					_self=this;
					if(opt.onshow)opt.onshow(_self,opt);
					if(opt.btns)_self.renderBtn(opt);
					_self.render(opt);
					opt.bj.style.zIndex = ++zIndex;
					opt.ct.style.zIndex = ++zIndex;
    				opt.bj.style.display="block";
    				opt.ct.style.display="block";
    				modalUtil.setBjSize(opt.bj);
    				_self.rgtClose(opt);
				},
    			getCls:function (className, parentElement){
					var elems = (parentElement||document.body).getElementsByTagName("*");
					var result=[];
					for (i=0; j=elems[i]; i++){
						if ((" "+j.className+" ").indexOf(" "+className+" ")!=-1){
							result.push(j);
						}
					}
					return result;
				},
				setModCls:function(opt){
					var bjExt=opt.bjCls?' '+opt.bjCls:"";
					var ctExt=opt.ctCls?' '+opt.ctCls:"";
                   	if(Browser.isIE){
                   		opt.bj.setAttribute("className",bjCls);
                   		opt.ct.setAttribute("className",ctCls);
                	}else{
                		opt.bj.setAttribute("class",bjCls+bjExt);
                		opt.ct.setAttribute("class",ctCls+ctExt);
                	}					
				},
				close:function(_self,opt){
	    			opt.ct.style.display='none';
	    			opt.bj.style.display='none';
					document.body.style.overflowY='auto';
					if(opt.onclose)opt.onclose(_self,opt);
					document.body.style.overflowY="auto";
				},
				onclose:function(_self,opt){
				},
				onshow:function(_self,opt){
				},
				panelTp:function(head,bodyHtml,opt){
					var ap=document.createElement("div");
					ap.className='uiModalPanel';
					ap.style.background="transparent url(/files/jsp/web/images/modal/"+opt.bgGif+") no-repeat scroll 5px 27px";
					ap.innerHTML=["<div style='width:100%;overflow:hidden;'><span id='modalCLoseMenu_"+opt.ns+"' class='modalCloseCt'><img src='/files/jsp/web/images/modal/close.gif'/></span><h1 class='modalPanelHead'>"+head+"</h1><div class='bodyContent'><div class='modalPanelBody'>"+bodyHtml+"</div><div id='"
					+opt.ns+"_btn_cotain' class='btnContent' align='center'></div></div></div>"].join("");//c4w9.18
					return ap;
				},
				setWidth:function(dom,fn){
					dom.style.visibility="hidden";
					dom.style.display="block";
					fn();
	    			dom.style.display="none";
	    			dom.style.visibility="";
	    			dom=null;
				},
				uiTp:function(head,bodyHtml,pOpt){
					var opt={
						ns:pOpt.ns?pOpt.ns:"modalBtn_"+(btnIndex++)+"_"+index++,
						bgGif:pOpt.bgGif,
						ct:(pOpt.ct?pOpt.ct:null),
						width:pOpt.width?pOpt.width:false,
						onshow:function(_self,opt){
							opt.uiPanel=_self.panelTp(head,bodyHtml,opt);
							opt.ct=opt.ct?opt.ct:document.createElement("div");
							opt.bj=document.createElement("div");
    						document.body.appendChild(opt.bj);
    						document.body.appendChild(opt.ct);
		      				opt.ct.appendChild(opt.uiPanel);
							_self.setWidth(opt.ct,function(){
								if(opt.width){
									opt.ct.style.width=opt.width+"px";
								}
								if(opt.ct.offsetWidth>450){
									opt.ct.style.width="450px";
								}
							});
							opt.btns[opt.btns.length]={
								dom:document.getElementById("modalCLoseMenu_"+pOpt.ns),
								click:function(opt){
									_self.close(_self,opt);
								}
							};
						},
						onclose:function(_self,opt){
							document.body.removeChild(opt.bj);
							document.body.removeChild(opt.ct);
							opt.ct=null,opt.bj=null;
						},
						btns:pOpt.btns?pOpt.btns:[]
					};
					this.show(opt);
				},
				showTxt:function(head,bodyHtml,optpara){
					var opt=optpara||{};					
					opt.ns='alt';
					opt.bgGif='info.gif';
					this.uiTp(head,bodyHtml,opt);
				},
				alert:function(head,bodyHtml){
					var opt={};
					opt.ns='alt';
					opt.bgGif='info.gif';
					opt.btns=
					[
						{
							name:infoObj.getInfo("close"),
							type:"button",
							click:function(opt){
								_self.close(_self,opt);
							}
						}
					];
					this.uiTp(head,bodyHtml,opt);
				},
				confirm:function(head,bodyHtml,yesFn,noFn,cfg){
					var opt={};
					opt.bgGif='important.gif';
					opt.ns='cfm';
					if(cfg){
						opt.width=cfg.width?cfg.width:false;
					}
					opt.btns=
					[
						{
							name:infoObj.getInfo("ok"),
							type:"button",
							click:function(opt){
								_self.close(_self,opt);
								if(yesFn)yesFn(opt,"yes");
							}
						},
						{
							name:infoObj.getInfo("cancel"),
							type:"button",
							click:function(opt){
								_self.close(_self,opt);
								if(noFn)noFn(opt,"no");
							}
						}
					];
					this.uiTp(head,bodyHtml,opt);
				},
				prompt:function(head,bodyHtml,yesFn,noFn){
					var opt={};
					opt.ns='prt';
					opt.bgGif='help.gif';
					opt.btns=
					[
						{
							name:infoObj.getInfo("tip"),
							type:"txt",
							size:'50'
						},
						{
							name:infoObj.getInfo("ok"),
							type:"button",
							click:function(opt){
								if(yesFn)yesFn(opt.btns[0].dom.value,opt,"YES");
								_self.close(_self,opt);
							}
						},
						{
							name:infoObj.getInfo("cancel"),
							type:"button",
							click:function(opt){
								if(noFn)noFn(opt.btns[0].dom.value,opt,"NO");
								_self.close(_self,opt);
							}
						}
					];
					this.uiTp(head,bodyHtml,opt);
				},
				divMd:function(opt){
					opt.bj=document.createElement("div");
					document.body.appendChild(opt.bj);
					if(opt.close){
						opt.btns=[{
							dom:opt.close.dom,
							click:function(opt){
								_self.close(_self,opt);
							}
						}];						
					}
					this.show(opt);
					return {
						close:function(){
							opt.bj.onclick();
						},
						opt:opt
					};
				},
				rdBtnForTxt:function(btn,btnCt){
					btn.dom.setAttribute("type",btn.type);
					btn.dom.className='modalBtnTxt';
					btn.dom.setAttribute("size",btn.size?btn.size:"30");
					btnCt.appendChild(btn.dom);
				},
				rdBtnForButton:function(btn,btnCt){
					btn.dom.setAttribute("type",btn.type);
					btn.dom.setAttribute("value",' '+btn.name+' ');//c4w9.18
					btn.dom.className='modalBtn';
					btnCt.appendChild(btn.dom);
				},
				renderBtn:function(opt){
					var btnCt=document.getElementById(opt.ns+"_btn_cotain");
					for(var i=0;i<opt.btns.length;i++){
						if(!opt.btns[i].dom){
							opt.btns[i].dom=document.createElement("input");
							opt.btns[i].dom.name=opt.btns[i].name;
							switch(opt.btns[i].type){
								case 'txt':
									this.rdBtnForTxt(opt.btns[i],btnCt);
									break;
								case 'button':
									this.rdBtnForButton(opt.btns[i],btnCt);
									break;
								default:
									break;
							}
							if(opt.btns[i].width)
								opt.btns[i].dom.style.width=opt.btns[i].width+"px";
						}
						opt.btns[i].dom.index=i;
						opt.btns[i].dom.onclick=function(e){
							opt.btns[this.index].click(opt);
						}	
					}
				}
			}
		}
		var modalUtil={
			max:function(a,b){
				if(a>b)return a;
				else return b;
			},
			setBjSize:function(bj){
				var brsize=modalUtil.getBrowserSize();
				bj.style.width = brsize[0]+"px";
				bj.style.height = brsize[1]+"px";
			},
			getBrowserSize : function(){
				return [window.screen.availWidth,modalUtil.max(document.body.offsetHeight,document.body.scrollHeight)];
			}
		}
		Imba.modal=Imba.modal();
