/* CLIQUE */
/* Actions Pattern Javascript
----------------------------------------------------------------------------- */


	(function($) {

	$.fn.cliqueActions = function() {


/* PRESERVE CHAINING
----------------------------------------------------------------------------- */


		return this.each(function(index) {

			var $this = $(this);

/* REPLACE BUTTONS
----------------------------------------------------------------------------- */


			if ($this.attr('value') && $this.attr('value') != "Submit") {

				var language = $this.attr('value');

			} else if ($this.parent().parent().parent().hasClass('signin')) {

				var language = "Sign In";

			} else if ($this.parent().parent().parent().hasClass('password')) {

				var language = "Reset Password";

			} else {

				var language = "Submit";

			}

			$this.parent().addClass('submit');
			$this.after('<a class="action submit" href="#submit">' + language + '</a>');

            if ($this.parent().is('li')) {
                $this.parent().parent().addClass('replaced');
            } else {
                $this.parent().addClass('replaced');
            }


/* SUBMIT FORM
----------------------------------------------------------------------------- */

			$this.siblings('a.action.submit').bind('click.submit', function( e ){
				
				e.preventDefault();
				
				//$this.closest('form').submit();
				$this.click();
				$(this).unbind('click.submit');
				
			});


/* END PLUG-IN
----------------------------------------------------------------------------- */


		});
	};
	})(jQuery);
