function MM_validateForm(formulario) { //v4.0
 	//formulario.btnEnviar.disabled=true;
	document.getElementById("Errores").innerHTML=""
	txt_errores="";
	
	for (var i = 0; i < formulario.elements.length; i++) {
		if (formulario.elements[i].type == "text" || formulario.elements[i].type == "textarea") {
			formulario.elements[i].style.backgroundColor="#DEE9EB";
		}
	}
	
	if (!tieneDatos(formulario.Nombre.value)) {
		txt_errores+="- Escriba su Nombre<br />";
		formulario.Nombre.style.backgroundColor="#FFD9D9";
	}
	if(!isEmailAddress(formulario.e_mail.value)) {
		txt_errores+="- Escriba su Mail correctamente<br />";
		formulario.e_mail.style.backgroundColor="#FFD9D9";
	}

	if (!tieneDatos(formulario.Asunto.value)) {
		txt_errores+="- Escriba un Asunto<br />";
		formulario.Asunto.style.backgroundColor="#FFD9D9";
	}
	if (!tieneDatos(formulario.Comentarios.value)) {
		txt_errores+="- Escriba su Comentario<br />";
		formulario.Comentarios.style.backgroundColor="#FFD9D9";
	}
	if(txt_errores!="") {
		//formulario.btnEnviar.disabled=false;
		document.getElementById("Errores").innerHTML="<strong>Han ocurrido los siguientes Errores: </strong><br />"+txt_errores+"<br />";
		
	}
  document.MM_returnValue = (txt_errores == '');
}
function tieneDatos(Valor) { 
 for (var i=0; i<Valor.length; i++) { 
   if ((" \t\n\r").indexOf(Valor.charAt(i))==-1) return true; 
   } 
 return false; 
}

function isEmailAddress(theElement)
{
	var s = theElement;
	var filter=/^[A-Za-z][A-Za-z0-9_.-]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	if (s.length == 0 ) return false;
	if (filter.test(s)){
		return true;
	}else{
		return false;
	}
}

function checkRevendedora(val){
	if(val.options[val.selectedIndex].text.toLowerCase()=="vender"){
		document.location.href = "sumate.php";
	}
}

function acceptNum(evt)
{
    // NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57
    var key;

    if(window.event)
    {
        key = evt.keyCode;
    }else if(evt.which)
    {
        key = evt.which;
    }

    return (key <= 13 || (key >= 48 && key <= 57) || key == undefined);
}

function setNewLength(area, numero){
	var leng = document.getElementById(area).value.length;
	var tel = document.getElementById(numero);
	
	if (leng == 4){
		tel.maxLength = 6;
	}else if(leng == 3){
		tel.maxLength = 7;
	}else if(leng == 2){
		tel.maxLength = 8;
	}
	//alert(leng);
	//e.maxLength;
}
