var pageCount = '';
var loadObservers = function() {
	if ($('flag_de') != undefined) {
		Event.observe(
			'flag_de',
			'click',
			function() {
				renderContent('index.php?action=home&lang=deutsch');
			},
			false
		);
	}
	if ($('flag_en') != undefined) {
		Event.observe(
			'flag_en',
			'click',
			function() {
				renderContent('index.php?action=home&lang=english');
			},
			false
		);
	}
	
	if ($('image_1') != undefined) {
		Event.observe(
			'image_1',
			'click',
			function() {
				renderContent('index.php?action=gallery&category=nature');
			},
			false
		);
		Event.observe(
			'image_1',
			'mouseover',
			function() {
				$('image_1').src = 'img/intro_starfish_color.gif';
				$('info_container_right').innerHTML = natureText;
			},
			false
		);
		Event.observe(
			'image_1',
			'mouseout',
			function() {
				$('image_1').src = 'img/intro_starfish_bw.gif';
				$('info_container_right').innerHTML = '';
			},
			false
		);
	}
	if ($('image_2') != undefined) {
		Event.observe(
			'image_2',
			'click',
			function() {
				renderContent('index.php?action=gallery&category=people');
			},
			false
		);
		Event.observe(
			'image_2',
			'mouseover',
			function() {
				$('image_2').src = 'img/intro_girl_sepia.gif';
				$('info_container_right').innerHTML = peopleText;
			},
			false
		);
		Event.observe(
			'image_2',
			'mouseout',
			function() {
				$('image_2').src = 'img/intro_girl_bw.gif';
				$('info_container_right').innerHTML = '';
			},
			false
		);
	}
	if ($('image_3') != undefined) {
		Event.observe(
			'image_3',
			'click',
			function() {
				renderContent('index.php?action=gallery&category=travel');
			},
			false
		);
		Event.observe(
			'image_3',
			'mouseover',
			function() {
				$('image_3').src = 'img/intro_bird_color.gif';
				$('info_container_right').innerHTML = travelText;
			},
			false
		);
		Event.observe(
			'image_3',
			'mouseout',
			function() {
				$('image_3').src = 'img/intro_bird_bw.gif';
				$('info_container_right').innerHTML = '';
			},
			false
		);
	}
	if ($('image_4') != undefined) {
		Event.observe(
			'image_4',
			'click',
			function() {
				renderContent('index.php?action=gallery&category=abstract');
			},
			false
		);
		Event.observe(
			'image_4',
			'mouseover',
			function() {
				$('image_4').src = 'img/intro_palmleaf_color.gif';
				$('info_container_right').innerHTML = momentsText;
			},
			false
		);
		Event.observe(
			'image_4',
			'mouseout',
			function() {
				$('image_4').src = 'img/intro_palmleaf_bw.gif';
				$('info_container_right').innerHTML = '';
			},
			false
		);
	}
	if ($('image_5') != undefined) {
		Event.observe(
			'image_5',
			'click',
			function() {
				renderContent('index.php?action=gallery&category=moments');
			},
			false
		);
		Event.observe(
			'image_5',
			'mouseover',
			function() {
				$('image_5').src = 'img/intro_dragonfly_color.gif';
				$('info_container_right').innerHTML = abstractText;
			},
			false
		);
		Event.observe(
			'image_5',
			'mouseout',
			function() {
				$('image_5').src = 'img/intro_dragonfly_bw.gif';
				$('info_container_right').innerHTML = '';
			},
			false
		);
	}
	if ($('image_6') != undefined) {
		Event.observe(
			'image_6',
			'mouseover',
			function() {
				$('image_6').src = 'img/intro_kauni_color.gif';
			},
			false
		);
		Event.observe(
			'image_6',
			'mouseout',
			function() {
				$('image_6').src = 'img/intro_kauni_bw.gif';
			},
			false
		);
	}
	if ($('link_previous') != undefined) {
		Event.observe(
			'link_previous',
			'click',
			function() {
				try {
					stopSlideshow();
				} catch(e) {}
			},
			false
		);
	}
	if ($('link_next') != undefined) {
		Event.observe(
			'link_next',
			'click',
			function() {
				try {
					stopSlideshow();
				} catch(e) {}
			},
			false
		);
	}
	if ($('link_cross') != undefined) {
		Event.observe(
			'link_cross',
			'click',
			function() {
				try {
					stopSlideshow();
				} catch(e) {}
				renderContent('index.php?action=home');
			},
			false
		);
		Event.observe(
			'link_cross',
			'mouseover',
			function(event) {
				$('link_cross').innerHTML = '<img align="left" title="" alt="" src="img/cross_highlight.gif"/>';
				$('hover_navigation').style.left = Event.pointerX(event)-$('container').viewportOffset().left+"px";
				$('hover_navigation').style.top = Event.pointerY(event)-$('container').viewportOffset().top+"px";
				$('hover_navigation').show();
			},
			false
		);
	}
	if ($('link_help') != undefined) {
		Event.observe(
			'link_help',
			'mouseover',
			function(event) {
				$('help_container_hoverbar').show();
				$('help_container_images').show();
				$('help_container_controls').show();
				$('help_container_slideshow').show();
				$('link_cross').innerHTML = '<img align="left" title="" alt="" src="img/cross_highlight.gif"/>';
				$('link_previous').innerHTML = '<img align="left" title="" alt="" src="img/previous_highlight.gif"/>';
				$('link_next').innerHTML = '<img align="left" title="" alt="" src="img/next_highlight.gif"/>';
				pageCount = $('page_count').innerHTML; 
				$('page_count').innerHTML = '<span style="color:#33ff00">start</span>';
			},
			false
		);
		Event.observe(
			'link_help',
			'mouseout',
			function() {
				$('help_container_hoverbar').hide();
				$('help_container_images').hide();
				$('help_container_controls').hide();
				$('help_container_slideshow').hide();
				$('link_cross').innerHTML = '<img align="left" title="" alt="" src="img/cross.gif"/>';
				$('link_previous').innerHTML = '<img align="left" title="" alt="" src="img/previous.gif"/>';
				$('link_next').innerHTML = '<img align="left" title="" alt="" src="img/next.gif"/>';
				$('page_count').innerHTML = pageCount;
			},
			false
		);
	}
	if ($('hover_navigation') != undefined) {
		Event.observe(
			'body',
			'click',
			function() {
				$('hover_navigation').hide();
				$('link_cross').innerHTML = '<img align="left" title="" alt="" src="img/cross.gif"/>';
			},
			false
		);
		Event.observe(
			'hover_navigation',
			'mouseout',
			function(event) {
				var boxX1 = parseInt($('hover_navigation').viewportOffset().left);
				var boxY1 = parseInt($('hover_navigation').viewportOffset().top);
				var boxX2 = boxX1 + parseInt($('hover_navigation').getWidth());
				var boxY2 = boxY1 + parseInt($('hover_navigation').getHeight());
				var mouseX = parseInt(Event.pointerX(event));
				var mouseY = parseInt(Event.pointerY(event));
				
				//alert('boxX1:'+boxX1+'\nboxY1:'+boxY1+'\nboxX2:'+boxX2+'\nboxY2:'+boxY2+'\nmouseX:'+mouseX+'\nmouseY'+mouseY);
				
				if (mouseX < boxX1+1 &&
					mouseY < boxY1+1 &&
					mouseX > boxX2-1 &&
					mouseY > boxY2-1) {
					alert('cought');
					$('hover_navigation').hide();
				}
			},
			false
		);
	}
	if ($('link_slideshow') != undefined) {
		Event.observe(
			'link_slideshow',
			'click',
			function() {
				if (slideshow_started) {
					stopSlideshow();
				} else {
					startSlideshow(image_id);
				}
			},
			false
		);
	}
	if ($('link_nature') != undefined) {
		Event.observe(
			'link_nature',
			'click',
			function() {
				try {
					stopSlideshow();
				} catch(e) {}
				renderContent('index.php?action=gallery&category=nature');
			},
			false
		);
	}
	if ($('link_people') != undefined) {
		Event.observe(
			'link_people',
			'click',
			function() {
				try {
					stopSlideshow();
				} catch(e) {}
				renderContent('index.php?action=gallery&category=people');
			},
			false
		);
	}
	if ($('link_travel') != undefined) {
		Event.observe(
			'link_travel',
			'click',
			function() {
				try {
					stopSlideshow();
				} catch(e) {}
				renderContent('index.php?action=gallery&category=travel');
			},
			false
		);
	}
	if ($('link_abstract') != undefined) {
		Event.observe(
			'link_abstract',
			'click',
			function() {
				try {
					stopSlideshow();
				} catch(e) {}
				renderContent('index.php?action=gallery&category=abstract');
			},
			false
		);
	}
	if ($('link_moments') != undefined) {
		Event.observe(
			'link_moments',
			'click',
			function() {
				try {
					stopSlideshow();
				} catch(e) {}
				renderContent('index.php?action=gallery&category=moments');
			},
			false
		);
	}
	if ($('link_imprint') != undefined) {
		Event.observe(
			'link_imprint',
			'click',
			function() {
				try {
					stopSlideshow();
				} catch(e) {}
				renderContent('index.php?action=imprint');
			},
			false
		);
	}
	if ($('link_contact') != undefined) {
		Event.observe(
			'link_contact',
			'click',
			function() {
				try {
					stopSlideshow();
				} catch(e) {}
				renderContent('index.php?action=contact');
			},
			false
		);
	}
	if ($('link_home') != undefined) {
		Event.observe(
			'link_home',
			'click',
			function() {
				try {
					stopSlideshow();
				} catch(e) {}
				renderContent('index.php?action=home');
			},
			false
		);
	}
	if ($('link_start') != undefined) {
		Event.observe(
			'link_start',
			'click',
			function() {
				try {
					stopSlideshow();
				} catch(e) {}
				renderContent('index.php?action=start');
			},
			false
		);
	}
	if ($('page_count') != undefined && image_id != undefined) {
		Event.observe(
			'page_count',
			'click',
			function() {
				if (slideshow_started) {
					stopSlideshow();
				} else {
					startSlideshow(image_id);
				}
			},
			false
		);
		Event.observe(
			'page_count',
			'mouseover',
			function(event) {
				pageCount = $('page_count').innerHTML; 
				if (slideshow_started) {
					$('page_count').innerHTML = 'end';
				} else {
					$('page_count').innerHTML = 'start';
				}
			},
			false
		);
		Event.observe(
			'page_count',
			'mouseout',
			function() {
				$('page_count').innerHTML = pageCount;
			},
			false
		);
	}
	if ($('contact_ben') != undefined) {
		Event.observe(
			'contact_ben',
			'mouseover',
			function(event) {
				$('contact_ben').innerHTML = '';
			},
			false
		);
		Event.observe(
			'contact_ben',
			'mouseout',
			function(event) {
				$('contact_ben').innerHTML = '<img src="img/ben_foto.jpg" alt="Ben" title="Ben" />';
			},
			false
		);
	}
	if ($('contact_isa') != undefined) {
		Event.observe(
			'contact_isa',
			'mouseover',
			function(event) {
				$('contact_isa').innerHTML = '';
			},
			false
		);
		Event.observe(
			'contact_isa',
			'mouseout',
			function(event) {
				$('contact_isa').innerHTML = '<img src="img/isa_foto.jpg" alt="Isa" title="Isa" />';
			},
			false
		);
	}
}
