window.addEvent('domready', function() {
	var c_element = $('teaser');
	var div1 = $('teaser').setStyles({opacity: 0});
	var div2 = $('more').setStyles({opacity: 0});
	var nr_fns = $('nr_fns').value;
	var showmore_exists = $('sm_exists').value;
	var langmenu_exists = $('lm_exists').value;
	
	var teaser_full = '0.90'; // '0.88';
	var teaser_more = '0.75';
	var teaser_half = '0.40';
	var teaser_leer = '0.00';
	var more_full = '0.93';
	var more_half = '0.65';
	var more_leer = '0.00';
	
	// var drag_more = new Drag('more');

	// Create a morph instance for content-div at startup
	var morph_site_in = new Fx.Morph('teaser', {duration: 1500, link: 'chain'});
	var morph_teas_slow = new Fx.Morph('teaser', {duration: 600, link: 'chain'});
	var morph_more_slow = new Fx.Morph('more', {duration: 600, link: 'chain'});
	var morph_teas_fast = new Fx.Morph('teaser', {duration: 100, link: 'chain'});
	var morph_more_fast = new Fx.Morph('more', {duration: 100, link: 'chain'});
	var morph_remember = new Fx.Morph('remthis_box', {duration: 100, link: 'chain'});
	var morph_footnotes = new Fx.Morph('footnotes_box', {duration: 100, link: 'chain'});

	var morph_footnote_1 = new Fx.Morph('footnotes_box_1', {duration: 100, link: 'chain'});
	var morph_footnote_2 = new Fx.Morph('footnotes_box_2', {duration: 100, link: 'chain'});
	var morph_footnote_3 = new Fx.Morph('footnotes_box_3', {duration: 100, link: 'chain'});
	var morph_footnote_4 = new Fx.Morph('footnotes_box_4', {duration: 100, link: 'chain'});
	var morph_footnote_5 = new Fx.Morph('footnotes_box_5', {duration: 100, link: 'chain'});
	var morph_footnote_6 = new Fx.Morph('footnotes_box_6', {duration: 100, link: 'chain'});

	var morph_langmenu = new Fx.Morph('lang_list', {duration: 100, link: 'chain'});

	morph_site_in.start({opacity: teaser_full});

	if(langmenu_exists){
		$('lang_selector').addEvent('click', function(e) {
			e.stop();
			morph_langmenu.start({opacity: '1.00'}).start({display: 'inline'});
		});
		$('lang_menu_clos').addEvent('click', function(e) {
			e.stop();
			morph_langmenu.start({opacity: '0.00'}).start({display: 'none'});
		});
	};
	
	if(showmore_exists){
		$('show_more').addEvent('click', function(e) {
			e.stop();
			morph_teas_slow.start({opacity: teaser_more});
			morph_more_slow.start({display: 'inline', opacity: more_full});
		});
		$('hide_more').addEvent('click', function(e) {
			e.stop();
			morph_more_slow.start({opacity: more_leer}).start({display: 'none'});
			morph_teas_slow.start({opacity: teaser_full});
		});
	
		$('remthis_ico').addEvent('mouseover', function(e) {
			e.stop();
			morph_remember.start({opacity: '1.00'}).start({display: 'inline'});
			morph_more_fast.start({opacity: more_half});
			morph_teas_fast.start({opacity: teaser_half});
		});
		$('remthis_ico').addEvent('mouseout', function(e) {
			e.stop();
			morph_remember.start({opacity: '0.00'}).start({display: 'none'});
			morph_more_fast.start({opacity: more_full});
			morph_teas_fast.start({opacity: teaser_more});
		});
	};

//	for(x=1;x<=nr_fns;x++){
//		fn_element = 'fn_' + x;
//		$(fn_element).addEvent('mouseover', function(e) {
//			e.stop();
//			morph_footnotes.start({opacity: '1.00'}).start({display: 'inline'});
//		});
//		$(fn_element).addEvent('mouseout', function(e) {
//			e.stop();
//			morph_footnotes.start({opacity: '0.00'}).start({display: 'none'});
//		});
//	};
	
	if (nr_fns >= 1){
		$('fn_1').addEvent('mouseover', function(e) {
			e.stop();
			morph_footnote_1.start({opacity: '1.00'}).start({display: 'inline'});
		});
		$('fn_1').addEvent('mouseout', function(e) {
			e.stop();
			morph_footnote_1.start({opacity: '0.00'}).start({display: 'none'});
		});
	};
	if (nr_fns >= 2){
		$('fn_2').addEvent('mouseover', function(e) {
			e.stop();
			morph_footnote_2.start({opacity: '1.00'}).start({display: 'inline'});
		});
		$('fn_2').addEvent('mouseout', function(e) {
			e.stop();
			morph_footnote_2.start({opacity: '0.00'}).start({display: 'none'});
		});
	};
	if (nr_fns >= 3){
		$('fn_3').addEvent('mouseover', function(e) {
			e.stop();
			morph_footnote_3.start({opacity: '1.00'}).start({display: 'inline'});
		});
		$('fn_3').addEvent('mouseout', function(e) {
			e.stop();
			morph_footnote_3.start({opacity: '0.00'}).start({display: 'none'});
		});
	};
	if (nr_fns >= 4){
		$('fn_4').addEvent('mouseover', function(e) {
			e.stop();
			morph_footnote_4.start({opacity: '1.00'}).start({display: 'inline'});
		});
		$('fn_4').addEvent('mouseout', function(e) {
			e.stop();
			morph_footnote_4.start({opacity: '0.00'}).start({display: 'none'});
		});
	};
	if (nr_fns >= 5){
		$('fn_5').addEvent('mouseover', function(e) {
			e.stop();
			morph_footnote_5.start({opacity: '1.00'}).start({display: 'inline'});
		});
		$('fn_5').addEvent('mouseout', function(e) {
			e.stop();
			morph_footnote_5.start({opacity: '0.00'}).start({display: 'none'});
		});
	};
	if (nr_fns >= 6){
		$('fn_6').addEvent('mouseover', function(e) {
			e.stop();
			morph_footnote_6.start({opacity: '1.00'}).start({display: 'inline'});
		});
		$('fn_6').addEvent('mouseout', function(e) {
			e.stop();
			morph_footnote_6.start({opacity: '0.00'}).start({display: 'none'});
		});
	};
	
});
