//themis

Fx.Blend = new Class({

	Extends: Fx,

	options: {
		mode: 'vertical'
	},
	
	initialize: function(element, options){
		this.element = this.subject = $(element);
		this.element.setStyle('overflow', 'hidden');
		this.initHeight = this.element.offsetHeight;
		this.initWidth = this.element.offsetWidth;
		this.parent(options);
	},

	set: function(now){
		this.element.setStyle(this.layout, now);
		return this;
	},
	
	vertical: function(){
		this.layout = 'height';
		this.offset = this.initHeight;
	},

	horizontal: function(){
		this.layout = 'width';
		this.offset = this.initWidth;
	},

	start: function(how, mode){
		if (!this.check(arguments.callee, how, mode)) return this;
		this[mode || this.options.mode]();
		var layout  = this.element.getStyle(this.layout).toInt();
		var caseIn  = [layout, this.offset];
		var caseOut = [layout, 0];
		var start;
		switch (how){
			case 'in': start = caseIn; break;
			case 'out': start = caseOut; break;
		}
		return this.parent(start[0], start[1]);
	},

	blendIn: function(mode){
		return this.start('in', mode);
	},
	
	blendOut: function(mode){
		return this.start('out', mode);
	},

	hide: function(mode){
		this[mode || this.options.mode]();
		return this.set(0);
	}

});

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

	var duration = 1000;
	var trans = Fx.Transitions.Sine.easeOut;

	var secondLevelDivAnimated = $('secondLevelDivAnimated');
	var thirdLevelDivAnimated = $('thirdLevelDivAnimated');
	
	if($('newsandevents'))
	{
		var myAccordion = new Fx.Accordion($$('.row2009'), $$('.details2009'), {
		    display: accordionPosition,
		    alwaysHide: true
		});
	}
	
	if(secondLevelDivAnimated){
		secondLevelDivAnimated.setStyle('visibility', 'visible');
		new Fx.Blend(secondLevelDivAnimated, {duration: duration, transition: trans}).hide().blendIn();
	}
		
	if(thirdLevelDivAnimated){
		thirdLevelDivAnimated.setStyle('visibility', 'visible');
		new Fx.Blend(thirdLevelDivAnimated, {duration: duration, transition: trans}).hide().blendIn();
	}

	/*
	var secondLevelUls = $$('.secondLevelAnimated');
	var thirdLevelUls = $$('.thirdLevelAnimated');
	var blends = new Array();
	
	if(secondLevelUls){
		
		secondLevelUls.each(function(item, index){
			blends[blends.length] = new Fx.Blend(item, {duration: duration, transition: trans}).hide();
		}); 
	}
	
	if(thirdLevelUls){
		
		thirdLevelUls.each(function(item, index){
			blends[blends.length] = new Fx.Blend(item, {duration: duration, transition: trans}).hide();
		}); 
	}
	
	blends.each(function(item, index){
		item.chain(function(){
			(function() {
				if(blends[index+1]){
					blends[index+1].blendIn();
				}
			}).delay(50);
		});
	});
	(function(){blends[0].blendIn()}).delay(50);
	*/
});



//var hManager = null; //History Manager


function updateNav(el){
	$$('#aktie_navi a').each(function(item, index){
    		item.className='';
	});
	el.className='active';
}


// AJAX Funktion mit Fade-Out / Fade-In für die Charts
function callAJAX(image, sprache) {

	var url = "index.php?article_id=83&image=" + image + "&clang=" + sprache;
        
	new Fx.Tween('aktieWrapper',{
			onComplete: function(){

				new Request.HTML({
					method: 'get',
					update: $('aktieWrapper'),
					url: url,
					onSuccess: function(responseText, responseXML){
						//Shadowbox.init({ skipSetup: true }); Shadowbox.setup()
						new Fx.Tween('aktieWrapper').start('opacity', '0', '1');
					}
				}).send();			
			}
		}).start('opacity', '1', '0');

	return false;
}



// AJAX Funktion mit Fade-Out / Fade-In für die Sidebar
function changeSidebar(pageid, sprache) {
	

	var url = "index.php?article_id=94&pageid=" + pageid + "&clang=" + sprache;

	new Fx.Tween('spalte_1',
		{
			duration: 200,
			onComplete: function()
			{
				new Request.HTML(
					{
						method: 'get',
						update: $('spalte_1'),
						url: url,
						onSuccess: function(responseText, responseXML)
						{
							new Fx.Tween('spalte_1',
								{ 
									duration: 200 // Geschwindigkeit
								}
							).start('opacity', '0', '1');
						} 
					}
				).send();			
			} 
		}
	).start('opacity', '1', '0');

	return false;
}

var activeFlashId = '';
var activeFlash;

function showFlashVideo(sliceId, file, width, height){
	var flashLayer = $('flashplayer_'+sliceId);
	if(activeFlashId != '' && activeFlashId != flashLayer.id){
		$(activeFlashId).get('morph').start( { 'height': 0, 'padding-top': 0 } ).chain(
			function(){
				$(activeFlashId).set('html','');
			}
		);
	}
	if(activeFlashId != flashLayer.id){
		flashLayer.get('morph').start( { 'height': height, 'padding-top': 5 } ).chain(
			function(){
				activeFlash = new SWFObject('player_rtmp.swf','mpl',width,height,'9');
				activeFlash.addParam('allowScriptAccess','always');
				activeFlash.addParam('allowfullscreen','true');
				activeFlash.addVariable('autostart','true');
				activeFlash.addParam('wmode','transparent');
				activeFlash.addVariable('id','P00015');
				activeFlash.addVariable('file',file);
				activeFlash.addVariable('streamer','rtmp://flv.daf.tmt.de/vod/');
				activeFlashId = 'flashplayer_'+sliceId;
				activeFlash.write('flashplayer_'+sliceId);			
			}
		);
	}else{
		$(activeFlashId).get('morph').start( { 'height': 0, 'padding-top': 0 } ).chain(
			function(){
				$(activeFlashId).set('html','');
				activeFlashId = '';
				activeFlash = null;
			}
		);
	}
	return false;
}

window.addEvent('domready',
	function(){
		new Fx.Accordion($$('.header'),$$('.images'), {
			alwaysHide: true,
			display: -1
		});
	}
);