﻿/**
 *客户端操作javascript包装类（跨浏览器支持）
 *@Auther Zhan Song
 *@Date 2007.07.02
 *@Version 1.0
 * SongSoft.Client.Dom
 * SongSoft.Client.Rect
 * SongSoft.Client.Point
 * SongSoft.Client.Event
 * SongSoft.Client.Listener
 */ 
 
/**
 *定义DHTML对象操作类
 */
if( !SongSoft.Client.Dom )
{
	SongSoft.Client.Dom = 
	{
		isSafari: (navigator.userAgent.match(/safari/gi)),
		isIE: (!this.isSafari && navigator.userAgent.match(/msie/gi)),
		/**
		 *根据指定的ID获取HTMLElement
		 *@param ele {String | HTMLElement}
		 *@return {HTMLElement}
		 */
		$ : function(ele)
		{
			if( typeof(ele) == 'string' )
			{
				ele = document.getElementById(ele);
			}
			return ele;
		},
		cloneNode : function(ele,includeChild,idPrefix)
		{
			ele = this.$(ele);
			if( ele == null )
				return null;
			var clonedNd = ele.cloneNode(includeChild);			
			this.modifyID(clonedNd,idPrefix,includeChild);
			return clonedNd;
		},
		modifyID : function(ele,idPrefix,includeChild)
		{
			ele = this.$(ele);
			if( ele == null || ele.nodeName == '#text' )
				return;
				
			var id = idPrefix+'_';
			if( ele.id )
				ele.id = id + ele.id;
			if( includeChild )
			{
				for(var i=0;i<ele.childNodes.length;i++)
					this.modifyID(ele.childNodes[i],idPrefix,includeChild);
			}
		},
		/**
		 *获取指定对象的边框
		 *@param ele {String | HTMLElement}
		 *@return {SongSoft.Client.Rect} 以对象的左上角 右下角围成的矩形框
		 */
		getBound : function(ele)
		{
			ele = this.$(ele);
 		    var pos = this.getXY(ele);
			var t = pos.y;
		    var l = pos.x;
			var b = pos.y + ele.offsetHeight;
			var r = pos.x + ele.offsetWidth;		
			return new SongSoft.Client.Rect(t, l, b, r);
	
		},
		/**
		 *获取指定对象的指定属性值
		 *@param el {String | HTMLElement} 要获取属性值的对象
		 *@param property {String} 要获取值的属性名称
		 *return {String}
		 */
		getProperty : function(el,property)
		{
			  var value = null;
			  var dv = document.defaultView;
		
			  el = this.$(el);
		
			  if (property == 'opacity' && el.filters) 
			  {// IE opacity
				 value = 1;
				 try 
				 {
					value = el.filters.item('DXImageTransform.Microsoft.Alpha').opacity / 100;
				 } 
				 catch(e) 
				 {
					try 
					{
					  value = el.filters.item('alpha').opacity / 100;
					} 
					catch(e) 
					{}
				 }
			  }
			  else if (el.style[property]) 
			  {
				 value = el.style[property];
			  }
			  else if (el.currentStyle && el.currentStyle[property]) 
			  {
				 value = el.currentStyle[property];
			  }
			  else if ( dv && dv.getComputedStyle )
			  {		
				 var converted = '';
				 for(i = 0, len = property.length;i < len; ++i) 
				 {
					if (property.charAt(i) == property.charAt(i).toUpperCase()) 
					{
					   converted = converted + '-' + property.charAt(i).toLowerCase();
					}
					else 
					{
					   converted = converted + property.charAt(i);
					}
				 }
		
				 if (dv.getComputedStyle(el, '').getPropertyValue(converted)) 
				 {
					value = dv.getComputedStyle(el, '').getPropertyValue(converted);
				 }
			  }	
			  return value;
		},
		/**
		 *设置指定对象的指定属性的值
		 *@param el {String | HTMLElement}
		 *@param property {String}
		 *@param val {String}
		 */
		setProperty : function(el,property,val)
		{
			el = this.$(el);
			switch(property) 
			{
			 case 'opacity' :
				if (SongSoft.Client.Dom.isIE) {
				   el.style.filter = 'alpha(opacity=' + val * 100 + ')';
	
				   if (el.currentStyle && !el.currentStyle.hasLayout) {
					  el.style.zoom = 1;
				   }
				} else {
				   el.style.opacity = val;
				   el.style['-moz-opacity'] = val;
				   el.style['-khtml-opacity'] = val;
				}
				break;
			 default :
				el.style[property] = val;
			}
		},
		/**
		 *获取当前浏览器可见窗口的宽度
		 *@return {Int}
		 */
	   getClientWidth : function()
	   {
		  return (
			 document.documentElement.offsetWidth
			 || document.body.offsetWidth
		  );
	   },
	   /**
	    *获取当前浏览器可见窗口的高度
		*@return {Int}
		*/
	   getClientHeight : function() 
	   {
		  return (
			 self.innerHeight
			 || document.documentElement.clientHeight
			 || document.body.clientHeight
		  )
	   },
	   /**
		 *获取当前浏览器窗口的宽度
		 *@return {Int}
		 */
	   getWindowWidth : function()
	   {
		  return (document.body.scrollWidth || document.documentElement.scrollWidth );
	   },
	   /**
	    *获取当前浏览器窗口的高度
		*@return {Int}
		*/
	   getWindowHeight : function() 
	   {
		  return ( document.body.scrollHeight || document.documentElement.scrollHeight );
	   },
	   getScrollLeft : function()
	   {
		 var docEle = document.documentElement;
		 docBody = document.body;
		 if( docEle && docEle.scrollLeft )
		 {
			 return docEle.scrollLeft;
		 }
		 else if( docBody )
		 {
			 return docBody.scrollLeft;
		 }
		 else
		 {
			 return 0;
		 }
	   },
	   getScrollTop : function()
	   {
		 var docEle = document.documentElement;
		 docBody = document.body;
		 if( docEle && docEle.scrollTop )
		 {
			 return docEle.scrollTop;
		 }
		 else if( docBody )
		 {
			 return docBody.scrollTop;
		 }
		 else
		 {
			 return 0;
		 }
	   },
	   /**
	    *获取指定对象的位置(左上角位置)
		*@param el {String | HTMLElement}
		*@return [Boolean | SongSoft.Client.Point] 当元素没有加入document中或者不可见时返回false，否则返回指定对象的左上角坐标位置
		*/
	   getXY : function(el) 
	   {
		  el = this.$(el);	
		  if (  el.parentNode == null || this.getProperty(el, 'display') == 'none') 
		  {
			 return false;
		  }

		  var parent = null;		
		  var box;
		  var pos = null;
	
		  if (el.getBoundingClientRect) 
		  { // IE
			 box = el.getBoundingClientRect();
			 var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
			 var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
			
			 return new SongSoft.Client.Point(box.left + scrollLeft, box.top + scrollTop);
		  }		  
		  else if (document.getBoxObjectFor) 
		  { // gecko
			 box = document.getBoxObjectFor(el);
			 var borderLeft = (el.style.borderLeftWidth)?parseInt(el.style.borderLeftWidth):0;         
			 var borderTop = (el.style.borderTopWidth)?parseInt(el.style.borderTopWidth):0; 
			 pos = new SongSoft.Client.Point(box.x-borderLeft, box.y-borderTop);	
		  }		  
		  else 
		  { // safari/opera
		  
			 pos = new SongSoft.Client.Point(el.offsetLeft, el.offsetTop);
			 parent = el.offsetParent;
		
			 if (parent != el) 
			 {
				while (parent) 
				{
				   pos.x += parent.offsetLeft;
				   pos.y += parent.offsetTop;
				   parent = parent.offsetParent;
				  
				}
			 }
	
			 // opera & (safari absolute) incorrectly account for body offsetTop
			 var ua = navigator.userAgent.toLowerCase();
			 if (ua.indexOf('opera') != -1 || ( ua.indexOf('safari') != -1 && this.getProperty(el, 'position') == 'absolute' ) ) 
			 {
				 pos.x -= document.body.offsetLeft;
				pos.y -= document.body.offsetTop;
			 }			
		  }	
	
		  if (el.parentNode) 
		  { 
		  	parent = el.parentNode; 
		  }
		  else 
		  { 
		  	parent = null; 
		  }	
		  while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML') 
		  {
			 pos.x -= parent.scrollLeft;
			 pos.y -= parent.scrollTop;			
			 if (parent.parentNode) 
			 { 
			 	parent = parent.parentNode; 
			 }
			 else 
			 { 
			 	parent = null; 
			 }
		  }	
		
		  return pos;
	   },
	   /**
	    *设置指定元素的位置
		*@param el [String | HTMLElement] 要设定位置的元素ID或者元素对象
		*@param pos {SongSoft.Client.Point} 要设置的新位置坐标
		*@param noRetry {Boolean} 是否跳过验证设置结果
		*@return {Boolean}是否成功设置位置
		*/
		setXY : function(el, pos, noRetry) 
		{
		  el = this.$(el);
		  var pageXY = this.getXY(el);
		  if (pageXY === false) 
		  {//当前元素不在Document文档中或者不可见 
			 return false; 
		  }		
		  var top = this.getProperty(el,'top');
		  var left = this.getProperty(el,'left');
		  if( isNaN(left) )
			left = 0;
		  if( isNaN(top) )
			top = 0;
	
		  if (pos.x != -1 ) 
		  { 
		  	el.style.left = pos.x - pageXY.x + left + 'px'; 
		  }
		  if (pos.y != -1 ) 
		  { 
		    el.style.top = pos.y - pageXY.y + top + 'px'; 
		  }	
		  var newXY = this.getXY(el);

		  // if retry is true, try one more time if we miss
		  if (!noRetry && (newXY.x != pos.x || newXY.y != pos.y) ) 
		  {
			 this.setXY(el, pos, true);
		  }
	
		  return true;
		}
	};
};

