/*****************************************************************************************
	
	Script	:	play media
	Desc	:	play media like youtube when clicked on a thumbnail image
	Author	: 	Reinhold Becze
	
*****************************************************************************************/

function playMedia() {
	var thumb = $('thumbnail');
	var clip = $('clip');
	var playButton = $$('.playButton');

	playButton[0].addEvents({
		'mouseenter': function(){
			thumb.fireEvent('mouseenter');
		},

		'mouseleave': function(){
			thumb.fireEvent('mouseleave');
		},

		'click': function(){
			thumb.fireEvent('click');
		}
	});
	
	thumb.addEvents({
		'mouseenter': function(){
			playButton[0].setStyle('background-position', '-170px 0');
		},

		'mouseleave': function(){
			playButton[0].setStyle('background-position', '0 0');
		},

		'click': function(){
			playButton[0].setStyle('display', 'none');
			thumb.setStyle('display', 'none');
			clip.setStyle('display', 'block');
			flowplayer( 
        "div.mainflvplayer",  
        "./swf/flowplayer-3.2.0.swf", 
        {
         	playlist: [
        	{
        		url: './videos/skunkfu-kenntz-etz-mi.mp4',
        		autoPlay: true, 
            autoBuffering: false,
            scaling: 'scale'
        	}
        	],
        	"plugins":{
						"controls":{
							"url": './swf/flowplayer.controls-3.2.0.swf',
							"name":"controls",
							
							"play":true,
							"stop":false,
							"slowForward":false,
							"slowBackward":false,
							"fastForward":false,
							"fastBackward":false,
							"scrubber":true,							
							"time":true,
							"mute":true,
							"volume":true,
							"playlist":false,
							"fullscreen":true,
							"builtIn":false,
							
							"width":"100pct",
							"height":24,
							"left":"50pct",
							"bottom":0,
							"border":"0px",
							"borderWidth":0,
							"borderRadius":0,
							// different to other player
							"backgroundColor":"rgba(0, 0, 0, 0.7)",
							"backgroundGradient":[0.5,0.2,0],
							"opacity":1,
							"zIndex":1,
							"display":"block",
							// different to other player
							"autoHide":{"enabled":true,"hideDelay":2000,"mouseOutDelay":500,"hideStyle":"fade","hideDuration":800,"fullscreenOnly":false},
							
							"buttonColor":"rgba(255, 255, 255, 0.6)",
							"buttonOverColor":"#ffffff",													
							
							"sliderColor":"#000000",
							"sliderGradient":"none",
							"sliderBorder":"1px solid rgba(128, 128, 128, 0.7)",
							"progressColor":"#4599ff",
							"progressGradient":"none",
							"bufferColor":"#a3a3a3",
							"bufferGradient":"none",
							"scrubberHeightRatio":0.6,
							"scrubberBarHeightRatio":0.2,							
							
							"timeFontSize":12,
							"timeSeparator":" /",
							"timeColor":"#ffffff",
							"timeBgColor":"rgb(0, 0, 0, 0)",
							"durationColor":"#b8d9ff",							
							"timeBorder":"0px solid rgba(0, 0, 0, 0.3)",
							"timeBorderRadius":20,							
							"timeBgHeightRatio":1.2,							
							
							"volumeColor":"#4599ff",
							"volumeSliderColor":"rgba(0, 0, 0, 1)",
							"volumeSliderGradient":"none",
							"volumeBorder":"1px solid rgba(128, 128, 128, 0.7)",
							"volumeSliderHeightRatio":0.4,
							"volumeBarHeightRatio":0.8,			
										
							"tooltips":{"marginBottom":5,"volume":true,"scrubber":true,"buttons":true},
							"tooltipColor":"rgba(0, 0, 0, 0.5)",
							"tooltipTextColor":"#ffffff"				
						}
					}
        }
    	);
		}
	});
	
	
	var newsclip = $$('.newsflvplayer');
	
	newsclip.each(function(el,i){
		el.addEvents({
			'mouseenter': function(){
				el.getElement('.newsPlayButton').setStyle('background-position', '-170px 0');
			},
	
			'mouseleave': function(){
				el.getElement('.newsPlayButton').setStyle('background-position', '0 0');
			}
		});
	});
	
	flowplayer(
		"a.newsflvplayer",  
		{src: "./swf/flowplayer-3.2.0.swf", wmode: 'transparent'},  
		{
	  	clip:{
		   		autoPlay: true, 
		      autoBuffering: false,
		      scaling: 'scale'
		  },
			plugins:{
				controls:{
					"url": './swf/flowplayer.controls-3.2.0.swf',
					"name":"controls",
					
					"play":true,
					"stop":false,
					"slowForward":false,
					"slowBackward":false,
					"fastForward":false,
					"fastBackward":false,
					"scrubber":true,							
					"time":true,
					"mute":true,
					"volume":true,
					"playlist":false,
					"fullscreen":true,
					"builtIn":false,
			
					"width":"100pct",
					"height":24,
					"left":"50pct",
					"bottom":0,
					"border":"0px",
					"borderWidth":0,
					"borderRadius":0,
					"backgroundColor":"rgba(0, 0, 0, 1)",
					"backgroundGradient":[0.5,0.2,0],
					"opacity":1,
					"zIndex":1,
					"display":"block",
					"autoHide":{"enabled":true,"hideDelay":2000,"mouseOutDelay":500,"hideStyle":"fade","hideDuration":800,"fullscreenOnly":true},
					
					"buttonColor":"rgba(255, 255, 255, 0.6)",
					"buttonOverColor":"#ffffff",
			
					"sliderColor":"#000000",
					"sliderGradient":"none",
					"sliderBorder":"1px solid rgba(128, 128, 128, 0.7)",
					"progressColor":"#4599ff",
					"progressGradient":"none",
					"bufferColor":"#a3a3a3",
					"bufferGradient":"none",
					"scrubberHeightRatio":0.6,
					"scrubberBarHeightRatio":0.2,							
					
					"timeFontSize":12,
					"timeSeparator":" /",
					"timeColor":"#ffffff",
					"timeBgColor":"rgb(0, 0, 0, 0)",
					"durationColor":"#b8d9ff",							
					"timeBorder":"0px solid rgba(0, 0, 0, 0.3)",
					"timeBorderRadius":20,							
					"timeBgHeightRatio":1.2,
				
					"volumeColor":"#4599ff",
					"volumeSliderColor":"rgba(0, 0, 0, 1)",
					"volumeSliderGradient":"none",
					"volumeBorder":"1px solid rgba(128, 128, 128, 0.7)",
					"volumeSliderHeightRatio":0.4,
					"volumeBarHeightRatio":0.8,			
								
					"tooltips":{"marginBottom":5,"volume":true,"scrubber":true,"buttons":true},
					"tooltipColor":"rgba(0, 0, 0, 0.5)",
					"tooltipTextColor":"#ffffff"
				}
			}
		}
	);
}

