jQuery(document).ready(function() {
	/* Bytte film pŒ forside */
	
	
	
	var videolinks = jQuery('a.videolink');
	jQuery('a.videolink').click(function() {
		var me = $(this);
		var movie_object_href = me.attr('href').split('/');
		var movie_id = 'movie_' + movie_object_href[4];
		loadmovie(me.attr('href'));
		var movie_info = jQuery( '#' + movie_id ).html();
		jQuery(".feature-film-details-active").remove();
		jQuery('#video-flash-container' ).after('<div class="commercial-film-details feature-film-details-active">' + movie_info + '</div>');
		return false;
	});
	//videolinks.eq(0).click();
	
	/* Getting rights for one movie based upon country*/
	jQuery('.CountryListMovie').change(function() {
		var me = jQuery(this);
		var target = jQuery('#holder-'+me.attr('title'));
		var formfields = {
			'Country': me.val(),
			'MovieID': me.attr('title')
		};
		//loader.show('fast');
		target.fadeOut('fast', function() {
			target.addClass('holder-filled');
			jQuery.ajax({
				  type: 'post', 
				  url: '/rights/film_by_country/',
				  data: formfields,
				  success: function (data) {
					//target.hide();
					target.html(data).fadeIn('slow');
				} 
			});
		});
		
	});
	var loader = jQuery('#loader');
	jQuery('.MovieListCountry').change(function() {
		var me = jQuery(this);
		var formfields = {
			'Country': me.val()
		};
		var target = jQuery(me.attr('title'));
		loader.fadeIn('fast', function() {
			jQuery.ajax({
				  type: 'post', 
				  url: '/rights/film_list_by_country/',
				  data: formfields,
				  success: function(data) {
					target.hide('fast', function() {
						loader.fadeOut('fast', function(){
							target.html(data).slideDown();
						});
					});
					
				}
				});
		})
		
		
	});	
});
