     
// Use jQuery via $j(...)
$j(document).ready(function(){
	$j(".row_news").corner("10px");
        $j("#guestbookForm textarea").keyup(updateCharCount);
        $j("#guestbookForm textarea").focus(updateCharCount);
        $j("#guestbookForm form").submit(guestbookSubmit);


});

function guestbookEnableAjax()
{
    $j("#guestbookForm form").submit(guestbookSubmit);
    $j("#guestbookForm textarea").keyup(updateCharCount);
}

function guestbookSubmit(event)
{
	if($j("#nombre_comment").val()=="") {
		alert("Ingresa tu nombre");
		return false;
	}

	if($j("#email_comment").val()=="") {
		alert("Ingresa tu email");
		return false;
	}
        var options = {
                indicator:         $j("#tip_comment"),
                errorContainer:    $j("#guestbookForm .errorBox"),
                update:            $j('#guestbook'),
		url:		   "/box.php?ajax=1&",
                onComplete:        function() {guestbookEnableAjax();}
        };
        var comment = document.getElementById("txtcomment").value;
        if( comment.length>500 )  {
                alert("No puedes sobrepasar los 500 caracteres en tu comentario.");
                return false;
        }
        $j(this).fAjaxSubmit(event, options);
        $j("#txtcomment").val("");
        $j("#nombre_comment").val("");
        $j("#email_comment").val("");
}

function updateCharCount()
{
        $j("#counter var").get(0).innerHTML = 500 - $j("#guestbookForm textarea").get(0).value.length;
}




