var reEmail3 = /^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
var reEmail = reEmail3;

function doEmail(pStr){
	if (reEmail.test(pStr)) {
		retorno = true
	} else if (pStr != null && pStr != "") {
		alert(pStr + " NÃO é um endereço de e-mail válido.");
		retorno = false
	}
	return retorno
}


function get_cidades(salva){
	req = null;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = cidades;
		req.open("POST","get_cidades.php",true);
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
		req.send('estado='+salva);
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = cidades;
			req.open("POST","get_cidades.php",true);
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");        
			req.send('estado='+salva);
		}
	}
}

function cidades() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			document.getElementById('select_cidades').innerHTML = '<select class="texto_selecione01" style="width:130px " onChange="get_bairro(this.value)" name="acidade" id="acidade"><option value=""></option>'+req.responseText+'</select>';
		}else{
			alert("Houve um problema ao obter os dados:\n" + req.statusText);
		}
	}
}

function get_bairro(salva){
	req = null;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = bairro;
		req.open("POST","get_bairro.php",true);
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
		req.send('finalidade='+salva);
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = bairro;
			req.open("POST","get_bairro.php",true);
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");        
			req.send('finalidade='+salva);
		}
	}
}
function bairro() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			document.getElementById('select_bairro').innerHTML ='<select style="width:130px " class="texto_selecione01" onChange="get_finalidade(this.value)" name="obairro" id="obairro" ><option value=""></option>'+req.responseText+'</select>';
		}else{
			alert("Houve um problema ao obter os dados:\n" + req.statusText);
		}
	}
}



function preenche_form() {
	document.forms[0]['cidade'].value = document.getElementById('acidade').value
	document.forms[0]['bairro'].value = document.getElementById('obairro').value
	document.forms[0]['marca'].value = document.getElementById('amarca').value
}








function mostra_foto() {
	
}


/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}
/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}









function get_cidadess(salva){
	req = null;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = cidadess;
		req.open("POST","get_cidadess.php",true);
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
		req.send('estado='+salva);
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = cidadess;
			req.open("POST","get_cidadess.php",true);
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");        
			req.send('estado='+salva);
		}
	}
}

function cidadess() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			document.getElementById('select_cidadess').innerHTML = '<select class="texto_selecione01" style="border:solid 1 px #FFFFFF; font-size:11px; font-weight:bold; width:130px" name="acidadee" id="acidadee"><option value=""></option>'+req.responseText+'</select>';
		}else{
			alert("Houve um problema ao obter os dados:\n" + req.statusText);
		}
	}
}






function preenche_formm() {
	
	 document.forms[0]['cidadee'].value = document.getElementById('acidadee').value
	
}








function get_marcas(salva){
	req = null;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = marcas;
		req.open("POST","get_marcas.php",true);
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
		req.send('estado='+salva);
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = marcas;
			req.open("POST","get_marcas.php",true);
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");        
			req.send('estado='+salva);
		}
	}
}

function marcas() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			document.getElementById('select_marcas').innerHTML = '<select class="texto_selecione01" style="background-color:#D4D4D4; width:150px" name="amarca" id="amarca"><option value=""></option>'+req.responseText+'</select>';
		}else{
			alert("Houve um problema ao obter os dados:\n" + req.statusText);
		}
	}
}


function preenche_form() {
	
	document.forms[0]['marca'].value = document.getElementById('amarca').value
}
