
window.addEvent('domready', function() {

	// ///////////////////////////
	//  STUDY CONTAINER ANIMATION
	// ///////////////////////////
	
	var study_status = 'close';

	var effectStudy = new Fx.Morph('study_container');
	 
	$('ss_headline').addEvent('click',
			function(e) {
				e.stop();
				if (study_status=="open") {
					effectStudy.start({
						'margin-top': [-173, -22], // from to
						'height': [180, 29]});
					study_status = "closed";
				} else {
					effectStudy.start({
						'margin-top': [-22, -173],
						'height': [29, 180]});
					study_status = "open";
				}
	});

	
	// ///////////////////////////
	//  MEDIA CONTAINER ANIMATION
	// ///////////////////////////
	
	var media_status = 'close';
	
	var effectMedia = new Fx.Morph('media_container');


	$('mc_logo').addEvent('click', 
			function(e){
				e.stop();
				// alert(e.client.x +"-"+e.page.x );
				if (media_status=="open") {
					effectMedia.start({
						'margin-left': [-220, 0],
						'width': [249, 29]});
					media_status = "closed";

				} else {
					effectMedia.start({
						'margin-left': [0, -220],
						'width': [29, 249]});
					media_status = "open";
				}
	});
	

	// /////////////////////////////
	//  FIX LINKS AND AJAX LOADING
	// /////////////////////////////
	// FIX:	select all mc_entry and _last to override the above action and open the links as planned
	// UDPATE: and now use the links to load the data into the display div AJAX-style 
	$$('.mc_entry, .mc_entry_last').each(function(el){
		// link animation, turned off
		// var fx = new Fx.Morph(el,{ duration:300, link:'cancel' });
		el.addEvents({
			//	'mouseenter': function() { fx.start({ 'padding-left': 20 }); },
			//	'mouseleave': function() { fx.start({ 'padding-left': 0 }); }
			'click' : function(event) {
				event.stop();
				// LOAD WINDOW
				window.location=this.href;
			
//				// AJAX LOADING
//		        // make the ajax call, replace text
//		        var req = new Request.JSON({
//		            url: this.get('href'),
//		            onRequest: function() { 
//		            	$('mm_middle').setStyle('color','#ddd');
//		            	// alert('Request made. Please wait...');
//		            	},
//		            onComplete: function(responseJSON) {
//		            	$('mm_middle').setStyle('color','#000');
//		            	$('headline_h1').set('html',responseJSON.headline);
//		            	$('mm_middle').set(  'html',responseJSON.articletext);
//		            	}
//		        }).send();
			}
		});
	});



	
	// ////////////////////
	//  SLIDE THE STUDIES
	// ////////////////////
	// var handles8_more = $$('#handles8_more span');
	var nS8 = new noobSlide({
		box: $('ss_content'),
		// also only for setting links to headline text
		items: $$('#ss_content h3'),
		size: 706,
		handles: $$('#ss_buttons a'),
		// addButtons: {previous: $('prev8'), play: $('play8'), stop: $('stop8'), playback: $('playback8'), next: $('next8') },
		addButtons: {},
		onWalk: function(currentItem,currentHandle){
			//style for handles
			// $$(this.handles,handles8_more).removeClass('active');
			// $$(currentHandle,handles8_more[this.currentIndex]).addClass('active');
			$$(this.handles).removeClass('active');
			$$(currentHandle).addClass('active');
			//text for "previous" and "next" default buttons
			// h2 text to button
			// $('prev8').set('html','&lt;&lt; '+this.items[this.previousIndex].innerHTML);
			// $('next8').set('html',this.items[this.nextIndex].innerHTML+' &gt;&gt;');
		}
	});
	//more "previous" and "next" buttons
	nS8.addActionButtons('previous',$$('#ss_content .prev'));
	nS8.addActionButtons('next',$$('#ss_content .next'));
	//more handle buttons
	// nS8.addHandleButtons(handles8_more);
	//walk to item 3 witouth fx
	nS8.walk(0,false,true);

	
	// //////////////////
	// IE6 HIGHLIGHT BUG
	// //////////////////
	// only links can hover in IE6, so we have to make the buttons for the study_slide links,
	// which now have to be disabled, otherwise we cant see the scrolling
	$$('#ss_buttons a, .buttons a').each(function(el){
		el.addEvents({
			'click' : function(event) {
				event.stop();
			}
		});
	});
	
	
});

 






