window.addEvent('domready', function() {
		
		//Top Navigation Hover Effect		
		$('nav_top').getElements('ul li.submenu').each( function( elem ){
			var list = elem.getElement('ul');
			
			if(elem.offsetLeft == '800'){
				list.style.left = "-53px";
			} else if (elem.offsetLeft == '880') {
				list.style.left = "-133px";
			}
				
			elem.addEvents({
				'mouseenter' : function(){
					list.setStyle('display', 'block');
					elem.addClass('hover');
				},
				'mouseleave' : function(){
					list.setStyle('display', 'none');
					elem.removeClass('hover');
				}
			});
		})
		
		
		//Game Schatzkiste
		if ($('schatzkiste')) {
			var ID = 1;
			var currentID = 1;
			var wrong = 0;
			var right = 0;
			var tmpID = 0;
			var pro	  = 0;
			
			var nicolasDontKnow = "<img src=\"../../../files/bilder/forschungslabor/schatzkiste/geldmemory_nicolas.jpg\" height=\"350\" />";
			var nicolasWrong = "<img src=\"../../../files/bilder/forschungslabor/schatzkiste/geldmemory_nicolas_wrong1.jpg\" height=\"350\" />";
			var nicolasWrong2 = "<img src=\"../../../files/bilder/forschungslabor/schatzkiste/geldmemory_nicolas_wrong2.jpg\" height=\"350\" />";
			var nicolasRight = "<img src=\"../../../files/bilder/forschungslabor/schatzkiste/geldmemory_nicolas_right.jpg\" height=\"350\" />";
			
			var congratulation = "Das Spiel ist vorbei und wir gratulieren dir. Das hast du wirklich gut gemacht.";
			var tztz = "Das war aber ganz sch&ouml;n schwierig oder? Villeicht klappt es ja beim n&auml;chsten Mal besser? Kuck ruhig mal nach, wie das Geld aus den verschiedenen L&auml;ndern heisst, und wie viel es wert ist.<br />Viel Gl&uuml;ck beim n&auml;chsten Versuch!";


			$('startGameBtn').addEvent('click', function(){
				$$('.gameHidden').each(function(el) {
					ID++;
				});
				
				$('startGame').setStyle('display', 'none');
				$('game_'+currentID).setStyle('display', 'block');
				
				$$('.btnCheckbox').each(function(el) {											 
					el.addEvent('click', function(e) {
						if(el.value == $('result_'+currentID).value) {
							right++;
							$('correct_'+currentID).setStyle('display', 'block');
							$('nicolas_'+currentID).innerHTML = nicolasRight;
							result();
						} else {
							if (wrong != 2) {
								wrong++;
								$('nicolas_'+currentID).innerHTML = nicolasWrong;
								$('label_'+el.value+'_'+currentID).innerHTML = el.value + " <span class=\"wrong\">(falsch)</span>";
							} else {
								wrong++;
								$('nicolas_'+currentID).innerHTML = nicolasWrong2;
								$('wrong_'+currentID).setStyle('display', 'block');
								result();
							}
						}					  
					});	
				});								   
				return false; // equivalent to stopPropagation.
			});
			
			function result(){
				$('answered_'+currentID).innerHTML = right;
				$('answered_gameover').innerHTML = right;
				$('question_'+currentID).setStyle('display', 'none');
				$('next_'+currentID).setStyle('display', 'block');
			}

			$$('.nextGame').each(function(el) {											 
				el.addEvent('click', function(e) {
					nextQuestion();						  
				});	
			});	
				
			function nextQuestion(){
				wrong = 0;
				tmpID = currentID+1;
				
				if (tmpID < ID) {
					$('game_'+currentID).setStyle('display', 'none');
					$('game_'+tmpID).setStyle('display', 'block');
				} else {
					$('game_'+currentID).setStyle('display', 'none');
					
					pro = (right / (ID-1)) * 100;
					$('answered_total').innerHTML = tmpID - 1;
					
					if (pro < 50) {
						$('congratulation').innerHTML = tztz;
					} else {
						$('congratulation').innerHTML = congratulation;
					}
					
					$('game_over').setStyle('display', 'block');
				}
				
				currentID++;
			}
		}/*Game Schatzkiste End*/
		
		if ($('flashElement')) {
			$$('.mainArticle').setStyle('padding', ' 0 5px 5px 5px');
		}
		
		if($$('.popup').length > 0)//only triggered if 'mb' class found on page
		{
			//alert("JEPP");
			try{
			//call multiBox
			var initMultiBox = new multiBox({
				mbClass: '.popup',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)
				container: $(document.body),//where to inject multiBox
				useOverlay: false,//use a semi-transparent background. default: false;
				maxSize: {w:800, h:550},//max dimensions (width,height) - set to null to disable resizing
				addOverlayIcon: false,//adds overlay icons to images within multibox links
				recalcTop: true,//subtract the height of controls panel from top position
				addTips: false//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)
			});
			}catch(e){};
		};
		
		// this is used to display an default text for the welttag page
		if($$('.ct-welttag').length == 0 && $('std-weltag-text'))
		{
			$('std-weltag-text').setStyle('display', 'block');
		};
		
});