/**
 *表示一个矩形区域
 *@return {SongSoft.Client.Rect}
 */
SongSoft.Client.Rect = function(t,l,b,r)
{
	this.top = t;
	this.left = l;
	this.bottom = b;
	this.right = r;
}
SongSoft.Client.Rect.prototype = 
{
	/**
	 *判断当前矩形区域是否包含指定的区域
	 *@param rect {SongSoft.Client.Rect} 
	 *@return {Boolean}
	 */
	contains : function(rect)
	{
	  return ( rect.left   >= this.left   &&
		 rect.right  <= this.right  &&
		 rect.top    >= this.top    &&
		 rect.bottom <= this.bottom    );
	},
	
	/**
	 *获取当前矩形区域和指定的区域的交集
	 *@return {SongSoft.Client.Rect} 两个区域的交集，如果没有交集返回null
	 */
	intersect : function(rect)
	{
		var t = Math.max( this.top,    rect.top    );
		var l = Math.max( this.left,   rect.left   );
		var b = Math.min( this.bottom, rect.bottom );
		var r = Math.min( this.right,  rect.right  );	
		if (b >= t && r >= l) 
		{
			return new SongSoft.Client.Rect(t,l, b, r);
		} 
		else 
		{
			return null;
		}
	},
	union : function(rect)
	{
		 var t = Math.min( this.top,    region.top    );
		var r = Math.max( this.right,  region.right  );
		var b = Math.max( this.bottom, region.bottom );
		var l = Math.min( this.left,   region.left   );
	
		return new YAHOO.util.Region(t, l, b, r);

	},
	getArea : function()
	{
		return ( (this.bottom - this.top) * (this.right - this.left) );
	},
	toString : function()
	{
		return "(left:"+this.left+",top:"+this.top+");(right:"+this.right+",bottom:"+this.bottom+")";
	}
};
/**
 *表示一个坐标点，派生自SongSoft.Client.Rect
 *@param x {Int} 坐标点的x坐标值
 *@param y {Int} 坐标点的y坐标值
 */
