function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
   {field.value = field.value.substring(0, maxlimit);}
   else
   {countfield.value = maxlimit - field.value.length;}   
}

function chkMensaje(){
	if (document.frm.nombre.value == "")  { 
		alert("Ingrese su nombre"); 
		document.frm.nombre.focus(); 
		return (false); 
	}	

	if (document.frm.email.value.indexOf('@', 0) == -1 || document.frm.email.value.indexOf('.', 0) == -1) { 
		alert("Dirección de e-mail inválida"); 
		document.frm.email.focus(); 
		return (false); 
	}	

	if (document.frm.mensaje.value == "") { 
		alert("Ingrese su mensaje"); 
		document.frm.mensaje.focus(); 
		return (false); 
	}	

    if( confirm("¿Desea comentar?") ) {
		f=document.getElementById('frm');
		f.method="post";
		f.action="post.php";
		f.submit();
		return (true);
    }
    else { 
        return (false);
    }
}

function clnMensaje(){
	document.frm.nombre.value="";
	document.frm.email.value="";
	document.frm.mensaje.value="";
	document.frm.contadorTexto.value="500";
	return (true);
}

///////////toolbar functions////////////////////////
function insertPicture(align){ 
	
    var szURL = prompt("IMG SRC", "");
	try { 	
	    if (szURL != "" && szURL != null){
			document.frm.texto.value += "<div style=\"padding: 7px; float: "+align+"; vertical-align: top;\"><img style=\"vertical-align: bottom;\" src=\"Imagenes/"+szURL+"\" class=\"reflect\"></div>";
	    }
	    else {
	        document.frm.texto.focus();
	    }
	} catch (e) { 
	    //do nothing 
	}    
}

function insertURL(){ 
	
    var szURL = prompt("Ingrese enlace", "http://");
	try { 	
	    if (szURL != "" && szURL != null){
			document.frm.texto.value += "<a href=\""+szURL+"\" target=\"top\">"+szURL+"</a>";
	    }
	    else {
	        document.frm.texto.focus();
	    }
	} catch (e) { 
	    //do nothing 
	}    
}

function insertEmail(){ 
	
    var szURL = prompt("Ingrese e-mail", "");
	try { 	
	    if (szURL != "" && szURL != null){
			document.frm.texto.value += "<a href=\"mailto:"+szURL+"\">"+szURL+"</a>";
	    }
	    else {
	        document.frm.texto.focus();
	    }
	} catch (e) { 
	    //do nothing 
	}    
}

function embedCode(){ 
	
    var szURL = prompt("EMBED CODE", "");
	try { 	
	    if (szURL != "" && szURL != null){
			document.frm.texto.value += "<p align=\"center\">"+szURL+"</p>";
	    }
	    else {
	        document.frm.texto.focus();
	    }
	} catch (e) { 
	    //do nothing 
	}    
}

function embedPicture(){ 
	
    var szURL = prompt("Ingrese el nombre de la imagen", "");
	try { 	
	    if (szURL != "" && szURL != null){
			document.frm.texto.value += "<p><img src=\"Imagenes/"+szURL+"\"></p>";
	    }
	    else {
	        document.frm.texto.focus();
	    }
	} catch (e) { 
	    //do nothing 
	}    
}

///////////end toolbar////////////////////////