//-----------------全局方法-----------------
			var move = false;
			var mouseLeft = 0;
			var mouseTop = 0;
			function StartDrag(evt, titleW, mainW, contentW){
				if(evt == null)
					evt = window.event;
					
				if((document.all == null && evt.button == 0) || (document.all != null && evt.button == 1)){
					if(document.all)
						titleW.setCapture();
					
					mouseLeft = evt.clientX - mainW.offsetLeft;
					mouseTop = evt.clientY - mainW.offsetTop;
					contentW.style.opacity = "0.5";
					contentW.style.filter = "Alpha(opacity=50)";
					move=true;
				}
			}
			function Drag(evt, titleW, mainW, contentW){
				if(evt == null)
					evt = window.event;
				
				if(move){
					mainW.style.left=evt.clientX - mouseLeft + "px";
					mainW.style.top=evt.clientY - mouseTop + "px";
				}
				
			}
			function StopDrag(evt, titleW, mainW, contentW){
				if(evt == null)
					evt = window.event;
					
				if(document.all)
					titleW.releaseCapture();
				
				contentW.style.opacity = "1";
				contentW.style.filter = "Alpha(opacity=100)";
				move=false;
			}
			
			var currentPopupWin = null;
			function closeCurrentPopup(){
				currentPopupWindow = document.getElementById("popupWin");
				currentPopupWindow.style.display = "none";
				
				if(currentPopupWin != null){
					currentPopupWin.fireEvent("onClose");
					
					if(currentPopupWin.parentObj != null){
						try{
							currentPopupWin.parentObj.focus();
						}catch(e){}
					}
					
					currentPopupWin = null;
				}
			}
			//-----------------全局方法-----------------
			var POPUP_TITLE_ALPHA = 0.8;
			function createWindow(){
				var html = new Array();
		
				html[html.length] = '<div id="popupWin" style="display:none;position:absolute;top:100px;left:100px;overflow:visible;">';
				html[html.length] = '	<table cellspacing="0" cellpadding="0" border="0" width="100%" height="100%" >';
				html[html.length] = '		<tr>';
				html[html.length] = '			<td>';
				html[html.length] = '				<div style="width:8px;height:27px;background:url(../../imgs/window/top_left.gif);filter:Alpha(opacity=' + (POPUP_TITLE_ALPHA*100) + ');-moz-opacity:' + POPUP_TITLE_ALPHA + ';opacity:' + POPUP_TITLE_ALPHA + ';"></div>';
				html[html.length] = '			</td>';
				html[html.length] = '			<td style="width:100%">';
				html[html.length] = '				<div style="height:27px;background-repeat:repeat-x;background:url(../../imgs/window/top_center.gif);filter:Alpha(opacity=' + (POPUP_TITLE_ALPHA*100) + ');-moz-opacity:' + POPUP_TITLE_ALPHA + ';opacity:' + POPUP_TITLE_ALPHA + ';cursor:move" onMousedown="StartDrag(event, this, document.getElementById(\'popupWin\'), document.getElementById(\'popupWinBody\'))" onMouseup="StopDrag(event, this, document.getElementById(\'popupWin\'), document.getElementById(\'popupWinBody\'))" onMousemove="Drag(event, this, document.getElementById(\'popupWin\'), document.getElementById(\'popupWinBody\'))">';
				html[html.length] = '					<table width="100%" border="0" cellspacing="0" cellpadding="0" style="font-size:12px">';
				html[html.length] = '						<tr>';
				html[html.length] = '							<td align="left" style="width:20px"><img style="height:16px;width:16px" id="popupWinTitleIcon" style="margin-top:4px" src=""></td>';
				html[html.length] = '							<td align="left" width="80%"><div id="popupWinTitleText" style="margin-top:6px;overflow:hidden" nowrap="nowrap"></div></td>';
				html[html.length] = '							<td align="right"><a href="javascript:closeCurrentPopup()"><img border="0" style="margin-top:1px" src="../../imgs/window/close.gif"></a></td>';
				html[html.length] = '						</tr>';
				html[html.length] = '					</table>';
				html[html.length] = '				</div>';
				html[html.length] = '			</td>';
				html[html.length] = '			<td >';
				html[html.length] = '				<div style="width:8px;height:27px;background:url(../../imgs/window/top_right.gif);filter:Alpha(opacity=' + (POPUP_TITLE_ALPHA*100) + ');-moz-opacity:' + POPUP_TITLE_ALPHA + ';opacity:' + POPUP_TITLE_ALPHA + ';"></div>';
				html[html.length] = '			</td>';
				html[html.length] = '		</tr>';
				html[html.length] = '		<tr>';
				html[html.length] = '			<td style="height:100%;background-repeat:repeat-y;background:url(../../imgs/window/middle_left.gif);filter:Alpha(opacity=' + (POPUP_TITLE_ALPHA*100) + ');-moz-opacity:' + POPUP_TITLE_ALPHA + ';opacity:' + POPUP_TITLE_ALPHA + ';">';
				html[html.length] = '			</td>';
				html[html.length] = '			<td>';
				html[html.length] = '				<div id="popupWinBody" style="width:100%;height:100%">';
				html[html.length] = '					<div id="popupWinToolbar" style="height:24px;background:white;width:100%;font-size:12px">';
				html[html.length] = '					</div>';
				html[html.length] = '					<div id="popupWinContent" style="background:white;width:100%;font-size:12px;overflow:hidden">';
				html[html.length] = '					</div>';
				html[html.length] = '					<div id="popupWinStatusbar" style="height:14px !important;height:16px;padding-top:2px;background:white;width:100%;font-size:12px">';
				html[html.length] = '					</div>';
				html[html.length] = '				</div>';
				html[html.length] = '			</td>';
				html[html.length] = '			<td style="background-repeat:repeat-y;background:url(../../imgs/window/middle_right.gif);filter:Alpha(opacity=' + (POPUP_TITLE_ALPHA*100) + ');-moz-opacity:' + POPUP_TITLE_ALPHA + ';opacity:' + POPUP_TITLE_ALPHA + ';">';
				html[html.length] = '			</td>';
				html[html.length] = '		</tr>';
				
				html[html.length] = '		<tr>';
				html[html.length] = '			<td style="height:8px;background:url(../../imgs/window/bottom_left.gif);filter:Alpha(opacity=' + (POPUP_TITLE_ALPHA*100) + ');-moz-opacity:' + POPUP_TITLE_ALPHA + ';opacity:' + POPUP_TITLE_ALPHA + ';"></td>';
				html[html.length] = '			<td style="background-repeat:repeat-x;background:url(../../imgs/window/bottom_center.gif);filter:Alpha(opacity=' + (POPUP_TITLE_ALPHA*100) + ');-moz-opacity:' + POPUP_TITLE_ALPHA + ';opacity:' + POPUP_TITLE_ALPHA + ';"></td>';
				html[html.length] = '			<td style="background:url(../../imgs/window/bottom_right.gif);filter:Alpha(opacity=' + (POPUP_TITLE_ALPHA*100) + ');-moz-opacity:' + POPUP_TITLE_ALPHA + ';opacity:' + POPUP_TITLE_ALPHA + ';"></td>';
				html[html.length] = '		</tr>';
				html[html.length] = '	</table>';
				html[html.length] = '</div>';
				
				document.write(html.join(''));
			}
			
			createWindow();
			
			
			function ZtWindow(parentObj, titleIcon, title, content, toolbar, statusbar, width, height){
				this.parentObj = parentObj != null?parentObj : null;
				this.titleIcon = titleIcon != null?titleIcon : "../../imgs/attribute.gif";
				this.title = title != null?title : "";
				this.toolbar = toolbar != null?toolbar : "";
				this.content = content != null?content : "";
				this.statusbar = statusbar != null?statusbar : '<font color="red">"esc"</font> <font color="blue">Close Window</font>,<font color="red">"ctrl+enter"</font> <font color="blue">Submit</font>';
				this.width = isNaN(width)?null:width;
				this.height = isNaN(height)?null:heigth;
				this.maxHeight = 400;
				
				this.events = new Array();
				
				/**
				 * event handling, supported events: onPopup,onClose
				 */ 
				this.attachEvent = function(eventType, eventFunc){
					this.events[this.events.length] = [eventType, eventFunc];
				}
		
				/* 触发事件 */
				this.fireEvent = function(eventType){
					if(eventType == null)
						return;
						
					for(var n=0;n<this.events.length;n++){
						if(this.events[n][0] == eventType){
							if(typeof(this.events[n][1]) == "string")
								eval(this.events[n][1]);
							else
								this.events[n][1](this);
						}
					}
				}
				
				this.popup = function(parentObj){
					if(parentObj != null)
						this.parentObj = parentObj;
					this.initPopupWin();
					
					currentPopupWin = this;
				}
				
				this.isShown = function(){
					return true;
				}
				
				this.initPopupWin = function(){
					var popupWin = document.getElementById("popupWin");
					var popupWinContent = document.getElementById("popupWinContent");
					var popupWinToolbar = document.getElementById("popupWinToolbar");
					var popupWinStatusbar = document.getElementById("popupWinStatusbar");
					
					if(this.width > 20)
						popupWin.style.width = this.width;
					
					if(this.height > 20)
						popupWin.style.height = this.height;
					
					popupWin.style.overflowY = "hidden";
					
					if(this.content.indexOf("<iframe")<0)
						popupWinContent.style.overflowY = "scroll";
					
					document.getElementById("popupWinTitleIcon").src = this.titleIcon;
					document.getElementById("popupWinTitleText").innerHTML = this.title;
					
					
					popupWinContent.innerHTML = this.content;
					
					
					if(this.toolbar != null && this.toolbar.length > 0){
						popupWinToolbar.innerHTML = this.toolbar;
						popupWinToolbar.style.display = "";
					}
					else{
						popupWinToolbar.style.display = "none";
					}
					if(this.statusbar != null && this.statusbar.length > 0){
						popupWinStatusbar.innerHTML = this.statusbar;
						popupWinStatusbar.style.display = "";
					}
					else{
						popupWinStatusbar.style.display = "none";
					}
					
					popupWin.style.display = "";
					
					var position = null;
					
					if(this.parentObj != null){
						
						position = getRelativePosition(this.parentObj, popupWin);
					}
					else{
						position = getWindowCenterPosition();
						
						position["x"] -= popupWin.offsetWidth/2;
						position["y"] -= popupWin.offsetHeight/2;
					}
					
					popupWin.style.left = position["x"] + "px";
					popupWin.style.top = position["y"] + "px";
					
					this.cacaulateWindowHeight();
					
					//this.cacaulateWindowWidth();
				}
				
				this.cacaulateWindowHeight = function(){
					popupWin.style.height = "";
					popupWinContent.style.height = "";
					if(popupWin.offsetHeight > this.maxHeight)
						popupWin.style.height = this.maxHeight+"px";
					popupWinContent.style.height = popupWin.offsetHeight - 27 - 8 - 
						(this.toolbar!=null&&this.toolbar.length>0?24:0) - (this.statusbar!=null&&this.statusbar.length>0?16:0);
				}
				
				this.cacaulateWindowWidth = function(){
					popupWin.style.width = "";
					popupWinContent.style.width = "";
					if(popupWin.offsetWidth > 400)
						popupWin.style.width = "400px";
						
					popupWinContent.style.width = (popupWin.offsetWidth - 8*2) + "px";
				};
				
				this.reinit = function(){
					this.cacaulateWindowHeight();
				};
				
				this.setMaxHeight=function(height){
					if(height){
						this.maxHeight = height;
					}
				};
				
				
			}
			
			function PopupWindow(title, content){
				this.title = title;
				this.content = content;
				if(document.all)
					this.width = 260;
			}
			
			PopupWindow.prototype = new ZtWindow();
			PopupWindow.prototype.constructor = PopupWindow;
			
			//--------------------------Event handling-----------------------------
			function capturePopupCloseHotkey(e){
				var evt = window.event?window.event:e;
				
				//esc
				if(evt.keyCode == 27){
					closeCurrentPopup();
				}
			}
			
			function capturePopupSubmitHotkey(e){
				var evt = window.event?window.event:e;
				
				if(evt.ctrlKey && evt.keyCode==13){
					if(currentPopupWin != null)
						currentPopupWin.fireEvent("onSubmit");
				}
			}
			
			addEvent(document.getElementById("popupWin"), "keyup", capturePopupCloseHotkey);
			addEvent(document.getElementById("popupWin"), "keyup", capturePopupSubmitHotkey);
			