function PopIn(sInstanceName, sTargetId) {
	var that = this;
	this.sTargetId = sTargetId;
	this.sBackId = sTargetId + "Back";
	this.sCloserId = sTargetId + "Closer";
	this.sContentId = sTargetId + "Content";
	this.sZIndex = "";
	
	this.contentPad = 50;
	
	this.expand = function(sContentFile,iBackgroundOpacity) {
		var scrollPosition = that.xScrollTop(document);
		var scrollHeight = document.body.offsetHeight;

		if ( typeof(window.innerWidth) == 'number' ) {
			//Non-IE
			iFullWidth = window.innerWidth;
			iFullHeight = window.innerHeight;
		} else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			iFullWidth = document.documentElement.clientWidth;
			iFullHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			iFullWidth = document.body.clientWidth;
			iFullHeight = document.body.clientHeight;
		}
		
		that.eTarget = that.addElement('','div', [
			['id',that.sTargetId]
		]);
		that.eTarget.style.position = 'absolute';
		that.eTarget.style.top = '0';
		that.eTarget.style.left = '0';
		that.eTarget.style.width = iFullWidth + 'px';
		that.eTarget.style.height = scrollHeight + "px";
		if (that.sZIndex != "") {
			that.eTarget.style.zIndex = that.sZIndex;
		}
		
		
		that.eBack = that.addElement(that.sTargetId, 'div', [
			['id',that.sBackId]
		]);
		that.eBack.style.position = 'absolute';
		that.eBack.style.top = '0';
		that.eBack.style.left = '0';
		that.eBack.style.width = iFullWidth + 'px';
		that.eBack.style.height = scrollHeight + "px";
		that.eBack.style.backgroundColor = '#FFFFFF';
		that.setOpacity(that.eBack, iBackgroundOpacity);
		
		that.eCloser = that.addElement(that.sTargetId, 'div', [
			['id',that.sCloserId]
		]);
		that.eCloser.style.position = 'absolute';
		that.eCloser.style.top = scrollPosition + 'px';
		that.eCloser.style.right = '15px';
		that.eCloser.style.padding = 5 + 'px';
		that.eCloser.style.color = '#580103';
		that.eCloser.style.textAlign = 'right';
		that.eCloser.innerHTML = "<a href='javascript:oPopIn.hide();'>Close agenda X</a>";
		
		that.eContent = that.addElement(that.sTargetId, 'div', [
			['id',that.sContentId],
			['oncluck','oPopIn.hide();']
		]);
		that.eContent.style.position = 'absolute';
		//that.eContent.style.border = '1px solid #DDDDDD';
		that.eContent.style.top = scrollPosition + that.contentPad + 'px';
		that.eContent.style.left = that.contentPad + 'px';
		that.eContent.style.width = (iFullWidth - 2*that.contentPad) + 'px';
		that.eContent.style.height = (iFullHeight - 2*that.contentPad) + 'px';
		that.eContent.style.overflow = 'auto';
		
		that.loadInfo(sContentFile);
	}
	
	this.hide = function() {
		that.eTarget.parentNode.removeChild(that.eTarget);
	}
	
	this.setOpacity = function(eElement, iValue) {
		eElement.style.opacity = iValue/100;
		eElement.style.filter = 'alpha(opacity=' + iValue + ')';
	}
	
	this.addElement = function(sParent, sType, aAttributes) {
		
		var newElement = document.createElement(sType);
		for (var i=0; i < aAttributes.length; i++) {
			if (aAttributes[i][0] == "onclick" || 
				aAttributes[i][0] == "onload" ||
				aAttributes[i][0] == "onmouseover") {
				
				if (document.all) {
					//Attach event in the IE way
					function makeEventFunc(sEvents) {
						return function() {
							eval(sEvents);
						}
					}
					newElement.attachEvent(aAttributes[i][0], makeEventFunc(aAttributes[i][1]), true);
					
				} else {
					//Attach event in the Moz way
					newElement.setAttribute(aAttributes[i][0], aAttributes[i][1]);
				}
				
			} if (aAttributes[i][0] == "class") {
				newElement.className = aAttributes[i][1];
			} else {
				newElement.setAttribute(aAttributes[i][0],aAttributes[i][1]);
			}
		}
		
		if (sParent != "") {
			document.getElementById(sParent).appendChild(newElement);	
		} else {
			document.body.appendChild(newElement);
		}
		
		return newElement;
	}
	
	this.loadInfo = function(sContentFile) {
		var oAjax = new AjaxPage();
		oAjax.request(sContentFile, that.sContentId);
	}
	
	this.xScrollTop = function(e, bWin) {
		var offset=0;
	  	if (typeof(e) == 'undefined' || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
			var w = window;
			if (bWin && e) w = e;
			if(w.document.documentElement && w.document.documentElement.scrollTop) offset=w.document.documentElement.scrollTop;
			else if(w.document.body && typeof(w.document.body.scrollTop) != 'undefined') offset=w.document.body.scrollTop;
	  	}  else {
			e = xGetElementById(e);
			if (e && xNum(e.scrollTop)) offset = e.scrollTop;
	  	}
	  	return offset;
	}
	
	this.getScrollXY = function() {
		var scrOfX = 0, scrOfY = 0;
		if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		}
		return [ scrOfX, scrOfY ];
	}
}