$(document).ready(function()
{
	if ($.utils.isiPhoneOriPod()) {
		$('a.flowplayer').each(function() {
			href = $(this).attr('href');
			href = href.substr(0, href.length - 3);
			href += 'm4v';
			$(this).attr('href', href);
		});
	}

	$('a.flowplayer').live('click', function() {
		
		if ($.utils.isiPhoneOriPod()) {
			return true;
		}
	
		var link = this;
		var href = $(this).attr('href');
		$(this).removeAttr('href');
		
		$.fancybox(this, {
			transitionIn: 'elastic',
			transitionOut: 'elastic',
			overlayShow: true,
			autoDimensions: false,
			autoScale: false,
			frameWidth: 640,
			frameHeight: 480,
			content: $('<div class="flowplayer-wrapper"><div class="flowplayer"></div></div>'),
			onComplete: function() {
				$(link).attr('href', href);			
				$('#fancybox-inner .flowplayer').flowplayer({ src: '/flash/flowplayer-3.1.5.swf', wmode: 'opaque' }, {
					clip: {
						autoPlay: true,
						bufferLength: 10,
						scaling: 'fit',
						url: href
					},
					canvas: {
						backgroundColor: '#000'
					},
					plugins: {
						controls: {
							url: '/flash/flowplayer.controls-3.1.5.swf',
							backgroundColor: '#000'
						}
					}
				});
			}
		});
		return false;
	});
});