SongSoft.Client.Point = function(x,y)
{
	this.x = x;
	this.y = y;
	this.top = y;
	this.left = x;	
	this.bottom = y;
	this.right = x;
}
SongSoft.Client.Point.prototype = new SongSoft.Client.Rect();

/**
 *定义事件监听对象
 */
if( !SongSoft.Client.Listener )
{
	SongSoft.Client.Listener = function(ele,eType,callback,args,argAsSender)
	{
		this.element = ele;
		this.eventType = eType;
		this.callback = callback;
		this.arguments = args;
		this.argAsSender = argAsSender;
		this.wrappedCallback = null;
	}
};

/**
 *定义客户端事件类
 *该类可以处理延时事件过接（当对象没有创建的时候已经可以声明对其事件的挂接）
 */
if( !SongSoft.Client.Event )
{
	SongSoft.Client.Event = 
	{
		isWindowLoaded : false,
		delayedListeners : [],
		unloadListeners : [],
		listeners : [],
		/**
		 *向指定对象加入一个事件处理器
		 *@param ele {String | HTMLElement} 要进行事件监听的对象
		 *@param eType {String} 要监听的事件类型如：click mousemove等
		 *@param callback {Function} 事件处理函数
		 *@param args {Object} 要传递给事件处理函数的参数(通过arguments[1]对象获取)
		 *@param argAsSender {Boolean} 是否将args对象作为事件处理函数的this对象
		 */
		addListener : function(ele,eType,callback,args,argAsSender)
		{
	    	var listener = new SongSoft.Client.Listener(ele,eType,callback,args,argAsSender);
			return this.addListener2(listener);
		},
		/**
		 *根据指定的监听器对象进行事件监听挂接
		 *@param listener {SongSoft.Client.Listener} 监听器对象
		 */
		addListener2 : function(listener)
		{
			if( typeof(listener.element) == 'string' )
			{//当前传递的Element是一个ID名称
				if( !this.isWindowLoaded )
				{//当前Document尚未加载完毕
					this.delayedListeners[this.delayedListeners.length] = listener;
					return true;
				}
				else
				{
					listener.element = SongSoft.Client.Dom.$(listener.element);
				}
			}
			if( !listener.element )
				return false;
			if( listener.eventType == "unload")
			{//当前要挂接的是unload事件
				this.unloadListeners[this.unloadListeners.length] = listener;
				return true;
			}	
			var sender = listener.argAsSender ? listener.arguments : listener.element;
			var wrappedFn = function(e)
			{
				return listener.callback.call(sender,SongSoft.Client.Event.getEvent(e),listener.arguments);
			};
			listener.wrappedCallback = wrappedFn;
			this.listeners[this.listeners.length] = listener;
			if( listener.element.addEventListener )
			{
				listener.element.addEventListener(listener.eventType,wrappedFn,false);
			}
			else if ( listener.element.attachEvent )
			{
				listener.element.attachEvent("on"+listener.eventType,wrappedFn);
			}
			return true;
		},
		removeListener : function(ele,eType,callback)
		{
			ele = SongSoft.Client.Dom.$(ele);
			var listener = null;
			var index = -1;
			for(var i=0;i<this.listeners.length;i++)
			{
				var l = this.listeners[i];
				if(!l) continue;
				if( l.element == ele && l.callback == callback && l.eventType == eType )
				{
					index = i;
					listener = l;
					break;
				}
			}
			if( ele == false || listener == null )
			{
				return false;
			}
			if (ele.removeEventListener) 
			{
				ele.removeEventListener(eType, listener.wrappedCallback, false);	
			}
			else if (ele.detachEvent) 
			{
				ele.detachEvent("on" + eType, listener.wrappedCallback);
			}	
			delete listener.wrappedCallback;
			delete listener.callback;
			delete listener;
			delete this.listeners[index];
	
			return true;
		},
		preventDefault : function(e)
		{
			 if( e.preventDefault )
			 	e.preventDefault();
			 else
			 	e.returnValue = false;
		},
		stopEvent : function(e)
		{
			 this.stopPropagation(e);
			 this.preventDefault(e);
		},
		stopPropagation : function(e)
		{
			if( e.stopPropagation )
			 	e.stopPropagation();
		    else
		 	  	e.cancelBubble = true;
		},
		getPageX : function(e)
		{
			 var x= e.pageX;
			 if( !x && x != 0 )
			 {
				 x = e.clientX || 0;
				 if( SongSoft.Client.Dom.isIE )
					x += SongSoft.Client.Dom.getScrollLeft();
			 }
			 return x;
		},
		getPageY : function(e)
		{
			var y= e.pageY;
			if( !y && y != 0 )
			{
			   y = e.clientY || 0;
			   if( SongSoft.Client.Dom.isIE )
				 y += SongSoft.Client.Dom.getScrollTop();
			}
			return y;
		},
		init : function()
		{
			this.isWindowLoaded = true;
		},
		dispose : function()
		{
			//当前的事件对象
		  	for (var i=0; i < this.unloadListeners.length; i++) 
			{//执行所有挂接的unload的事件
				var listener = this.unloadListeners[i];
				if (listener) 
				{
					var sender = listener.argAsSender ? listener.args: window;
					listener.callback.call(sender,this.getEvent(), listener.args );
				}
			}
			if ( this.listeners && this.listeners.length > 0) 
			{//卸载所有事件监听
				for (i = 0; i < this.listeners.length; i++) 
				{
					listener = this.listeners[i];
					if (listener) 
					{
						this.removeListener(listener.element,listener.eventType,listener.callback);
					}
				}				
			}		
		},
		/**
		 *获取执行当前方法调用的event对象
		 *@param e {event} 如果e为空将从方法调用的上下文堆栈中获取
		 *return {event}
		 */
		 getEvent : function(e) 
		 {
			var ev = e || window.event;
	
			if (!ev)
			{
				var c = this.getEvent.caller;
				while (c) 
				{
					ev = c.arguments[0];
					if (ev && Event == ev.constructor)
					{
						break;
					}
					c = c.caller;
				}
			}	
			return ev;
		 },
		attachListeners : function()
		{
			if (!this.isWindowLoaded) 
			{//如果当前文档尚未加载完成定时重试
				setTimeout("SongSoft.Client.Event.attachListeners()", 50);
			}
			else
			{	
				for (var i=0; i < this.delayedListeners.length; i++) 
				{
					var listener = this.delayedListeners[i];
					if (listener) 
					{				
						var ele = SongSoft.Client.Dom.$(listener.element);
						if (ele) 
						{					
							this.addListener(ele,listener.eventType, listener.callback,listener.arguments,listener.argAsSender);
							delete this.delayedListeners[i];
						}
					}
				}	
			}
		}
	};
	if (document && document.body) 
	{
        SongSoft.Client.Event.init();
	}
	else 
	{
		SongSoft.Client.Event.addListener(window, "load", SongSoft.Client.Event.init,SongSoft.Client.Event, true);
    }
   	SongSoft.Client.Event.addListener(window, "unload", SongSoft.Client.Event.dispose,SongSoft.Client.Event,true);

    SongSoft.Client.Event.attachListeners();
};
/**
 *定义模态弹出窗体
 */
