var nombreEstablecimiento, direccion;
var regexNombreEstablecimiento, regexDireccion;
var suma = 0;
var errores = new Array();
var campo;
var salida;
function error(n){
	errores.push(n);
	/*
	document.getElementById(campo).style.borderColor = "red";
	document.getElementById(campo).style.borderWidth = 1+"px";
	document.getElementById(campo).style.borderStyle = "solid";
	*/
}
function bien(){
	/*
	document.getElementById(campo).style.borderColor = "#cccc00";
	document.getElementById(campo).style.borderWidth = 1+"px";
	document.getElementById(campo).style.borderStyle = "solid";
	document.getElementById(campo).style.color = "#cccc00";
	*/
	suma ++;	
}
function limpiaErrores(){
	errores = new Array();
}

function validaCliente(){
	suma = 0; 
	/*Validacion, 2 = ok*/
	//validaNombre();//1
	validaEmail();//2
	
	if (suma == 1){//Los campos que valida son 16 si no error.
		document.getElementById("salida").style.display = "none";//Oculto la salida
		document.getElementById("form").action = "suscripcion2.php";
		document.getElementById("form").submit();	
	}else{
		salida = "<b>Atención debe revisar los siguientes errores:</b><br/>";
		for(var m=0;m<errores.length;m++){
			salida =  salida + (m+1) + ". " + errores[m] + "<br/>";
		}
		limpiaErrores();
		document.getElementById("salida").style.display = "";
		//document.getElementById("salida").firstChild.firstChild.nodeValue = salida;
		document.getElementById("salida").firstChild.innerHTML = salida;
	}
}
/*-----------------------------------------------------------------------------------*/
function validaNombre(){
	campo = 'nombre';
	nombreEstablecimiento = document.getElementById(campo).value;
	regexNombreEstablecimiento = "^[A-Za-z\x20\xE1\xE9\xED\xF3\xFA\xF1\xC1\xC9\xCD\xD3\xDA\xD1\x2D]+$";
/*	
	if (nombreEstablecimiento.match(regexNombreEstablecimiento)!=null){
		numSubcampos ++;
		bien();
	}else{		
		error("2. <a href='#s2'>Establecimiento</a>: Debe especificar un Nombre de Establecimiento");
	}
*/
	if (nombreEstablecimiento != ""){
		bien();
	}else{		
		error("Debe especificar su Nombre.");
	}
}
function validaEmail(){
	campo = 'email';
	email = document.getElementById(campo).value;
	regexEmail = "^([0-9a-zA-Z\xF1\x2D]+(?:[._][0-9a-zA-Z\xF1\x2D]+)*)\@([0-9a-zA-Z\xF1\x2D]+(?:[._-][0-9a-zA-Z\x2D]+)*(?:[.][0-9a-zA-Z]{2,3}))$";
	if (email.match(regexEmail)!=null){
		bien();
	}else{
		error('Debe revisar su E-mail');
	}
}
