$(document).ready(function() {
    $(".fancyvideo").click(function() {
		$.fancybox({
				'padding'		: 0,
				'autoScale'		: true,
				'transitionIn'	: 'fade',
				'speedIn'		: 1000,
				'speedOut'		: 1000,
				'transitionOut'	: 'fade',
				'width'			: 640,
				'height'		: 360,
				'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'onClosed'		: function(){setCurrentPage("start");},
				'swf'			: {
				   	 'wmode'		: 'transparent',
					'allowfullscreen'	: 'true'
				}
			});

		return false;
	});
});

function playVideo(videoID){
	$("#video_"+videoID).click();
}

var currentPage="start";

 function setCurrentPage(newPage) {
       currentPage = newPage;
	   //alert(newPage);
       SendDataToFlashMovie(newPage);
 }

function SendDataToFlashMovie(newPage){
    var flashMovie=getFlashMovieObject("banner");
    flashMovie.sendTextToFlash(newPage);
}

function getFlashMovieObject(movieName){
	if (window.document[movieName]){
		return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1){
		if (document.embeds && document.embeds[movieName])
			return document.embeds[movieName];
	}
	else{
		return document.getElementById(movieName);
	}
}


