function ping_video(file) {
	function ping() {
		var req = new Request({
			url: "/it/mcheck/ping",
			method: "post",
			data: "fname=" + file
		}).send();
	}	

	document.video_ping = setInterval(ping, 60000);	
}

function show_wait_message() {
	$('VideoBox').setStyle('visibility', 'hidden');
	$('WaitMessage').setStyle('visibility', 'visible');
}

function hide_wait_message() {
	$('VideoBox').setStyle('visibility', 'visible');
	$('WaitMessage').setStyle('visibility', 'hidden');
}

var colore1 = '#735F5A';
var colore2 = '#CEB3B2';	

var play_video = function (file) {
	var fname = file.split("/").pop();
	if (!fname || file == "novideo") {
		$("player").innerHTML = $("WaitMessage").innerHTML;
		return
	}

	flowplayer('player', {
		'src': "/Scripts/flowplayer/flowplayer.commercial-3.2.7.swf",
		'wmode'	:	'opaque'
	},
	{
		'key' : '#@0b740f51dd8051c7ba9',
		"clip" : {
			'scaling': 'fit',
			"url" : file
		},
	
		"play" : {
			//'url'			:	'/themes/default_sm/images/play.png',
			'opacity'		:	0.9,
			'label'			:	null,
			'replayLabel'	:	'Play again',
			'fadeSpeed'		:	500,
			'rotateSpeed'	:	50,
			'width'			:	46,
			'height'		:	46
		},
		"screen" : {
			'height'	:	'100pct',
			'top'		:	0
		},
		"canvas" : {
			'background'			:	'#000000',
			'backgroundGradient'	:	'none'
		},
		"plugins" : {
			"controls" : {
				'borderRadius'				:	'0px',
				'timeColor'					:	colore1,
				'bufferGradient'			:	'none',
				'zIndex'					:	1,
				'sliderColor'				:	colore1,
				'backgroundColor'			:	'rgba(0, 0, 0, 0)',
				'scrubberHeightRatio'		:	0.6,
				'volumeSliderGradient'		:	'none',
				'tooltipTextColor'			:	'#ffffff',
				'spacing' : {
					'time'	:	6,
					'volume':	8,
					'all'	:	2
				},
				'sliderGradient'			:	'none',
				'timeBorderRadius'			:	20,
				'timeBgHeightRatio'			:	0.8,
				'volumeSliderHeightRatio'	:	0.6,
				'progressGradient'			:	'none',
				'height'					:	26,
				'volumeColor'				:	'rgba(204, 204, 204, 1)',
				'tooltips' : {
					'marginBottom'	:	5,
					'buttons'		:	false
				},
				'timeSeparator'				:	' ',
				'name'						:	'controls',
				'volumeBarHeightRatio'		:	0.2,
				'opacity'					:	1,
				'left'						:	'50pct',
				'timeFontSize'				:	12,
				'tooltipColor'				:	colore1,
				'border'					:	'0px',
				'volumeSliderColor'			:	colore1,
				'bufferColor'				:	'#a3a3a3',
				'buttonColor'				:	colore1,
				'durationColor'				:	colore1,
				'autoHide' : {
					'enabled'		:	true,
					'hideDelay'		:	500,
					'mouseOutDelay'	:	500,
					'hideStyle'		:	'fade',
					'hideDuration'	:	400,
					'fullscreenOnly':	false
				},
				'backgroundGradient'		:	'none',
				'width'						:	'100pct',
				'display'					:	'block',
				'sliderBorder'				:	'1px solid rgba(128, 128, 128, 0.7)',
				'buttonOverColor'			:	'#ffffff',
				'progressColor'				:	colore1,
				'timeBorder'				:	'0px solid rgba(0, 0, 0, 0.3)',
				'timeBgColor'				:	'rgb(0, 0, 0, 0)',
				'borderWidth'				:	0,
				'scrubberBarHeightRatio'	:	0.2,
				'bottom'					:	0,
				'volumeBorder'				:	'1px solid rgba(128, 128, 128, 0.7)',
				'builtIn'					:	false,
				'margins'					:	[2,12,2,12]
			}
		}
	}).ipad();
	ping_video(file)
};

window.addEvent("domready", function() {
	var id_video = $("video_num").value;
	var hidden_video = $("hidden_video_" + id_video);
	var	video_url = "";
	
	if (hidden_video) {
		video_url = hidden_video.value;

	} else {
		video_url = $("imgVideo_" + id_video).getParent("a[video_url]").getAttribute("video_url");
	}

	play_video(video_url);
});			

