var allowClose = false;
var swfu = null;
function blendeAus(element)
 {
	var el = document.getElementById(element)
	if(el != null) 
		el.style.display = 'none';
 }

 function blendeEin(element)
 {
 	firefox=(document.getElementById && !document.all)?1:0;
	var el = document.getElementById(element)
	if(el != null) 
	{
		el.style.display = 'block';
		/*if(firefox)
			el.style.display = 'table-row';
		else
			el.style.display = 'inline';*/
	}
 }
 
 function setText(id, text)
 {
 	var element = document.getElementById(id);
 	if(element != null)
 	{
 		deleteText(id);
 		if(text != null)
 			element.appendChild(document.createTextNode(text));
 	}		 	
 }
 
 function deleteText(parentId)
 {
	var parent = document.getElementById(parentId);
	var childNodes = parent.childNodes;
	var	size = childNodes.length;
	for (i = 0; i < size; i++)
	{
		parent.removeChild(parent.firstChild);
	}
 }
 
 var popups = [];
 
 popupHandler = function(event) {
	 event.stop();
	 for ( i=0; i < popups.length; i++ ) {
		if (popups[i].elm == this) popups[i].openPopup();
	 }
 }
 
 closePopups = function() {
	 for ( i=0; i < popups.length; i++ ) {
		 popups[i].close();
	 }
 }
 
 AMPopup = function(elm,opts) {
	 this.href    = elm.href;
	 this.elm     = elm;
	 this.x       = 0;
	 this.y       = 0;
	 this.opts    = opts;
	 this.offsetX = ( opts.offsetX ) ? opts.offsetX : 0;
	 this.offsetY = ( opts.offsetY ) ? opts.offsetY : 0;
	 this.width   = ( opts.width   ) ? opts.width : 300;
	 
	 this.renderElem = new Element('div',{ style: 'position: absolute;'} );
	 this.renderElem.hide();
	 
	 this.open = false;
	 
	 popups.push(this);
	 
	 this.elm.observe('click', popupHandler);
	 
	 this.openPopup = function() {
		 closePopups();
		 if ( !this.renderElem.parentNode ) {
			 document.body.appendChild(this.renderElem);
		 }
		 this.calcPos();
		 
		 this.renderElem.setStyle( { width: this.width + 'px', top: this.y + 'px', left: this.x + 'px' })
		 new Ajax.Updater(this.renderElem,this.href);
		 this.renderElem.show();
		 this.open = true;
		 return false;
	 }
	 
	 this.calcPos = function() {
		obj = this.elm;
        for ( var x = 0, y = 0; obj != null; x+=obj.offsetLeft, y+=obj.offsetTop, obj=obj.offsetParent );
        this.x = x + this.offsetX;
        this.y = y + this.offsetY;
	 }
	 
	 this.close = function() {
		 if ( this.open ) {
			 this.renderElem.parentNode.removeChild(this.renderElem);
			 this.open = false;
		 }
	 }
 }
