
function show_buy_error(price, money)
{
	$('.no_money_template .user_deposit_value').html(money);
	$('.no_money_template .movie_price').html(price);
	var newHtml = $('.no_money_template').html();

	$.fn.colorbox({
		html: newHtml,
		width: '500px',
		open: true
	});
	$('#cboxTopCenter').html('');
}

function buy_wmv_scene(movie_id, codec_id, price, form)
{
	$.ajax({
		url: 'ajax_buy_content.html?movie_id=' + movie_id + '&codec_id=' + codec_id,
		dataType: 'json',
		success: function (data)
		{
			if (data == null) return;

			if (data.status == 0)
			{
				show_buy_error(price, data.money);
			}
			else
			{
        			form.submit();
			}
		}
	});
	return false;
	
}

function ajax_buy_content(movie_id, codec_id, price, url)
{
	$.ajax({
		url: 'ajax_buy_content.html?movie_id=' + movie_id + '&codec_id=' + codec_id,
		dataType: 'json',
		success: function (data)
		{
			if (data == null) return;

			if (data.status == 0)
			{
				show_buy_error(price, data.money);
			}
			else
			{
        			window.location = url;
			}
		}
	});
	return false;
  
}

function show_flash_free_movie(filename)
{
	$.fn.colorbox({
		html: "<a id='flowplayer_free_movie' style='width: 100%; height: 100%; display: block;'></a>",
		width: '500px',
		height: '400px',
		open: true
	});
	$f(
		'flowplayer_free_movie',
		'/javascripts/flowplayer-3.1.5.swf',
		{
			clip:
			{
				scaling: 'orig',
				provider: 'rtmp',
				autoPlay: 'true',
				url: filename,
				connectionArgs: [true]
			},
			plugins:
			{
				rtmp:
				{
					url: '/javascripts/flowplayer.rtmp-3.1.3.swf',
					netConnectionUrl: 'rtmp://fms.blitzeis.com/free_movies'
				}
			}
		}
	);
	return false;
}

function show_flash_teaser(teaser_link, movie_link, movie_link_text)
{
	$.fn.colorbox({
		html: "<a id='flowplayer_trailer' style='width: 100%; height: 300px; display: block;'></a><div><div style='margin: 0 auto;' class='buttonrots'><a class='buttonredss' href='" + movie_link + "'>" + movie_link_text + "</a></div></div>",
		width: '500px',
		height: '400px',
		open: true
	});
	$f(
		'flowplayer_trailer',
		'/javascripts/flowplayer-3.1.5.swf',
		{
			clip:
			{
				scaling: 'orig',
				autoPlay: 'true',
				url: teaser_link
			}
		}
	);
	return false;
}

function show_flash_trailer(trailer_link)
{
	$.fn.colorbox({
		html: "<a id='flowplayer_trailer' style='width: 100%; height: 100%; display: block;'></a>",
		width: '500px',
		height: '400px',
		open: true
	});
	$f(
		'flowplayer_trailer',
		'/javascripts/flowplayer-3.1.5.swf',
		{
			clip:
			{
				scaling: 'orig',
				autoPlay: 'true',
				url: trailer_link
			}
		}
	);
	return false;
}

function show_flash_movie(movie_id, user_id, partner_id)
{
	$.ajax({
		url: 'ajax_flash_player.html?movie_id=' + movie_id,
		dataType: 'json',
		success: function (data)
		{
			if (data == null) return;

			if (data.status == 0)
			{
				show_buy_error(data.price, data.money);
			}
			else
			{
				$.fn.colorbox({
					html: "<a id='flowplayer_movie' style='width: 100%; height: 100%; display: block;'></a>",
					width: '500px',
					height: '400px',
					open: true
				});
				$f(
					'flowplayer_movie',
					'/javascripts/flowplayer-3.1.5.swf',
					{
						clip:
						{
							scaling: 'orig',
							provider: 'rtmp',
							autoPlay: 'true',
							url: data.filename,
							connectionArgs: [
								true,
								user_id,
								partner_id,
								data.content_id,
								data.token
							]
						},
						plugins:
						{
							rtmp:
							{
								url: '/javascripts/flowplayer.rtmp-3.1.3.swf',
								netConnectionUrl: 'rtmp://fms.blitzeis.com/movieon4'
							}
						}
					}
				);
			}
		}
	});
	return false;
}

