/*/function blanc(){
while (espacios && (cont < p1.length)) {
  if (p1.charAt(cont) != " ") {
    espacios = false;
  }
  cont++;
}
}
*/
function valida2_form(){
    //valido el nombre
    if (document.sugerenciasx.nombre.value.length<2){
       document.getElementById("sugiere").innerHTML = "Ingrese correctamente su nombre";
       document.sugerenciasx.nombre.focus()
       return (false);
    }
    
    //valido el apellido
    if (document.sugerenciasx.apellido.value.length<2){
       document.getElementById("sugiere").innerHTML = "Ingrese correctamente su apellido";
       document.sugerenciasx.apellido.focus()
       return (false);
    }
    
    //valido el email
    var asd=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.sugerenciasx.email.value);

    if (asd ==false){
        document.getElementById("sugiere").innerHTML = "Ingrese correctamente su Email";
       document.sugerenciasx.email.focus()
       return (false);     
    }
    
    //valido el asunto
    if (document.sugerenciasx.asunto.value.length<2){
       document.getElementById("sugiere").innerHTML = "Ingrese el asunto";
       document.sugerenciasx.asunto.focus()
       return (false);
    }
    
    //valido el mensaje
    if (document.sugerenciasx.mensaje.value.length<2){
       document.getElementById("sugiere").innerHTML = "Escriba el mensaje";
       document.sugerenciasx.mensaje.focus()
       return (false);
    }
    
 return (true);
} 


function checkUsernameForLength(whatYouTyped) {
	var fieldset = whatYouTyped.parentNode;
	var txt = whatYouTyped.value;
	if (txt.length > 1) {
		fieldset.className = "welldone";
	}
	else {
		fieldset.className = "";
	}
}

function checkEmail(whatYouTyped) {
	var fieldset = whatYouTyped.parentNode;
	var txt = whatYouTyped.value;
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(txt)) {
		fieldset.className = "welldone";
	} else {
		fieldset.className = "";
	}
}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}


function prepareInputsForHints() {
  var inputs = document.getElementsByTagName("input");
  for (var i=0; i<inputs.length; i++){
    inputs[i].onfocus = function () {
      this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
    }
    inputs[i].onblur = function () {
      this.parentNode.getElementsByTagName("span")[0].style.display = "none";
    }
  }
}
addLoadEvent(prepareInputsForHints);