﻿var JTFrame=function(panel){
	this.panel=panel;
	this.elapSize=[-1,-1];
	this.size=[-1,-1];
	this.elapLocation=[-1,-1];
	this.location=[-1,-1];
	this.visible=false;
	this.componentListener=null;
	this.isSizeFix=false;
}
JTFrame.COMPONENT_SHOWN=0;
JTFrame.COMPONENT_HIDDEN=1;
JTFrame.prototype.setSizeFix=function(b){
	this.isSizeFix=!!b;
}
JTFrame.prototype.addComponentListener=function(l){
	if(typeof l != "function")
		return;
	this.componentListener=l;	
}
JTFrame.prototype.getLocation=function(){
	if(this.location[0]==-1){
		this.location=YAHOO.util.Dom.getXY(this.panel);
	}
	return this.location;	
}
JTFrame.prototype.setLocation=function(x,y){
	this.elapLocation=this.location;
	this.location=[x,y];
	this.panel.style.left=x+"px";
	this.panel.style.top=y+"px";
}
JTFrame.prototype.getElapseLocation=function(){
	if(this.elapLocation[0]==-1)
		return null;
	return this.elapLocation;	
}
JTFrame.prototype.getSize=function(){
	if(this.size[0]==-1)
		this.size=[this.panel.offsetWidth,this.panel.offsetHeight];
	return this.size;	
}
JTFrame.prototype.getElapseSize=function(){
	if(this.elapSize[0]==-1)
		return null;
	return this.elapSize;	
}
JTFrame.prototype.setSize=function(w,h){
	if(this.isSizeFix)
		return;	
	this.elapSize=this.size;
	this.size=[w,h];
	this.panel.style.width=w+"px";
	this.panel.style.height=h+"px";	
}
JTFrame.prototype.isVisible=function(){
	return this.visible;
}
JTFrame.prototype.setVisible=function(b){
	if(b){
		this.panel.style.visibility="visible";
		this.visible=true;
	}else{
		this.panel.style.visibility="hidden";
		this.visible=false;
	}	
	if(this.componentListener!=null)
		this.componentListener(this.visible?JTFrame.COMPONENT_SHOWN:JTFrame.COMPONENT_HIDDEN);	
}

















