function valida (f) {
	var campos = "";
	for (i = 0; i < f.length; i++) { 
		var id = f[i].id;
		if (id.toLowerCase().indexOf('empty_') != -1) {
            // FTI temporarily allow some blank vars as per Donna, 8/26
            if (id == "empty_your_phone_evening" || 
                id == "empty_partner_phone_day" ||
                id == "empty_partner_phone_evening" || 
                id == "email_partner_email" ||
                id == "empty_work_phone" ||
                id == "empty_destination" ||
                id == "empty_contact_city" ||
                id == "empty_contact_postal_code" ) {
                continue;
            }

			if (!isEmpty(f[i].value)) {
				campos += "\t » " + id.substring(id.indexOf("_",2)+1).toUpperCase().addcomm_replace("_"," ") + "\n";
			}
		} else if (id.toLowerCase().indexOf('numero_') != -1) {
			if (!isNumber(f[i].value)) {
				campos += "\t » " + id.substring(id.indexOf("_",2)+1).toUpperCase().addcomm_replace("_"," ") + "\n";
			}
		} else if (id.toLowerCase().indexOf('dinheiro_') != -1) {
			if (!isMoney(f[i].value)) {
				campos += "\t » " + id.substring(id.indexOf("_",2)+1).toUpperCase().addcomm_replace("_"," ") + "\n";
			}
		} else if (id.toLowerCase().indexOf('nome_') != -1) {
			if (!isName(f[i].value)) {
				campos += "\t » " + id.substring(id.indexOf("_",2)+1).toUpperCase().addcomm_replace("_"," ") + "\n";
			}
		} else if (id.toLowerCase().indexOf('email_') != -1) {
            // FTI temporarily allow some blank vars as per Donna, 8/26
            if (id == "email_partner_email") {
                continue;
            }
			if (!isEmail(f[i].value)) {
				campos += "\t » " + id.substring(id.indexOf("_",2)+1).toUpperCase().addcomm_replace("_"," ") + "\n";
			}
		} else if (id.toLowerCase().indexOf('url_') != -1) {
			if (!isUrl(f[i].value)) {
				campos += "\t » " + id.substring(id.indexOf("_",2)+1).toUpperCase().addcomm_replace("_"," ") + "\n";
			}
		} else if (id.toLowerCase().indexOf('data_') != -1) {
			if (!isDate(f[i].value)) {
				campos += "\t » " + id.substring(id.indexOf("_",2)+1).toUpperCase().addcomm_replace("_"," ") + "\n";
			}
		} else if (id.toLowerCase().indexOf('niver_') != -1) {
			if (!isDate(f[i].value, true)) {
				campos += "\t » " + id.substring(id.indexOf("_",2)+1).toUpperCase().addcomm_replace("_"," ") + "\n";
			}
		} else if (id.toLowerCase().indexOf('cpf_') != -1) {
			if (!isCpf(f[i].value, true)) {
				campos += "\t » " + id.substring(id.indexOf("_",2)+1).toUpperCase().addcomm_replace("_"," ") + "\n";
			}
		} else if (id.toLowerCase().indexOf('cnpj_') != -1) {
			if (!isCnpj(f[i].value, true)) {
				campos += "\t » " + id.substring(id.indexOf("_",2)+1).toUpperCase().addcomm_replace("_"," ") + "\n";
			}
		} else if (id.toLowerCase().indexOf('rg_') != -1) {
			if (!isRg(f[i].value)) {
				campos += "\t » " + id.substring(id.indexOf("_",2)+1).toUpperCase().addcomm_replace("_"," ") + "\n";
			}
		} else if (id.toLowerCase().indexOf('cep_') != -1) {
			if (!isCep(f[i].value)) {
				campos += "\t » " + id.substring(id.indexOf("_",2)+1).toUpperCase().addcomm_replace("_"," ") + "\n";
			}
		} else if (id.toLowerCase().indexOf('senha_') != -1) {
			if (!isSenha(f[i].value, document.getElementById("compara").value)) {
				campos += "\t » " + id.substring(id.indexOf("_",2)+1).toUpperCase().addcomm_replace("_"," ") + "\n";
			}
		} else if (id.toLowerCase().indexOf('tel_') != -1) {
			if (!isTel(f[i].value)) {
				campos += "\t » " + id.substring(id.indexOf("_",2)+1).toUpperCase().addcomm_replace("_"," ") + "\n";
			}
		}
	}
	if (campos) {
		var msg = "The fields:\n\n" + campos + "\n Are filled incorrectly. \t\t\n Please try again.";
		alert(msg);
		return false;
	} else {
		return true;
	}
}
/*#####################################*/
function isEmpty (v) {
	return (v);
}
function isNumber(v){
	return (!isNaN(v));
}
function isMoney(v){
	return (v.match(/^([0-9]{1,3}\.?)+\,[0-9]{2}$/));
}
function isName(v){
	return (v.match(/\w[^ ]+.+/));
}
function isEmail(v){
	return (v.match(/^[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)*@[a-zA-Z0-9-]{2,64}(\.[a-zA-Z0-9-]{2,64})*\.[a-zA-Z]{2,4}$/));
}
function isUrl(v){
	return (v.match(/^(ht|f)tp\:\/\/[a-zd][a-zd-]{1,64}(\.[a-zd][a-zd-]{2,64})*\.[a-z]{2,4}.+$/));
}
function isDate(date, b) {
	if (date==null) return false;
	arrDdate = date.split('/');
	dia = arrDdate[1]; mes = arrDdate[0]; ano = arrDdate[2]
	if (
		( isNaN(parseInt(dia)) || isNaN(parseInt(mes)) || isNaN(parseInt(ano)) ) ||
		(ano < 1900 || ano > 9999) || 
		(mes < 1 || mes > 12) || 
		(dia < 1 || dia > 31) || 
		(mes == 2 && dia > 28 && (ano % 4 != 0)) || 
		(mes == 2 && dia > 29 && (ano % 4 == 0)) || 
		(dia > 30 && (mes == 4 || mes == 6 || mes == 9 || mes== 11))
	) { 
		return false;
	} else {
		if (b){
			data = new Date (ano,mes,dia);
			dateInicio = new Date(1900,01,01);
			dateFim = new Date(2005,01,01);
			if(data<dateInicio || data>dateFim)return false;
		}
		return true;
	}
}
function isCpf(v){
	var s=null;
	var r=null;
	if(v.length !=11 || v.match(/1{11}|2{11}|3{11}|4{11}|5{11}|6{11}|7{11}|8{11}|9{11}|0{11}/))return false;
	s=0;
	for(var i=0;i<9;i++)s+=parseInt(v.charAt(i))*(10-i);r=11-(s%11);
	if(r==10||r==11)r=0;
	if(r!=parseInt(v.charAt(9)))return false;
	s=0;
	for(var i=0;i<10;i++)s+=parseInt(v.charAt(i))*(11-i);
	r=11-(s%11);
	if(r==10||r==11)r=0;
	if(r!=parseInt(v.charAt(10)))return false;
	return true;
}
function isCnpj(v){
	var dig1=0;
	var dig2=0;
	var x;
	var Mult1='543298765432';
	var Mult2='6543298765432';
	for(x=0;x<=11;x++){
		dig1=dig1+(parseInt(v.slice(x,x+1))*parseInt(Mult1.slice(x,x+1)));
	}
	for(x=0;x<=12;x++){
		dig2=dig2+(parseInt(v.slice(x, x+1))*parseInt(Mult2.slice(x,x+1)));
	}
	dig1=(dig1*10)%11;dig2=(dig2*10)%11;
	if(dig1==10){
		dig1=0;
	}
	if(dig2==10){
		dig2=0;
	}
	if(dig1!=parseInt(v.slice(12, 13))){
		return false;
	}else{
		if(dig2!=parseInt(v.slice(13, 14))){
			return false;
		}else{
			return true;
		}
	}
}
function isRg(v) {
	v = v.addcomm_replace(" ","");
	v = v.addcomm_replace(".","");
	v = v.addcomm_replace("-","");
	return (v.match(/[0-9xX]{9}/))
}
function isCep(v) {
	v = v.addcomm_replace(" ","");
	v = v.addcomm_replace("-","");
	return (v.match(/[0-9]{8}/))
}
function isSenha(v, c) {
	if (isEmpty(v)) {
		if (v == c) {
			return true;
		} else {
			return false;
		}
	} else {
		return false;
	}
}
function isTel(v) {
	v = v.addcomm_replace(" ","");
	v = v.addcomm_replace("-","");
	v = v.addcomm_replace(".","");
	v = v.addcomm_replace("(","");
	v = v.addcomm_replace(")","");
	if (v.length < 11) {
		return (v.match(/\d{7,11}/));
	} else {
		return false
	}
}
/*#####################################*/
String.prototype.addcomm_replace = function(a,b) {
	var str = "";
	for (lS=0; lS < this.length; lS++){
		if (this.charAt(lS) == a) { str += b } else { str += this.charAt(lS) }
	}
	return str;
}
function selectDestination(v) {
	if (v != ""){
		window.location = "../../secoes/destination/index.php?i=" + v;
	}
}
	  
function selectInterest(v) {
	if (v != ""){
			
			window.location = "../../secoes/interests/index.php?i=" + v;
	}
}
