// Releases 

$(document).ready(function() {
		//Rating
		$(".rating_bar").hover(show_rating,hide_rating);
		//release info
		$(".show_release").hoverIntent(show_rel,hide_rel);
		//more info
		$(".more_info").bind("mouseover",show_info);
		$(".info").bind("mouseleave",hide_info);
		$(".close_info").live("click",hide_info);
		$("a.show_tooltip_plot").live("mouseover",show_plot);
		$("a.show_tooltip_plot").live("mouseout",hide_plot);
		
		$("a.show_tooltip_plot").live("click",function(){ return false;  });
		$(".inside-tab").click(openLinkbox);
		
		// Change synopsis :
		$("#synopsisChange").change(ChangeSynopsis);
		// Group By...
		$("#GroupByRel").change(ChangeGroupBy);
		
});


// Show rating bar.
function show_rating(evt){
	var ratingDiv=$(" .rating_results",this);
	$(ratingDiv).show();	
	
	var imdb_split=$(this).attr("id").split('_');
	
	$.get('http://www.nzbmovieseeker.com/sql/grab.rating.ajax.php',{ imdb: imdb_split[0],rating:imdb_split[1] }, function(data) {
		  $(ratingDiv).html(data);
		 
	});

	
	return false;
};


function hide_rating(evt){
	
		$(" .rating_results",this).hide();	
	
};


// Show rating
function show_rel(evt){
	
	var release_info=$(" .release_info",this);
	var release_ajax=$(" .release_ajax",release_info);
	
	var r_id=$(this).attr("id");
	// show them
	$(release_info).show();
	$(release_ajax).show();
	$.get('http://www.nzbmovieseeker.com/sql/grab.release.ajax.php',{ r_id: r_id }, function(data) {
		  $(release_ajax).html(data);
		 
	});
	return false;
};


function hide_rel(evt){
	
		var release_info=$(" .release_info",this);
	var release_ajax=$(" .release_ajax",release_info);
	
	// show them
	$(release_info).hide();
	$(release_ajax).hide();	
	
};

// show movie info
function show_info(evt){
	var imdb=$(this).attr("id");
	var movie_info=$(this).next('div');
	$(movie_info).show();
	$.get('http://www.nzbmovieseeker.com/sql/grab.more_info.ajax.php',{ imdb: imdb }, function(data) {
		  $(movie_info).html(data);
		 
	});
	return false;
	
};


// Hide info
function hide_info(evt){
	if($(this).attr('id')=="close_info"){
		$(this).parents('.more_info_movie').hide();
		
	}else{
	
		$(" .more_info_movie",this).hide();	
	}
	return false;
};

// show extra plot
 function show_plot(evt){
	if($(this).next(".tooltip_plot").length==0){
			$(this).parent().next(".tooltip_plot").show();	
		}else{
			$(this).next(".tooltip_plot").show();
		}
 };
 
  function hide_plot(evt){
	if($(this).next(".tooltip_plot").length==0){
			$(this).parent().next(".tooltip_plot").hide();	
		}else{
			$(this).next(".tooltip_plot").hide();
		}
 };
 
 // open menu box (left)
 function openLinkbox(evt){
	if($(this).next().attr("class")=="box-links"){
		//change sign.
		
		$(" img",this).attr("src",$(" img",this).attr("src").replace('plus','minus' ));
		$(this).next().attr("class","box-links-active");
	
		
	}else{
		
		$(" img",this).attr("src",$(" img",this).attr("src").replace('minus','plus' ));
		$(this).next().attr("class","box-links");

		
	}
	 
	 
 };
 
 // Change Synopsis 
 function ChangeSynopsis(evt){
		 
	acPlot	=$(this).val();
	
	// check vip
	if(acPlot!='imdb.com'){
		if(!vip){	
			open_vip('Only V.I.P. members are allowed change the default synopsis ');
			return false;
		
		}
		
	}
	
	// CHange synopsis session.
	$.get('http://www.nzbmovieseeker.com/sql/synopsis_sessions.php',{ plotSite: acPlot }, function(data) {
		
		location.reload();
		 
	});
	
	 
	 
	 return false;
 };
 
 
 // Change Synopsis 
 function ChangeSynopsis(evt){
		 
	acPlot	=$(this).val();
	
	// check vip
	if(acPlot!='imdb.com'){
		if(!vip){	
			open_vip('Only V.I.P. members are allowed change the default synopsis ');
			return false;
		
		}
		
	}
	
	// CHange synopsis session.
	$.get('http://www.nzbmovieseeker.com/sql/synopsis_sessions.php',{ plotSite: acPlot }, function(data) {
		
		location.reload();
		 
	});
	
	 
	 
	 return false;
 };
 
 
 //Change group by 
 function ChangeGroupBy(evt){
	 
	 acGroupBy=$(this).val();
	 
	 $.get('http://www.nzbmovieseeker.com/sql/groupBy_sessions.php',{ groupBy: acGroupBy }, function(data) {
		
		location.reload();
		 
	});
	
	 
	 return false;
	 
 };
