/**
 * IreusToolkit (Pseudo Class Definition)
 */
function IreusToolkit() 
{
	/**
	 * Executes IREUS Toolkit
	 * 
	 * @scope public
	 * @return void
	 */
	this.call = function()
	{
		getLanguage();
		getGallery();
	};


	/**
	 * Adjusts language selector
	 * 
	 * @scope private
	 * @return void
	 */
	function getLanguage ()
	{
		var cur_language = document.location.pathname.split('/')[1];
		if (cur_language == 'de'
		) {
			document.getElementById('LanguageSelector').selectedIndex = 0;
		}
		else
		{
			document.getElementById('LanguageSelector').selectedIndex = 1;
		}
	};


	/**
	 *  Loads Gallerifix
	 *  
     * @scope private
	 */
	function getGallery ()
	{
		// Do we have some parameters?
		if ((typeof load_gl) != 'object') return;

		// Create HTML parts dynamically based on given parameters 
		var body = document.getElementsByTagName('body');

		var dBoxes = document.createElement('div');
		dBoxes.id = 'boxes';
		dBoxes.className = 'isboxes';

		var dMask = document.createElement('div');
		dMask.id = 'mask';

		for (var i=0; i<load_gl.length; i++)
		{	
			var aClose = document.createElement('a');
			aClose.href = '#';
			TextNode = document.createTextNode('Close');
			aClose.appendChild(TextNode);

			var pSmall = document.createElement('p');
			pSmall.className = 'close';
			pSmall.appendChild(aClose);
			
			var dMoreInfo = document.createElement('div');
			dMoreInfo.className = 'window';
			dMoreInfo.appendChild(pSmall);
			
			var h3HeadLine = document.createElement('h3');
			var TextNode = document.createTextNode(load_gl[i]['hl']);
			h3HeadLine.appendChild(TextNode);
			dMoreInfo.appendChild(h3HeadLine);

			var iframe = document.createElement('iframe');
			iframe.style.border = '0';
			iframe.src = load_gl[i]['target'];
			iframe.width = load_gl[i]['width'];
			iframe.height = load_gl[i]['height'];
			iframe.width = load_gl[i]['width'];
			iframe.scrolling = 'no';
			iframe.frameBorder = '0';

			var dContent = document.createElement('div');
			dContent.className = 'wContent';
			dContent.appendChild(iframe);

			dMoreInfo.appendChild(dContent);
			dMoreInfo.id = 'MoreInfo' + (i + 1);

			dBoxes.appendChild(dMoreInfo);
			
			var aOpen = document.getElementById(load_gl[i]['linkid']);
			aOpen.href = '#MoreInfo' + (i + 1);
			aOpen.rel = 'modal';
		}
		dBoxes.appendChild(dMask);
		body[0].appendChild(dBoxes);

		// load required JS
		document.write(unescape("%3Cscript src='/ireus2-theme/js/ireus.modalwindow.js' type='text/javascript'%3E%3C/script%3E"));
	};
}


/**
 * Start processing
 */
var IreusToolkit = new IreusToolkit();
IreusToolkit.call();
