/*
	Javascript code for videowall
*/

function reloadVideo () {

	// JQuery Timer Plugin Error
	jQuery(document).ready(function($) {
	
		$.timer(videoReload, function (timer) {
		
			$('#videowall').load(videoScriptPath + '?videoCount=' + videoCount);	
			timer.reset(videoReload);
			
			//alert(videoScriptPath + '?videoCount=' + videoCount);
		});
	});
}

function displayvideo (video_id) {

	jQuery(document).ready(function($) {
	
		$('#videowallcurtain').fadeTo(0,0);
		$('#videowallcurtain').height($('#videowall').height());
		$('#videowallcurtain').fadeTo('normal', 0.7, function () { 
	
			$("#videowallcurtain").click(closevideo);

			$('#videoplayer').fadeTo('fast', 1, function () {
	
				var swf_id = 'vimeoplayer';
				flashembed('videoplayer',{
					src: 'http://www.youtube.com/v/' + video_id + '?autoplay=1&rel=0&border=0&fs=0&enablejsapi=1',
					id: swf_id,
			 		name: swf_id,
			 		width: 504,
			 		height: 340,
					quality: 'high',
					wmode: 'transparent',
			 		swLiveConnect: true,
			 		allowScriptAccess: 'always'
				});
			});
		});
	});
}

function onYouTubePlayerReady(playerId) {

	ytplayer = document.getElementById("vimeoplayer");
  	ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
}

function onytplayerStateChange(newState) {
   
   if (newState == 0) closevideo();
}

function closevideo () {

	jQuery(document).ready(function($) {

		$('#videoplayer').fadeTo('fast', 0, function () {
	
			$('#videoplayer').html('');
		});
	
		$('#videowallcurtain').fadeTo('fast', 0, function () {
	
			$('#videowallcurtain').height(0);
		});
	});
}