/*
###############################################
#### ALL CONTENTS OF THIS FILE � WILL SKY  ####
#### WEB: WWW.WILLSKY.DE                   ####
#### E-MAIL: WEB@WILLSKY.DE				   ####
###############################################
*/

var shadowMorph;
var statusPlayback = 0;

window.addEvent('domready', function(){
	$('main-nav').getElements('a').each(function(el){
		el.addEvent('mouseenter', function(){
			var hover = el.getElement('img').get('src').replace('.png', '_hover.png'); 
			el.getElement('img').set('src', hover);
		});
		el.addEvent('mouseleave', function(){
			el.getElement('img').set('src', el.getElement('img').get('src').replace('_hover.png', '.png'));
		});
	});
});

function initGallery(){
	var imagesAr = $('galerie').getElement('.layout_fullsize').getElements('.image_container');
	imagesAr.each(function(el) {
		el.addEvent('mouseenter', function(){
			if(shadowMorph != null)
				shadowMorph.cancel();
			
			shadowMorph = new Fx.Morph(el, {
				duration: 350,
				transition: Fx.Transitions.Elastic.easeInOut
			});
			shadowMorph.start({
				'box-shadow': '0 0 15px #98bbdd',
				'-webkit-box-shadow': '0 0 15px #98bbdd',
				'-moz-box-shadow': '0 0 15px #98bbdd'
			});
		});
	});
}

function initNewsGallery(){
	var imagesAr = $('news-gallery').getElements('.image_container');
	imagesAr.each(function(el) {
		el.addEvent('mouseenter', function(){
			if(shadowMorph != null)
				shadowMorph.cancel();
			
			shadowMorph = new Fx.Morph(el, {
				duration: 350,
				transition: Fx.Transitions.Elastic.easeInOut
			});
			shadowMorph.start({
				'box-shadow': '0 0 15px #98bbdd',
				'-webkit-box-shadow': '0 0 15px #98bbdd',
				'-moz-box-shadow': '0 0 15px #98bbdd'
			});
		});
	});	
}

function togglePlayback(){
	if (Browser.Plugins.Flash){

		if (statusPlayback == 0){
			sendToNonverBlaster('play');
			statusPlayback = 1;
			piwikTracker.trackGoal(1); // logs a conversion for goal 1
		
			$('speaker-btn').set('src', $('speaker-btn').get('src').replace('play', 'stop'));
			$('speaker-btn').set('onmouseover', $('speaker-btn').get('onmouseover').replace('play', 'stop'));
			$('speaker-btn').set('onmouseout', $('speaker-btn').get('onmouseover').replace('_hover', ''));
		}else{
			sendToNonverBlaster('resetAll');
			statusPlayback = 0;
		
			$('speaker-btn').set('src', $('speaker-btn').get('src').replace('stop', 'play'));
			$('speaker-btn').set('onmouseover', $('speaker-btn').get('onmouseover').replace('stop', 'play'));
			$('speaker-btn').set('onmouseout', $('speaker-btn').get('onmouseover').replace('_hover', ''));
		}
	}else{
		if ($('song-download').get('src') == '')
			$('song-download').set('src', flashvars.mediaURL);
		else
			$('song-download').set('src', '');
	}	
}

function initSongDownload(){
	$('song-download').set('src', flashvars.mediaURL);
}

