
function AbrirNoticia(noticia, ancho, alto) {

var url;

   url = "ver_noticia.php?id=" + noticia;

   window.open(url, "noticia", "width="+ancho+",height="+alto+",scrollbars=yes,resizable=yes,status=no");
}

function TrimLeft( str ) {
	var resultStr = "";
	var i = len = 0;

	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str == null)	
		return null;

	// Make sure the argument is a string
	str += "";

	if (str.length == 0) 
		resultStr = "";
	else {	
  		// Loop through string starting at the beginning as long as there
  		// are spaces.
//	  	len = str.length - 1;
		len = str.length;
		
  		while ((i <= len) && (str.charAt(i) == " "))
			i++;

   	// When the loop is done, we're sitting at the first non-space char,
 		// so return that char plus the remaining chars of the string.
  		resultStr = str.substring(i, len);
  	}

  	return resultStr;
}

function TrimRight( str ) {
	var resultStr = "";
	var i = 0;

	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str == null)	
		return null;

	// Make sure the argument is a string
	str += "";
	
	if (str.length == 0) 
		resultStr = "";
	else {
  		// Loop through string starting at the end as long as there
  		// are spaces.
  		i = str.length - 1;
  		while ((i >= 0) && (str.charAt(i) == " "))
 			i--;
 			
 		// When the loop is done, we're sitting at the last non-space char,
 		// so return that char plus all previous chars of the string.
  		resultStr = str.substring(0, i + 1);
  	}
  	
  	return resultStr;  	
}


function trim( str ) {
	var resultStr = "";
	
	resultStr = TrimLeft(str);
	resultStr = TrimRight(resultStr);
	
	return resultStr;
}

function validar_envio_correo(formulario) {
  if (trim(formulario.txtnombre.value) == "") {
    alert("Escriba su nombre.");
	formulario.txtnombre.focus();
    return (false);
  }

  if (trim(formulario.txtemail.value) != "") {
    if ((formulario.txtemail.value.indeexOf ('@', 0) == -1)) { 
      alert("Escriba una dirección de correo válida."); 
      formulario.txtemail.focus();
      return (false); 
    }
  }
  
  if (trim(formulario.txttelefono.value) == "") {
    alert("Escriba su teléfono de contacto.");
	formulario.txttelefono.focus();
    return (false);
  }
  
  if (trim(formulario.txtasunto.value) == "") {
    alert("Escriba el asunto del mensaje.");
	formulario.txtasunto.focus();
    return (false);
  }
 
  if (trim(formulario.txttexto.value) == "") {
    alert("Escriba el mensaje.");
	formulario.txttexto.focus();
    return (false);
  }

  return (true); 
}