if( !SongSoft.Client.Window )
{
	SongSoft.Client.Window = 
	{
		windows : [],
		zIndex : 2000,
		frame : null,
		showDlg : function(contentEle)
		{
			contentEle = SongSoft.Client.Dom.$(contentEle);
			if( !contentEle )
				return;
			if( !this.frame )
			{
				var frame = document.createElement('iframe');					
				frame.frameBorder = 'no';				
				SongSoft.Client.Dom.setProperty(frame,'zIndex',1000);		
				SongSoft.Client.Dom.setProperty(frame,'position','absolute');
				SongSoft.Client.Dom.setProperty(frame,'top','0px');
				SongSoft.Client.Dom.setProperty(frame,'left','0px');											
			    SongSoft.Client.Dom.setProperty(frame,'width','100%');
				SongSoft.Client.Dom.setProperty(frame,'height','100%');
				SongSoft.Client.Dom.setProperty(frame,'backgroundColor','#FFFFFF');
				SongSoft.Client.Dom.setProperty(frame,'opacity','0.5');
				
				if(  contentEle.parentNode != null )
			        contentEle.parentNode.appendChild(frame);   
			    else
                    document.body.appendChild(frame);
				this.frame = frame;
				
			}
			var w = SongSoft.Client.Dom.getWindowWidth();
			var h = SongSoft.Client.Dom.getWindowHeight();
			
			var clientW=SongSoft.Client.Dom.getClientWidth();
			var clientH=SongSoft.Client.Dom.getClientHeight();
			
			var scrollTop=SongSoft.Client.Dom.getScrollTop();
			var scrollLeft=SongSoft.Client.Dom.getScrollLeft();
			
			SongSoft.Client.Dom.setProperty(this.frame,'display','block');
			
		
			SongSoft.Client.Dom.setProperty(this.frame,'width',w+'px');
			SongSoft.Client.Dom.setProperty(this.frame,'height',h+'px');

				
			var win = this.findWindow(contentEle);
			if( win )
			{
				if( win.zIndex != this.zIndex )
					this.zIndex++;
				win.zIndex = this.zIndex;
				SongSoft.Client.Dom.setProperty(win.element,'zIndex',this.zIndex);
			}
			else
			{
				this.zIndex++;
				win = {};
				win.zIndex = this.zIndex;
				win.element = contentEle;
				SongSoft.Client.Dom.setProperty(contentEle,'display','block');
				SongSoft.Client.Dom.setProperty(contentEle,'zIndex',this.zIndex);		
				SongSoft.Client.Dom.setProperty(contentEle,'position','absolute');
				
				var width = SongSoft.Client.Dom.getProperty(contentEle,'width');
				var height = SongSoft.Client.Dom.getProperty(contentEle,'height');
				height = (isNaN(parseInt(height)) ? 0 : parseInt(height));
				width = (isNaN(parseInt(width)) ? 0 : parseInt(width));
				SongSoft.Client.Dom.setProperty(contentEle,'top',(clientH-height)/2+scrollTop + 'px');
				SongSoft.Client.Dom.setProperty(contentEle,'left',(clientW - width)/2 + scrollLeft+'px');
				if( SongSoft.Client.DragAbleElement )
					new SongSoft.Client.DragAbleElement(contentEle.id,[]);
				this.windows[this.windows.length] = win;
			}			
			return win;
		},
		findWindow : function(contentEle)
		{
			contentEle = SongSoft.Client.Dom.$(contentEle);
			if( !contentEle )
				return null;
			for(var i=0;i<this.windows.length;i++)
			{
				if( this.windows[i].element == contentEle )
					return this.windows[i];
			}
			return null;
		},
		closeDlg : function(contentEle)
		{
			contentEle = SongSoft.Client.Dom.$(contentEle);
			if( !contentEle )
				return;
			var index = -1;
			for(var i=0;i<this.windows.length;i++)
			{
				if( this.windows[i].element == contentEle )
				{
					index = i;
					break;
				}			
			}
			if( index < 0 )
				return;
			var win = this.windows[index];
			this.windows.splice(index,1);
			if( win.element )
			{			
				SongSoft.Client.Dom.setProperty(win.element,'display','none');
			}
			delete win;
			if( this.windows.length == 0 )
				SongSoft.Client.Dom.setProperty(this.frame,'display','none');
		},
		onResize : function()
		{
			if( !this.frame )
				return;
			var w = SongSoft.Client.Dom.getWindowWidth() + 10;
			var h = SongSoft.Client.Dom.getWindowHeight()+10;
			SongSoft.Client.Dom.setProperty(this.frame,'width',w+'px');
			SongSoft.Client.Dom.setProperty(this.frame,'height',h+'px');

		}
	}
	SongSoft.Client.Event.addListener(window,'resize',SongSoft.Client.Window.onResize,SongSoft.Client.Window,true);
};
/**
 *定义气泡弹出窗体
 */
