/**
 * Review.js
 *	- functions to be used with recipe reviews
 **/
 
 $(document).ready(function(){
	var link;
	$('.review-link').each(function(){
		link = $(this).attr('href');
		$(this).attr('href',link.split('&redirect')[0]+'&format=ajax');
	});
	/*$('.review-link').colorbox({fixedWidth:'557',fixedHeight:'544',iframe:true}); */
	
	$('.review-link').click( function(e) {
		e.preventDefault();
		$.get($(this).attr('href'), function(data){
			$('#modalTemplate #modalContentArea').html(data);
			$('#modalTemplate').modal({
				opacity:48,
				overlayClose: false,
				zIndex: 2000
			});
		});
	});
 });
 
  /**
  * _close(); 	closes the sendto friend popup
  **/
  function Review_close(no_wait){
	if(no_wait) $('.simplemodal-close').click();
	else setTimeout("$('.simplemodal-close').click();",10000);
  }
  
  function approveReview(rec_num)	{
	  var content = $('#review-Content').val();
	  $('.simplemodal-close').click();
	  $.post( "/recipes/review", 
		  { RecipeNumber: rec_num, Content: content, format: "ajax" },
		  function(data) {
		  	$('#modalTemplate #modalContentArea').html(data);
		  	$('#modalTemplate').modal({
				opacity:48,
				overlayClose: false,
				zIndex: 2000
			});
	  	}
	  );  
  }

