/*
 * jQuery Plugin : jConfirmAction
 * 
 * by Hidayat Sagita
 * http://www.webstuffshare.com
 * Licensed Under GPL version 2 license.
 *
 */
(function($){

	jQuery.fn.jConfirmAction = function (options) {
		
		var theOptions = jQuery.extend ({ question: "Are You Sure ?", yesAnswer: "Yes", cancelAnswer: "Cancel" }, options);
		
		return this.each (function () {
			
			$(this).bind('click', function(e) {

				e.preventDefault();
				
				if($(this).next('.question').length <= 0)
					$(this).after('<div class="question">'+theOptions.question+'<br/><span class="yes">'+theOptions.yesAnswer+'</span><span class="cancel">'+theOptions.cancelAnswer+'</span></div>');
				
				$(this).next('.question').animate({opacity: 1}, 300);
				
				$('.yes').bind('click', function() {
					document.getElementById('reg_form').submit();
				});
		
				$('.cancel').bind('click', function() {
					$(this).parents('.question').fadeOut(300, function() {
						$(this).remove();
					});
				});
			});
		});
	}
})(jQuery);
