if(!aiviki.ui)
	{
	aiviki.ui = aiviki.Class.create("aiviki.ui");
	}

aiviki.ui.window = aiviki.Class.create("aiviki.ui.window");
aiviki.ui.window.prototype = 
	{
	init:function(name)
		{
		this.UIID=aiviki.util.getSN(this);

		},
	UIID:null,
	windowObj:null,
	th:null,
	listener:null,
	WINDOWSTYLE:'avkWindow',
	width:"0px",
	height:"0px",
	x:0,
	y:0,
	opacity:1,
	visible:true,
	tempData:null,
	isCenter:false,
	isEffects:false,
	setEffects:function(a)
		{
			this.isEffects=a;
		},
	close:function()
		{

			this.visible=true;
			this.setVisible(false);
		},
	_close:function(){},
	setVisible:function(a)
		{
		if(a==this.visible)return;

		if(a==true)
			{
			this.visible=true;
			}else{
			this.visible=false;
			}
		if(this.windowObj==null)return;
		if(!this.visible)
			{
			if(!this.isEffects)
				{

				this.windowObj.style.visibility="hidden";

				}else{
				var f = new aiviki.effects.fade(this.windowObj,this.opacity*100,0);
				f.setEndFunction(aiviki.bind(function(){
					this.windowObj.style.visibility="hidden";
					this.windowObj.parentNode.removeChild(this.windowObj);
					this._close();
					},this));
				f.start();
				}
			}else{
			this.windowObj.style.visibility="visible";

			if(this.isEffects)
				{
				if(isIE)
					{
					this.windowObj.style.filter="alpha(opacity=0)";
					}else{
					this.windowObj.style.opacity=0;					
					}

					var f = new aiviki.effects.fade(this.windowObj,0,this.opacity*100);
					f.start();
				}else{
				if(isIE)
					{
					this.windowObj.style.filter="alpha(opacity="+this.opacity*100+")";
					}else{
					this.windowObj.style.opacity=this.opacity;					
					}
				}
			}



		},
	setClassName:function(s)
		{
		this.WINDOWSTYLE=s;
		if(this.windowObj!=null)
			this.WINDOWSTYLE.className=this.WINDOWSTYLE;
		},
	setContent:function(a)
		{
			if(this.windowObj!=null)
				{
					this.windowObj.innerHTML=a;
				}else{
					this.tempData=a;
				}
		},
	setOpacity:function(a)
		{
			this.opacity=a;
		},
	getOpactiry:function()
		{
			return this.opacity;
		},
	setX:function(p)
		{
			this.x=p;
		if(this.windowObj==null)
			return;
			this.windowObj.style.left=this.x+"px";			
		},
	setY:function(p)
		{
			this.y=p;
		if(this.windowObj==null)
			return;
			this.windowObj.style.top=this.y+"px";			
		},
	setLocation:function(a,b)
		{
			this.x=a;
			this.y=b;
		if(this.windowObj==null)
			return;
			this.windowObj.style.left=this.x+"px";			
			this.windowObj.style.top=this.y+"px";			
		},
	getX:function()
		{
		return this.x;	
		},
	getY:function()
		{
		return this.y;	
		},		
	setWidth:function(w)
		{
		this.width=w;
		if(this.windowObj==null)
			return;
			this.windowObj.style.width=this.width;
		
		},
	setHeight:function(h)
		{
		this.height=h;
		if(this.windowObj==null)
			return;
			this.windowObj.style.height=this.height;
		},
	center:function()
		{
		this.isCenter=true;
		if(this.windowObj==null)
			return;
		var ps = aiviki.util.getPgsize();
		var xx=(ps[0]-this.windowObj.offsetWidth)/2;
		var yy=(ps[1]-this.windowObj.offsetHeight)/2;
		this.setLocation(xx,yy);
		},
	render:function()
		{
		return this.tempData;

		},
	destory:function()
		{
			this.close();
			document.body.removeChild(this.windowObj);
		},
	show:function()
		{
		if(this.windowObj==null)
			{
			var entity = document.createElement("div");
		//	aiviki.event.addEventByObj(this.UIID,mo,"mouseout",this.mouseout,this);
			entity.name=this.UIID;
			entity.className=this.WINDOWSTYLE;
			entity.style.position="absolute";			
			entity.flag=this.UIID;
			entity.style.height=this.height;	
			entity.style.width=this.width;
			entity.style.left=this.x+"px";
			entity.style.top=this.y+"px";
			entity.appendChild(document.createTextNode("CCC"));
				entity.style.visibility='hidden';
			entity.innerHTML=this.render();
			document.body.appendChild(entity);
			this.windowObj=entity;
			if(this.isCenter)
				this.center();

			if(this.visible)
				{
				this.visible=false;
				this.setVisible(true);
				}

//			var  f = new aiviki.effects.fade(this.windowObj,100);
	//		this.setOpacity(0);
//			f.start();
			}
		}

	}

