function toogle_flash_visibility(targetFLAH,targetLINK,oldHeight)
{
	if(targetFLAH.offsetHeight > 10)
	{
		new Effect.Morph(targetFLAH, {
		  style: 'height:0px;',
		  duration: 0.8
		});
		createCookie("show_flash","false",360);
		targetLINK.innerHTML = 'Animation anzeigen';
	}else{
		new Effect.Morph(targetFLAH, {
		  style: 'height:'+oldHeight+'px;',
		  duration: 0.8
		});
		createCookie("show_flash","true",360);
		targetLINK.innerHTML = 'Animation verbergen';
	}
}


document.observe("dom:loaded", function() {

	if($('flash_displayer') != null)
	{		
		var flash_height = "300";
		
		Event.observe($('flash_displayer'), 'klick', function(event) {
			toogle_flash_visibility($('flash_displayer'),$('flash_hide_link'),flash_height);
		});	
		
		
		if(readCookie("show_flash") == "false")
		{
			$('flash_displayer').style.height = "0px";
			$('flash_hide_link').innerHTML = 'Animation anzeigen';
			flash_height = "0";
		}
		
		
		var flashvars = {
		  xml_file: AJAX_PATH+"?s=get_flash_xml"
		};
		var params = {
		  menu: "false",
		  allowScriptAccess: "always",
		  scale: "noscale",
		  wmode: "transparent"
		};	
		var attributes = {
			styleclass : "z_behind"
		};

		swfobject.embedSWF("system/clientside/flash/header_flash.swf", "flash_displayer", "800",
						   flash_height, "9.0.0","system/clientside/flash/expressInstall.swf", flashvars, params,attributes);	
		
	}
	
	
	if($('header_news') != null)
	{
		var flashvars = {
		  news_content: AJAX_PATH+"?s=get_flash_news"
		};
		var params = {
		  menu: "false",
		  allowScriptAccess: "always",
		  scale: "noscale",
		  wmode: "transparent"
		};	
		var attributes = {
			styleclass : "z_behind"
		};
		swfobject.embedSWF("system/clientside/flash/news_ticker.swf", "header_news", "800",
						   "25", "9.0.0","system/clientside/flash/expressInstall.swf", flashvars, params,attributes);	
	}
	
	
	show_new_flyer();
});


function draw_section_meneu()
{
	if($('header_sections_div') != null)
	{
	
		euEnv.imageBasePath=IMG_DIR;
	
	   var dock = new euDock();
	   
	   dock.setBar({
		});
	   
	   dock.setObjectAlign('header_sections_div',euCENTER,0,euHORIZONTAL);
	   
	   dock.setIconsOffset(0);
			
	   dock.addIcon(new Array({euImage:	{image:CONTENT_PATH+"section_img/hip_hop.png"}}),
										{link:"?s=section&id="});
	
	   dock.addIcon(new Array({euImage:	{image:CONTENT_PATH+"section_img/rock.png"}}),
										{link:"?s=section&id="});
	   
	   dock.addIcon(new Array({euImage:	{image:CONTENT_PATH+"section_img/party.png"}}),
										{link:"?s=section&id="});;
	
	   dock.addIcon(new Array({euImage:	{image:CONTENT_PATH+"section_img/land_side.png"}}),
										{link:"?s=section&id="});
	
	   dock.addIcon(new Array({euImage:	{image:CONTENT_PATH+"section_img/supported.png"}}),
										{link:"?s=section&id="});

	}
}


function show_new_flyer()
{
	if(SHOW_FLYER_WINDOW)
	{
		if(readCookie("FLYER_WINDOW_ALREADY_SCHOWN_"+CUR_FlYER_ID) != "true")
		{
			createCookie("FLYER_WINDOW_ALREADY_SCHOWN_"+CUR_FlYER_ID,"true",360);
			
			myLightWindow = new lightwindow();
			
			myLightWindow.activateWindow({
				iframeEmbed: false,
				title: "",
				href: AJAX_PATH+"?s=get_next_event_popup", 
				width: 350,
				height: 465
			});
			
		}
	}
}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function show_add_forum_entry()
{
	$('forum_add_entry_div').show();
	focus($('forum_add_text'));
}

function hide_add_forum_entry()
{
	$('forum_add_entry_div').hide();
	$('forum_add_text').value = "";
	scroll(0,0);
}

function add_entry()
{
	if($('forum_add_text').value == "")
	{
		$('forum_add_text').style.background = "red";
		Effect.Shake('forum_add_text');
		return;
	}
	
	var url = AJAX_PATH+"?s=add_forum_entry";

	new Ajax.Request(url, {
	  method: 'post',
	  parameters: {ID: $('forum_add_id').value, text: $('forum_add_text').value},
	  	onSuccess: function(transport) {

			if(transport.responseText != null && transport.responseText != 0)
			{
				$('forum_add_text').style.background = "black";
				hide_add_forum_entry();
				
				$('forum_topic_container_div').innerHTML = transport.responseText + $('forum_topic_container_div').innerHTML;
				
				Dialog.alert("Eintrag wurde hinzugef&uuml;gt!", 
							 {className: "alphacube", width:260, okLabel: "OK"});
								
				scroll(0,0);
			}
		},
		onFailure: function(){ alert('Something went wrong...') }
	});

	
}

function inv_friend()
{		
	var email_value = $('inv_friend_email').value;
	$('inv_friend_email').value = "";
	if(email_value == "")
	{
		$('inv_friend_email').style.background = "red";
		Effect.Shake('inv_friend_email');
		return;
	}
	
	Dialog.alert("Einladung abgesendet!", 
										 {className: "alphacube", width:260, okLabel: "OK"});
	
	var url = AJAX_PATH+"?s=inv_friend";

	new Ajax.Request(url, {
	  method: 'post',
	  parameters: {email: email_value},
	  	onSuccess: function(transport) {

			if(transport.responseText == "ok")
			{
				$('inv_friend_email').style.background = "black";
												
				$('inv_friend_email').value = "";
			}
		},
		onFailure: function(){ alert('Something went wrong...') }
	});	
}