/* 	
	------------------------------------------------------------------------------
	/framework/classes/js/panel.js
	
	Een panel is een div die hidden of visible is. Dat is alles!
	
   	------------------------------------------------------------------------------
    
    VERSION HISTORY:
 	   20050809		1.0		PFAS	Initial version
	
	------------------------------------------------------------------------------
*/

function Panel(_id) {

	// standard properties
	this.id = _id;	
	
	this.containerelementid = "C_" + this.id;
	this.containerelement = document.getElementById(this.containerelementid);
	this.handleelementid = "H_" + this.id;
	this.handleelement = document.getElementById(this.handleelementid);
	this.popupElementId = "P_" + this.id;
	this.popupElement = document.getElementById(this.popupElementId);
	
	
	// appearance
	this.visible = true;
	this.type = "normal";
	this.width = 0;
	this.height = 0;
	
	// events
	// extra properties
	
	
	// methods
	this.show = Panel_show;
	this.hide = Panel_hide;
	
	this.showPopup = Panel_showPopup;
	this.hidePopup = Panel_hidePopup;
}


function Panel_hide() {
	if (this.containerelement) {
		showDropDowns();
		this.visible = false;
		this.containerelement.style.display = "none";
	}
}

function Panel_show(ev) {
	
	if (this.containerelement) {
		if (this.type == "normal") {
			this.visible = true;
			this.containerelement.style.display = "block";
		}
		else {
			/*if (ev.pageX || ev.pageY)
			{
				posx = ev.pageX;
				posy = ev.pageY;
			}
			else if (ev.clientX || ev.clientY)
			{
				posx = ev.clientX + document.body.scrollLeft;
				posy = ev.clientY + document.body.scrollTop;
			}
			alert("posx = " + posx + " posy = " + posy);
			*/
			
			var divWidth = this.width;
			var divHeight = this.height;
			posX = (getClientWidth() - divWidth) / 2;
			posY = (getClientHeight() - divHeight) / 2;
			if (document.documentElement && document.documentElement.scrollTop)
				theTop = document.documentElement.scrollTop;
			else if (document.body)
				theTop = document.body.scrollTop
			
			//alert(getClientWidth() + " - " + getClientHeight() + " - " + getdocwidth() + " - " + getdocheight() + " - " + posX + " - " + posY + " - " + theTop + " - " + this.width + " - " + this.height);
			
			
			/*
			this.containerelement.style.minheight = divHeight + "px";
			// TODO - Dit is echt mottig gedaan -> dat moet nog gecheckt hoe dit deftig kan gebeuren!
			if (document.all) {
				this.containerelement.style.height = divHeight + "px";
			}
			*/
			//this.containerelement.style.height = divHeight + "px";
			this.popupElement.style.height = divHeight + "px";
			this.popupElement.style.width = divWidth + "px";
			
			
			this.containerelement.style.position = "absolute";	
			this.containerelement.style.display = "block";
			this.containerelement.style.backgroundColor = "#FFFFFF";	
			this.containerelement.style.border = "1px solid #CECECE";	
			//this.containerelement.style.border = "1px solid red";
			//this.containerelement.style.overflow = "auto";
			
			//alert(this.containerelement.style.left);
			//alert(this.containerelement.style.top);
			
			this.containerelement.style.left = posX + "px";
			this.containerelement.style.top = posY + theTop + "px";
			//this.containerelement.style.width = (imgwidth+10) + "px";
			this.containerelement.style.width =  divWidth + "px";
			this.containerelement.style.zIndex = "100";
			
			//alert(this.containerelement.style.left);
			//alert(this.containerelement.style.top);
				
			//alert(this.containerelement.offsetWidth);
			Drag.init(this.handleelement, this.containerelement);
			
			hideDropDowns();
			
			this.visible = true;
		}
		
	}
}


function Panel_hidePopup() {
	if (this.containerelement) {
		showDropDowns();
		this.visible = false;
		this.containerelement.style.display = "none";
	}
}

function Panel_showPopup() {
	if (this.containerelement) {
		
		
		
		
	}
}

