var openning = false;

function closeFceLayerbox() {
	try {
		$('fceLayerbox').fade({ duration: 0.5, from: 1, to: 0 });	
	}catch(e){}
}

function initFceLayerbox() {
	try {
		if($('fceLayerbox')) {
			var temporaryHTMLOfFCELayerbox = $('fceLayerbox').parentNode.innerHTML;
			$('fceLayerbox').remove();
			$('main').insert({bottom: temporaryHTMLOfFCELayerbox});
			$$('.fceLayerbox .fceCtArea')[0].style.maxHeight = (document.viewport.getHeight()-150)+"px";
			$$('.fceLayerbox .fceCtArea')[0].style.overflowY = 'scroll';
		}
	}catch(e){}
}

function showLayerBox() {
	if($('fceLayerbox')) {
		openning = true;
		$('fceLayerbox').appear({ duration: 0.5, from: 0, to: 1, afterfinish: function(){
			openning = false;
		}});
		
		// 21.09.10 SS: Commented out to make media elements in layerbox possible
		/* try {
			Event.observe($$('#fceLayerbox .fceCtArea')[0], 'click', 'closeFceLayerbox(false)');
		}catch(e) {
			window.alert(e);
		}
		try {
			Event.observe($('fceLayerbox'), 'click', 'closeFceLayerbox(true)');
		}catch(e) {
			window.alert(e+" fceLayerBox");
		}
		 */
		try {
			Event.observe($('fceLayerboxClose'), 'click', closeFceLayerbox);
		}catch(e){
			window.alert();
		}
			
	}
}

// run initFceLayerbox as soon as the page is ready
Event.observe(window, 'load', initFceLayerbox);


