// ------------------------------------------
// CLASS   : mcms_div_popup
// descr.  : manages the div-popup function
// author  : Richard Lagerström (+46 739 39 19 10)
// website : http://www.empty.se, http://www.mediatroop.se
// date    : 2007-04-05
// ------------------------------------------
function mcms_div_popup()
{
	// -------------------------------------------
	// properties
	// -------------------------------------------
		/* keeps the id of the last used box id
		 * @var string
		*/
		this.old_unique_id = "";
		
	// -------------------------------------------
	// methods
	// -------------------------------------------
		/* hidex a given box
		 * @param 
		 * @return void
		*/
		this.popup_hide = function(contentBoxID)
		{
			// hide popup box
			if(document.getElementById(contentBoxID)) document.getElementById(contentBoxID).style.display = 'none';
			
			// reset dynamix content <div>
			if(document.getElementById(contentBoxID+'_dynamic')) document.getElementById(contentBoxID+'_dynamic').innerHTML = '<img src="'+config['http_root']+'inc/gfx/loading.gif"> Loading ...';
			
			// hide site fader
			if(document.getElementById('lockedLayer')) document.getElementById('lockedLayer').style.display = 'none';
			
		}
		
		
		/* displays a popup with contents retreived from given DIV id (innerHTML)
		 * @param 
		 * @return void
		*/
		this.popup = function(contentBoxID, optionalData)
		{
			// jump to site top
			window.scroll(10000,0);
			
			// make sure this element exists
			if(document.getElementById(contentBoxID))
			{
				// hide last used box
				if(this.old_unique_id != '')
				{
					// make sure box exists
					if(document.getElementById(this.old_unique_id))
					{
						// hide it
						document.getElementById(this.old_unique_id).style.display = 'none';
					}	
				}
				
				// display popup
				document.getElementById(contentBoxID).style.display = '';
				
				// fade entire site (set focus on popup)
				if(document.getElementById('lockedLayer'))
				{
					document.getElementById('lockedLayer').style.display = 'block';
				}
				
				// send optional third parameter data to customer function
				if(optionalData != 'undefined' && optionalData != undefined)
				{
					// make sure function exists
					eval(contentBoxID+"('"+optionalData+"');");
				}
				
				// store id of last used unique_id (box id)
				this.old_unique_id = contentBoxID;
			}
			else
			{
				alert("Could not locate content holder.");	
			}
		}
}

var mcmsDivPopup = new mcms_div_popup();