gscf = function()
{			
	var cutOut = function(str,a,b)
	{
		var pos_a = str.indexOf(a);
		var pos_b = str.indexOf(b, pos_a+a.length);
		return str.substr(pos_a+a.length, pos_b-pos_a-a.length);
	}
	
	var contentShow = function()
	{
		//new Effect.Move('contenteffect', { x: 0, y: 0, mode: 'absolute', duration:0.6 });
		$('loading').fade({ duration: 0.2 });
		
		//$('contenteffect').appear({ duration: 0.4 });
		$('contenteffect').setStyle({display:'block'});
	}
	
	var contentHide = function(removeAfter)
	{	
		// move out sideways	
		//var af = removeAfter ? function(){$('contentbox').setStyle({display:"none"});} : null;
		//new Effect.Move('contenteffect', { x: -1000, y: 0, mode: 'absolute', duration:0.4,afterFinish:af});
		
		// fade out
		//$('contenteffect').fade({ duration: 0.3 });
		
		// remove contents
		$('text').update('');
		$('media').update('');
		
		// make invisible
		$('contenteffect').setStyle({display:'none'});
	}
	
	var contentSwitch = function(transport)
	{
		$('media').setStyle({display:'block'});
		$('text').setStyle({width:'410px'});
			
		$('mainmenu').setStyle({height:"265px"});	
		//$('media').update( transport.responseXML.$("media").innerText );
		//$('text').update( transport.responseXML.$("text").innerText );
		contentShow();
		
		// WORKAROUND IE XMLPARSER
		$('text').update( cutOut(transport.responseText, "<div id=\"text\"><!--TYPO3SEARCH_begin-->", "<!--TYPO3SEARCH_end--></div>") );
		$('media').update( cutOut(transport.responseText, "<div id=\"media\"><!--TYPO3SEARCH_begin-->", "<!--TYPO3SEARCH_end--></div>") );
		
		//alert(transport.responseXML.getElementById("text").innerText);
		
	}
	
	var contentError = function()
	{ 
		alert('An error occured. Could not load page contents.');
	}
	
	
	
	// public functions
	return {
		content:function(url)
		{
			$('loading').appear({duration:.2});
			contentHide();
			
			url += "&xml=1";
			
			new Ajax.Request(url,
			{
			  method:'get',
			  onSuccess: contentSwitch,
			  onFailure: contentError
			});
			

		},		
		flashmenu:function ()
		{
			if(swfobject.hasFlashPlayerVersion("9.0.0") && window.location.href.indexOf('noflash') == -1 )
			{
				var vars = {'xmlfile':'index.php?type=3'};
				var params = { scale:'noScale', salign:'lt', menu:'false' };
				swfobject.embedSWF("fileadmin/templates/preload.swf", "mainmenu", "100%", "100%", "9.0.0", "js/expressInstall.swf",vars,params);
				$('mainmenu').setStyle({height:"620px"});
				$('pagetitle').setStyle({display:"none"});
				$('servicenavi').setStyle({display:"none"});
				$('loading').setStyle({display:"none"});
				contentHide(true);
			}
			else
			{
				if(window.location.href.indexOf('id=')==-1)
				{
					var nofl = '<div id="msg_overlay"><div><p>Multimedia contents on this website require the latest <a href="http://www.adobe.com/go/getflashplayer" target="_blank">Adobe Flashplayer 9</a> which can be downloaded free of charge.</p><a href="http://www.adobe.com/go/getflashplayer" target="_blank"><img src="fileadmin/templates/get_adobe_flash_player.png" /></a><p>Alternatively you can <a href="#" onclick="gscf.dismiss(); return false;">dismiss</a> this message to use the limited non-flash version of this site.</p></div></div>';
					new Insertion.Top('site', nofl)
				}
				
				$('noflash').setStyle({display:"block"});
				contentShow();
			}
			
			$('contentbox').setStyle({display:"block"});
			
			// IE6 FOOTER FIX
			if(navigator.appName == "Microsoft Internet Explorer" && (navigator.appVersion.indexOf("MSIE 6") > -1 || navigator.appVersion.indexOf("MSIE 5") > -1) )
			{
				$('footer').setStyle({position:"static"});
			}
			
		},
		overview:function(h)
		{
			h = h ? h : "620";
			$('mainmenu').setStyle({height:h+"px"});

			contentHide(true);
		},
		print:function(url)
		{
			if(url)
			{
				printWindow = window.open(url+"&print=1&no_cache=1", "printWindow");
				printWindow.focus();
			} 
			else
			{
				alert("Please select a content-page first.");
			}
		},
		dismiss:function()
		{
			$('msg_overlay').remove();
		}
		
	}
}();

Event.observe(window, 'load', gscf.flashmenu);


