naviki.main.ModalDialog = function( el , userConfig){

	this.id = el;
	
	naviki.main.ModalDialog.superclass.constructor.call(this, el, userConfig);
};

naviki.main.ModalDialog.prototype.bringToTop = function() {
	// the normal bring to top function does not work correctly because of the nui- classes. So i must implement ower own.
	var aDivs = new Array();
	var Dom = YAHOO.util.Dom;
	// get all div elements.
	aDivs = document.getElementsByTagName("div");
	if (aDivs.length == 0) {
		this.cfg.setProperty("zindex", 10);
		return;
	}
	var maxIndex = -9999;
	var count = aDivs.length;
	for (var i=1;i<count;i++) {
		var div = aDivs[i];
		var sZIndex = Dom.getStyle(div, "zIndex");
		var nZIndex = (!sZIndex || isNaN(sZIndex)) ? 0 : parseInt(sZIndex, 10);
		if (nZIndex > maxIndex) {
			maxIndex = nZIndex;
		}
	}
	this.cfg.setProperty("zindex", (maxIndex + 2));
};

naviki.main.ModalDialog.prototype.show = function(){

	eventMgr.disableControls.fire();
	
	var id     = this.id + "_mdIframe";
	var parent = document.getElementById(this.id+"_c");
	var iframe = document.createElement("iframe");
	var region = YAHOO.util.Dom.getRegion(parent.id);
	
	iframe.id             = id;
	iframe.style.top      = "1px";
	iframe.style.left     = "2px";	
	iframe.style.position = "absolute";
	iframe.width  = region.width  - 6;
	iframe.height = region.height - 4;
	
	parent.appendChild(iframe);
	
	this.cfg.setProperty("visible", true);
};

naviki.main.ModalDialog.prototype.hide = function(){

	eventMgr.enableControls.fire();
	
	var id     = this.id + "_mdIframe";
	var iframe = document.getElementById(id);
	var parent = document.getElementById(this.id+"_c");
	parent.removeChild(iframe);
	
	this.cfg.setProperty("visible", false);
};