if( !SongSoft.Client.PopupWindow )
{
	SongSoft.Client.PopupWindow = 
	{
		popups : [],
		zIndex : 999,
		showPopup : function(contentEle,x,y)
		{
			var popup = this.findPopup(contentEle);
			if( popup )
			{
		
				SongSoft.Client.Dom.setProperty(popup.frame,'top',y);
				SongSoft.Client.Dom.setProperty(popup.frame,'left',x);		
				SongSoft.Client.Dom.setProperty(popup.element,'top',y);
				SongSoft.Client.Dom.setProperty(popup.element,'left',x);			
				popup.x = x;			
				popup.y = y;	
				if( popup.zIndex != this.zIndex )
				{
					this.zIndex++;
					popup.zIndex = this.zIndex;
					SongSoft.Client.Dom.setProperty(popup.element,'zIndex',this.zIndex);
				}
			}
			else
			{
				popup = this.createPopup(contentEle,x,y);			
				this.popups[this.popups.length] = popup;
			}	
		},
		createPopup : function(contentEle,x,y)
		{
			this.zIndex++;
			var frame = document.createElement('iframe');	
			SongSoft.Client.Dom.setProperty(frame,'display','block');
			frame.frameBorder = 'no';				
			SongSoft.Client.Dom.setProperty(frame,'zIndex',0);		
			SongSoft.Client.Dom.setProperty(frame,'position','absolute');
			
			 SongSoft.Client.Dom.setProperty(frame,'backgroundColor','#ffffff');		
			 
			contentEle = SongSoft.Client.Dom.$(contentEle);
			if(  contentEle.parentNode != null )
			   contentEle.parentNode.appendChild(frame);   
			else
               document.body.appendChild(frame);
			var w = SongSoft.Client.Dom.getProperty(contentEle,'width');
			var h = SongSoft.Client.Dom.getProperty(contentEle,'height');
			SongSoft.Client.Dom.setProperty(frame,'width',w);
			SongSoft.Client.Dom.setProperty(frame,'height',h);

			
			var e = SongSoft.Client.Event.getEvent();		
			var t = y;
			var l = x;
			SongSoft.Client.Dom.setProperty(frame,'top',t);
			SongSoft.Client.Dom.setProperty(frame,'left',l);
			
			SongSoft.Client.Dom.setProperty(contentEle,'display','block');
			SongSoft.Client.Dom.setProperty(contentEle,'zIndex',this.zIndex);					
			SongSoft.Client.Dom.setProperty(contentEle,'position','absolute');
			SongSoft.Client.Dom.setProperty(contentEle,'top',t);
			SongSoft.Client.Dom.setProperty(contentEle,'left',l);
			var popup = {};
			popup.frame = frame;
			popup.element = contentEle;
			popup.zIndex = this.zIndex;
			popup.x = x;
			popup.y = y;
			return popup;
		},
		findPopup : function(contentEle)
		{		
			contentEle = SongSoft.Client.Dom.$(contentEle);
			if( !contentEle )
				return null;
			for(var i=0;i<this.popups.length;i++)
			{
				if( this.popups[i].element == contentEle )
					return this.popups[i];
			}
			return null;
		},
		hidePopup : function(contentEle)
		{
			contentEle = SongSoft.Client.Dom.$(contentEle);
			if( !contentEle )
				return;
			var index = -1;
			for(var i=0;i<this.popups.length;i++)
			{
				if( this.popups[i].element == contentEle )
				{
					index = i;
					break;
				}			
			}
			if( index < 0 )
				return;
			var popup = this.popups[index];
			this.popups.splice(index,1);
			if( popup.element )
			{			
				SongSoft.Client.Dom.setProperty(popup.element,'display','none');
			}
			if( !popup.frame )
				delete popup;
			else
			{
				document.body.removeChild(popup.frame);
				delete popup.frame;
				delete popup;
			}
			
		}
	}
};


