// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
$(document).ready(function(){
	if( $('.expander').length > 0 )
	{	
		$('.expander').toggle(function(){
			target = $(this).attr("rel");
			$("#" + target).attr("style", "height: 500px");
			$(this).html("compress textbox");
			return false;
		}, function(){
			$("#" + target).attr("style", "height: 200px");
			$(this).html("expand textbox");
			return false;
		});
	}
	if( $("#review_review").length > 0 )
	{
		$("#review_review").keyup(function()
		{
			$(this).checkReviewLength();
		});
		$(this).checkReviewLength();	
	}
});

jQuery.fn.checkReviewLength = function()
{
	size = $("#review_review").val();
	size = 250-size.length;
	read = "(" + size + " remaining)";
	$(".review_length").html(read);
	if(size < 0) {
		$("#review_submit").attr("disabled", "disabled");
		$("#review_submit").addClass("disabled");
	} else {
		$("#review_submit").removeAttr("disabled");
		$("#review_submit").removeClass("disabled");
	}
}
