function TheoFrame(){
	this.title 		= "TheoFrame";
	this.modal		= false;
	this.movable	= false;
	this.closable	= true;
	this.dom		= new Dom();
	this.frame		= document.createElement("div");
	this.menuBar	= document.createElement("div");
	this.closeBar	= document.createElement("div");
	this.titleBar	= document.createElement("div");
	this.content	= document.createElement("div");
	//this.frameB 	= document.createElement("iframe");
	this.visible 	= false;
	
	this.frame.className	= "TheoFrame";
	this.titleBar.className	= "TheoFrameTitleBar";
	this.content.className	= "TheoFrameContent";
	this.closeBar.className	= "TheoFrameCloseBar";
	
	this.closeBar.innerHTML = "&nbsp;"
	
	var menuBar = document.createElement("div");
	menuBar.className = "menuBar";
	menuBar.innerHTML = "&nbsp;"
	
	var titreLab = document.createElement("div");
	titreLab.className = "titreLab";
	titreLab.appendChild(document.createTextNode(this.title));
	
	this.titleBar.appendChild(menuBar);
	this.titleBar.appendChild(titreLab);
	this.titleBar.appendChild(this.closeBar);
	
	
	this.frame.id = "TheoFrame"+new Date().getTime();
	
	this.getId = function(){
		return this.frame.id;	
	}
	
	this.setClassName = function(cl){
		this.frame.className = cl;
		//this.frameB.className = cl;
	}
	
	this.append = function(node){
		this.content.innerHTML += node;
	}
	
	this.appendChild = function(node){
		//alert(node.innerHTML+" "+node.childNodes.length);
		
		this.dom.addChild(this.content,node);
		//this.content.appendChild(node.cloneNode(true));
	}
	
	this.clear = function(){
		this.dom.removeAllChilds(this.content);
	}
	
	this.getFrame = function(){
		return this.content;	
	}
	
	this.close = function(){
		document.body.removeChild(document.getElementById("thedivm"+this.getId()));
		document.body.removeChild(this.frame);
	}
	
	this.display = function(){
		if(!this.visible){
		
			if(this.closable){
				
				this.closeBar.title = "Fermer la fenetre";
				
				
				this.closeBar.onclick = function(){
					//document.body.removeChild(document.getElementById("ifr"+this.parentNode.parentNode.id));
					
					if(document.getElementById("thedivm"+this.parentNode.parentNode.id))
						document.body.removeChild(document.getElementById("thedivm"+this.parentNode.parentNode.id));
					
					document.body.removeChild(document.getElementById(this.parentNode.parentNode.id));
				}
				
				
			}
			                 
			if(this.modal){
				
		        var hautM = document.documentElement.scrollHeight;
				var largM = document.documentElement.scrollWidth;
				thedivm = document.createElement("div");
				thedivm.style.position 	= "absolute";
				thedivm.style.top 		= "0px";
				thedivm.style.left 		= "0px";
				thedivm.style.width 	= largM+"px";
				thedivm.style.height	= hautM+"px";
				//Debug.write(largM+"px "+hautM+"px");
				thedivm.style.zIndex	= "100000";
				thedivm.className = "TheDivModal";
				thedivm.id = "thedivm"+this.frame.id;
				document.body.appendChild(thedivm);
			}
			
			
			
			this.frame.appendChild(this.titleBar);
			this.frame.appendChild(this.content);

			document.body.appendChild(this.frame);
			this.dom.centerElement(this.frame);
			//this.frameB.id = "ifr"+this.frame.id;
			//document.body.appendChild(this.frameB);
			//this.dom.centerElement(this.frameB);
			this.frame.style.zIndex = "100000";
			/*this.frameB.style.zIndex = "10000";
			this.frameB.style.width = (parseInt(this.frame.offsetWidth)-5)+"px";
			this.frameB.style.height = (parseInt(this.frame.offsetHeight)-5)+"px";
			this.frameB.style.top = this.frame.offsetTop+"px";
			this.frameB.style.left = this.frame.offsetLeft+"px";*/
			
			if(this.movable){
				this.titleBar.onmousedown = function(e){
					if (!e) e = window.event
					window.dragger.setObj(this.parentNode,e);	
					window.dragger.startDrag()	;
				}
				
				this.titleBar.onmouseup = function(){
					window.dragger.stopDrag()	;
				}
				this.closeBar.onmousedown = function(e){
					if (!e) e = window.event
					window.dragger.setObj(this.parentNode,e);	
					window.dragger.startDrag()	;
				}
				
				this.closeBar.onmouseup = function(){
					window.dragger.stopDrag()	;
				}
	
				window.dragger = new Dragger();
						
				this.moveFunction = function(e){
					if (!e) {e = window.event}
			
					if(window.dragger.isDragging()){
							window.dragger.move(e);
							/*thefr = document.getElementById("ifr"+window.dragger.getObj().id);
							//thefr.style.position="absolute";
							thefr.style.top = window.dragger.getObj().offsetTop+"px";
							thefr.style.left = window.dragger.getObj().offsetLeft+"px";*/
					}
				}
				if(!document.all)
				document.body.addEventListener("mousemove",this.moveFunction,true);
				else
				document.body.onmousemove = this.moveFunction;
			}
			this.visible = true;
		}
	}
	
	this.setTitle = function(tit){
		this.title = tit;
		var sp = document.createElement("div");
		sp.className = "titreLab";
		sp.innerHTML = this.title;
		this.titleBar.replaceChild(sp,this.titleBar.firstChild.nextSibling);
	}
	
	this.setPosition = function(t,l){
		this.frame.style.top = t+"px";
		this.frame.style.left = l+"px";
		/*this.frameB.style.top = this.frame.offsetTop+"px";
		this.frameB.style.left = this.frame.offsetLeft+"px";*/
	}
	
	this.getTitle = function(){
		return this.title;
	}
	
	this.setModal = function( bool){
		this.modal = bool;
	}
	
	this.isModal = function(){
		return this.modal;
	}
	
	this.setMovable = function( bool){
		if(bool == 'true')
			bool = true;
		if(bool == 'false')
			bool = false;
		this.movable = bool;
	}
	
	this.isMovable = function(){
		return this.movable;
	}
	
	this.setClosable = function( bool){
		if(bool == 'true')
			bool = true;
		if(bool == 'false')
			bool = false;
		this.closable = bool;
	}
	
	this.isClosable = function(){
		return this.closable;
	}
	
}