/*
 *
 * Copyright (c) 2009 Doubleclique (dev [at] doubleclique [dot] com)
 * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license
 *
 */

/**
 *
 * jquery.dql.filtermenu
 *
 * @name     jquery.dql.filtermenu
 * @version  0.1
 * @author   Kyle Beattie (kyle [at] doubleclique [dot] com)
 * @requires jQuery
 *
 */
/*global jQuery */
"use strict";
(function ($) {

	$.fn.reviews = function (options) {

		var $this = $(this), priv = {}, publ = {};

		options = $.extend(
			{
				editButton : $('.edit'),
				editNote : $('#MyReviewEdit'),
				rating : $('#MyRating'),
				editRating : $('#Form_Rating'),
				note : $('#MyReview')
			},
			options
		);

		priv.init = function () {

			priv.notReviewed = $this.hasClass('notReviewed');

			//alert(priv.notReviewed);
			
			priv.addEventHandlers();

		};

		priv.addEventHandlers = function () {

			options.editButton.click(function (event) {

				event.preventDefault();

				options.note.hide();

				options.editNote.show();

				options.rating.hide();

				options.editRating.show();

				options.editNote.find('textarea').focus();

				$('#Cellar').animate({opacity : 0.6}, 500, "linear");
				
			});

//			$this.find('form').submit(function (event) {
//
//				if (!priv.notReviewed) {
//
//					event.preventDefault();
//
//					var $form = $(this);
//
//					var $submit = $form.find('input[type="submit"]');
//
//					$submit.blur();
//
//					$submit.parent().addClass('loading');
//
//					$.ajax({
//						url : $form.attr('action'),
//						success : function () {
//
//							options.note.show();
//
//							options.editNote.hide();
//
//							options.rating.show();
//
//							options.editRating.hide();
//
//							$('#Cellar').animate({opacity : 1}, 500, "linear");
//
//							$submit.parent().removeClass('loading');
//
//						}
//					});
//
//				}
//
//			});

		};

		priv.init();

		return publ;

	}

}(jQuery));
