correctWindow = function(){
	var display = document.id('display');
	display.position();
	return true;
}

building_toplinks = function(){
	/*toplinks = $$('.space_icon');
	toplinks.each(function(item, index){
		item.addEvent('click', function(){
			// reloadContent(item.getParent());
			$('maincontent').load(item.getParent());
			return true;;
		});
   });*/
	$('anfahrt').addEvent('click', function() { $('cContent').load('stellaris1.4/stellarisCore/prepages/anfahrt.html'); return true; });
	$('year').addEvent('click', function(){	$('cContent').load('stellaris1.4/stellarisCore/worked/show.php?contentId=3002');return true; });
	$('kontakt').addEvent('click', function(){ $('cContent').load('stellaris1.4/stellarisCore/prepages/kontakt.php'); return true; });
	$('imprint').addEvent('click', function(){ $('cContent').load('stellaris1.4/stellarisCore/prepages/impressum.php'); return true; });
	$('agb').addEvent('click', function(){ $('cContent').load('stellaris1.4/stellarisCore/prepages/agb.php'); return true; });
	if($('year2') == true) {$('year2').addEvent('click', function(){	$('cContent').load('stellaris1.4/stellarisCore/worked/show.php?contentId=3002');return true; })};
}

reloadContent = function(target){
	$('maincontent').empty();
	var myRequest = new Request({method: 'get', url: target, onComplete: function(antwort){ $('maincontent').set('html', antwort)}});
	myRequest.post();
	return true;
}

function updateMain(contentd){
	/*alert(contentId);
	var cRequest = new Request.JSON({
		'url':'stellaris1.4/stellarisCore/worked/contentFunctions.inc.php',
		onRequest: function() {
		},
		onSuccess: function(antwort){
			$('cContent').set('html', "");
			$('cContent').set('html', antwort.text);
			$('cContent').set('ref', antwort.contentId);
		}
	}).get({'action':'updateDisplay','contentId':contentId});
	*/
	// $('cContent').load('stellaris1.4/stellarisCore/worked/show.inc.php?contentId='+contentd);
}



build_Mainmenu = function(){
	
	// var overlay = new Overlay(document.body,{id: 'overlay',color: '#000',duration: 300,	opacity: 0.4, onClick: function() {},onShow: function() {}});
	
	mouseovers = $$('#mainMenu img');
	mouseovers.each(function(item, index){
		if(item.getParent().hasClass('up')){
			item.addEvent('click', function(){
				if(item.get('id') == "7002"){
					$('cContent').load('stellaris1.4/stellarisCore/guestbook/mainindex.php');
				}
				else if (item.get('id') == "8002"){
					$('cContent').load('stellaris1.4/stellarisCore/prepages/bestellkontakt.php');
				}
					else {
					$('cContent').load('stellaris1.4/stellarisCore/worked/show.php?contentId='+this.get('id'));
				}
			});
		}
		else{								 
		item.addEvents({
			'mouseover': function(){
				item.highlight('#5BC4E6');
			},
			'click': function(){
				if(this.get('id') != "7002")
				{
					item.setStyle('background', '#5BC4E6');
					$('cContent').load('stellaris1.4/stellarisCore/worked/show.php?contentId='+this.get('id'));
					return true;
				}
				else if (item.get('id') == "8002"){
					$('cContent').load('stellaris1.4/stellarisCore/prepages/bestellkontakt.php');
				}
				else{
					item.setStyle('background', '#5BC4E6');
					$('cContent').load('stellaris1.4/stellarisCore/guestbook/mainindex.php');
					return true;
				}
			},
			'mouseleave': function(){
				item.setStyle('background','');
			}
	   });
		}
	});
	
	var menu = new Accordion($('mainMenu'), '.up', 'div.sub', {
		opacity: false,
		display:-1,
		onActive: function(toggler, element){
			var alt = toggler.getChildren();
			toggler.setStyle('color', '#41464D');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#528CE0');
			resetItems = $$('.ups');
				resetItems.each(function(backwards){
					backwards.setStyle('background','');
				});
					
		}
	})
}

window.addEvent('domready', function(){
	
	window.addEvent('resize', function(){
		// correctWindow();
	});
	
	
	// correctWindow();

	build_Mainmenu();
		
	building_toplinks();
	
	if(Cookie.read('stop')){
		var cid = Cookie.read('stop');
		$('cContent').load('stellaris1.4/stellarisCore/worked/show.php?contentId='+cid);
		return true;
		Cookie.dispose('stop');
	}
	
	if(Cookie.read("sprache") == "eng"){
		$('cContent').load('stellaris1.4/stellarisCore/worked/show.php?contentId=5003');
	} else {
		$('cContent').load('stellaris1.4/stellarisCore/worked/show.php?contentId=5003');
	}
});

