$(function()
{
	$('#comment_saving,#leave_comment_autor_data').hide();
	$('#comment_comment').focus(function(e)
	{
		if($('#leave_comment_autor_data').css('display') == 'none')
			$('#leave_comment_autor_data').slideDown('fast');
	});
	$('#btn_comment_submit').sahFormValidator( {
		scope: '#frm_comment',
		/* messages */
		prefix: 'Field',
		msg_required: 'is required',
		msg_email: 'is not a valid e-mail adress',
		msg_div: '#comment_error',
		success: function()
		{
			$.ajax( {
				url: $.sah.ajaxUrl('Index', 'ajax_saveComment'),
				data: $('#frm_comment').serialize(),
				beforeSend: function()
				{
					$('#frm_comment input[type=button]').sahDisable();
					$('#comment_saving').show();
				},
				success: function(nCommentId, st)
				{
					if(nCommentId)
					{
						$('#comment_comment').val('');
						// alert('Tanks for your comment');
				$('#leave_comment_autor_data').slideUp('fast');
				
				/* Invocar handler si existe */
				if(comments_save_handler != undefined && $.isFunction(comments_save_handler))
					comments_save_handler();
			}
		},
		complete: function(Xhr, st)
		{
			$('#comment_saving').hide();
			$('#frm_comment input[type=button]').sahEnable();
		}
			});
		}
	});
	/*
	 * $('#btn_comment_close').click(function(e) {
	 * $('#cortina').fadeOut('fast'); $('#leave_comment').hide(); });
	 */
});

/*
 * function hideLeaveComment() { $('#cortina').fadeOut('fast');
 * $('#leave_comment').hide(); } function showLeaveComment() {
 * $('#cortina').sahExpand(); $('#leave_comment').show().sahCenter(); }
 */
