/* sada utilit vyuzivanych calendarem, colorPickerem a dalsimi widgety v budoucnu */

// true pokud browser je IE
var isIE = ((document.all)&&(!window.opera)) ? true : false;

// dve funkce pro zjisteni pozice objektu na strance, autor: Peter-Paul Koch
fixOffsetLeft = function(obj) {var curleft = 0;if (obj.offsetParent) {while (obj.offsetParent) {curleft += obj.offsetLeft; obj = obj.offsetParent;}} else if (obj.x)	curleft += obj.x; return curleft;} 
fixOffsetTop  = function(obj) {var curtop  = 0;if (obj.offsetParent) {while (obj.offsetParent) {curtop  += obj.offsetTop; obj = obj.offsetParent;}} else if (obj.y) curtop += obj.y; return curtop;}

// umozni zobrazit widgety v IE i pres select pomoci <iframe> pod objektem
function IframeHack(obj) {
	this.create(obj);
}

IframeHack.prototype = {
	create: function(obj) {
		if (isIE) {
			this.obj    = obj;
			this.iframe = document.createElement('IFRAME');
			this.iframe.src = "javascript:false";
			this.iframe.style.position = 'absolute';
			this.iframe.style.display  = 'none';
			document.body.appendChild(this.iframe);
		}
	},
	change: function() {
		if (isIE) {
			this.iframe.style.top     = this.obj.style.top;
			this.iframe.style.left    = this.obj.style.left;
			this.iframe.style.width   = this.obj.offsetWidth;
			this.iframe.style.height  = this.obj.offsetHeight;
			this.iframe.style.display = this.obj.style.display;
			this.iframe.style.clip    = this.obj.style.clip;
		}
	}
}

// univerzalni objekt starajici se jen o zobrazeni a schovani widgetu a pouziti iframeHacku pro IE
function BlockHolder(className) {
	this.create(className);
}

BlockHolder.prototype = {
	create: function(className) {
		this.div             = document.createElement('DIV');
		this.iframe          = new IframeHack(this.div);
		this.div.className   = className;
	},
	show: function(top, left) {
		this.div.style.display = 'block';
		if (top && left) {
			this.div.style.top  = top;
			this.div.style.left = left;
		}
		this.iframe.change();
	},
	hide: function(className) {
		this.div.style.display = 'none';
		this.iframe.change();
	}
}