// JavaScript Document

function checkComent()
{
    var oEditor = FCKeditorAPI.GetInstance('coment') ;
	var content = oEditor.GetHTML();
	with (window.document.comentForm) {
		if (name.value == '' || name.value == 'Nombre') {
			alert('Introduzca un nombre');
			return;
		} else if (content == '') {
			alert('Introducir algun contenido en el comentario');
			return;
		} else {
			sendComent(name.value,content);
		}
	}
}

function sendComent(name,content) {
	
    var xhr = getTransport();
    xhr.onreadystatechange = function() {
        updateDataComent(xhr);
    }
	xhr.open('post', 'datasource/coment.php', true);
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
    xhr.send('cont='+escape(content)+'&name='+name);
	
}


function updateDataComent(xhr) {
    if (xhr.readyState == 4) {
        if (xhr.status == 200) {
 
			SWFAddress.setValue('/comentarios/');
			
        } else {
            //alert('Error: ' + xhr.status + '!');
        }
    }
}
