function emptyForm(id_form){
	var search = document.getElementById('search_id').value;
	
	if (search != ''){
		document.getElementById(id_form).submit();
	}
}

function emptyForm_2(id_form2){
	var search = document.getElementById('search_id_2').value;
	
	if (search != ''){
		document.getElementById(id_form2).submit();
	}
}

function valida(e){
    if (e.keyCode == 13){
        document.getElementById('botao_submit').click();
    }
}

function imposeMaxLength(Event, Object, MaxLen){
	return (Object.value.length <= MaxLen)||(Event.keyCode == 8 ||Event.keyCode==46||(Event.keyCode>=35&&Event.keyCode<=40)) 
}


/* 2 */
function Dados(valor){
	try{ ajax = new ActiveXObject("Microsoft.XMLHTTP"); }
	catch(e){
		try{ ajax = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch(ex){
			try{ ajax = new XMLHttpRequest(); }
			catch(exc){
				alert("Esse browser não tem recursos para uso do Ajax");
				ajax = null;
			}
		}
	}
	if(ajax){
		document.forms[0].listSubcat.options.length = 1;
		document.forms[0].cat2.disabled = true;
		document.forms[0].cat2.style.visibility = 'visible';
		idOpcao  = document.getElementById("opcoes");
		ajax.open("POST", "sistemas/_subcat.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.onreadystatechange = function() {
			if(ajax.readyState < 4){
				idOpcao.innerHTML = "--Carregando--";
			}
			if(ajax.readyState == 4 ){
				if(ajax.responseXML) {
					processXML(ajax.responseXML);
					document.forms[0].cat2.disabled = false;
				}else{
					idOpcao.innerHTML = "--Nenhuma subcategoria disponível--";
					document.forms[0].cat2.disabled = true;
				}
			}
		}
		var params = "test1="+valor;
		ajax.send(params);
	}
}

function processXML(obj){
	var dataArray = obj.getElementsByTagName("categoria");
	if(dataArray.length > 0) {
	for(var i = 0 ; i < dataArray.length ; i++){
		var item = dataArray[i];
		var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
		var descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
		
		idOpcao.innerHTML = "--selecione--";
		var novo = document.createElement("option");
			novo.setAttribute("id", "opcoes");
			novo.value = codigo;
			novo.text  = descricao;
			document.forms[0].listSubcat.options.add(novo);
	}
	}else{
		idOpcao.innerHTML = "--Vazio--";
	}
}


/* 3 */
function Dados2(valor){
	try{ ajax = new ActiveXObject("Microsoft.XMLHTTP"); }
	catch(e){
		try{ ajax = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch(ex){
			try{ ajax = new XMLHttpRequest(); }
			catch(exc){
				alert("Esse browser não tem recursos para uso do Ajax");
				ajax = null;
			}
		}
	}
	if(ajax){
		document.forms[0].listSubcat3.options.length = 1;
		document.forms[0].cat3.disabled = true;
		document.forms[0].cat3.style.visibility = 'visible';
		idOpcao2  = document.getElementById("opcoes2");
		ajax.open("POST", "sistemas/_subcat2.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.onreadystatechange = function() {
			if(ajax.readyState < 4) {
				idOpcao2.innerHTML = "--Carregando--";
			}
			if(ajax.readyState == 4 ) {
				if(ajax.responseXML) {
					processXML2(ajax.responseXML);
					document.forms[0].cat3.disabled = false;
				}else{
					idOpcao2.innerHTML = "--Nenhuma subcategoria disponível--";
					document.forms[0].cat3.disabled = true;
				}
			}
		}
		var params = "test2="+valor;
		ajax.send(params);
	}
}

function processXML2(obj){
	var dataArray = obj.getElementsByTagName("categoria");
	if(dataArray.length > 0) {
	for(var i = 0 ; i < dataArray.length ; i++){
		var item = dataArray[i];
		var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
		var descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
		
		idOpcao2.innerHTML = "--selecione--";
		var novo = document.createElement("option");
			novo.setAttribute("id", "opcoes2");
			novo.value = codigo;
			novo.text  = descricao;
			document.forms[0].listSubcat3.options.add(novo);
	}
	}else{
		idOpcao2.innerHTML = "--Vazio--";
	}
}


/* 4 */
function Dados3(valor){
	try{ ajax = new ActiveXObject("Microsoft.XMLHTTP"); }
	catch(e){
		try{ ajax = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch(ex){
			try{ ajax = new XMLHttpRequest(); }
			catch(exc){
				alert("Esse browser não tem recursos para uso do Ajax");
				ajax = null;
			}
		}
	}
	if(ajax){
		document.forms[0].listSubcat4.options.length = 1;
		document.forms[0].cat4.disabled = true;
		document.forms[0].cat4.style.visibility = 'visible';
		idOpcao3  = document.getElementById("opcoes3");
		ajax.open("POST", "sistemas/_subcat3.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.onreadystatechange = function() {
			if(ajax.readyState < 4) {
				idOpcao3.innerHTML = "--Carregando--";
			}
			if(ajax.readyState == 4 ) {
				if(ajax.responseXML) {
					processXML3(ajax.responseXML);
					document.forms[0].cat4.disabled = false;
				}else{
					idOpcao3.innerHTML = "--Nenhuma subcategoria disponível--";
					document.forms[0].cat4.disabled = true;
				}
			}
		}
		var params = "test3="+valor;
		ajax.send(params);
	}
}

function processXML3(obj){
	var dataArray = obj.getElementsByTagName("categoria");
	if(dataArray.length > 0) {
	for(var i = 0 ; i < dataArray.length ; i++){
		var item = dataArray[i];
		var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
		var descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
		
		idOpcao3.innerHTML = "--selecione--";
		var novo = document.createElement("option");
			novo.setAttribute("id", "opcoes3");
			novo.value = codigo;
			novo.text  = descricao;
			document.forms[0].listSubcat4.options.add(novo);
	}
	}else{
		idOpcao3.innerHTML = "--Vazio--";
	}
}



/* incluir anuncio */
function Dados11(valor,valor2){
	try{ ajax = new ActiveXObject("Microsoft.XMLHTTP"); }
	catch(e){
		try{ ajax = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch(ex){
			try{ ajax = new XMLHttpRequest(); }
			catch(exc){
				alert("Esse browser não tem recursos para uso do Ajax");
				ajax = null;
			}
		}
	}
	if(ajax){
		document.forms[0].listSubcat.options.length = 1;
		document.forms[0].cat2.disabled = true;
		document.forms[0].cat2.style.visibility = 'visible';
		document.forms[0].cat3.style.visibility = 'hidden';
		document.forms[0].cat4.style.display = 'none';
		document.getElementById("botao_cont").style.display = 'none';
		idOpcao  = document.getElementById("opcoes");
		ajax.open("POST", "sistemas/1_subcat.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.onreadystatechange = function() {
			if(ajax.readyState < 4){
				document.forms[0].listSubcat.options.length = 1;
				idOpcao.innerHTML = "--Carregando--";
			}
			if(ajax.readyState == 4 ){
				if(ajax.responseXML) {
					processXML11(ajax.responseXML);
					document.forms[0].cat2.disabled = false;
				}else{
					idOpcao.innerHTML = "--Nenhum item disponível--";
					document.forms[0].cat2.disabled = true;
				}
			}
		}
		var params = "test1="+valor+"&test2="+valor2;
		ajax.send(params);
	}
}

function processXML11(obj){
	var dataArray = obj.getElementsByTagName("categoria");
	document.forms[0].listSubcat.options.length = 0;
	if(dataArray.length > 0) {
	for(var i = 0 ; i < dataArray.length ; i++){
		var item = dataArray[i];
		var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
		var descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
		
		var novo = document.createElement("option");
			novo.setAttribute("id", "opcoes");
			novo.value = codigo;
			novo.text  = descricao;
			document.forms[0].listSubcat.options.add(novo);
	}
	}else{
		idOpcao.innerHTML = "--Vazio--";
	}
}

/* incluir anuncio2 */
function Dados22(valor,valor2){
	try{ ajax = new ActiveXObject("Microsoft.XMLHTTP"); }
	catch(e){
		try{ ajax = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch(ex){
			try{ ajax = new XMLHttpRequest(); }
			catch(exc){
				alert("Esse browser não tem recursos para uso do Ajax");
				ajax = null;
			}
		}
	}
	if(ajax){
		document.forms[0].listSubcat3.options.length = 1;
		document.forms[0].cat3.disabled = true;
		document.forms[0].cat3.style.visibility = 'visible';
		document.forms[0].cat4.style.display = 'none';
		document.getElementById("botao_cont").style.display = 'none';
		idOpcao  = document.getElementById("opcoes2");
		ajax.open("POST", "sistemas/1_subcat2.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.onreadystatechange = function() {
			if(ajax.readyState < 4){
				document.forms[0].listSubcat3.options.length = 1;
				idOpcao.innerHTML = "--Carregando--";
			}
			if(ajax.readyState == 4 ){
				if(ajax.responseXML) {
					processXML22(ajax.responseXML);
					document.forms[0].cat3.disabled = false;
				}else{
					idOpcao.innerHTML = "--Nenhum item disponível--";
					document.forms[0].cat3.disabled = true;
				}
			}
		}
		var params = "test2="+valor+"&test3="+valor2;
		ajax.send(params);
	}
}

function processXML22(obj){
	var dataArray = obj.getElementsByTagName("categoria");
	document.forms[0].listSubcat3.options.length = 0;
	if(dataArray.length > 0) {
	for(var i = 0 ; i < dataArray.length ; i++){
		var item = dataArray[i];
		var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
		var descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
		
		var novo = document.createElement("option");
			novo.setAttribute("id", "opcoes2");
			novo.value = codigo;
			novo.text  = descricao;
			document.forms[0].listSubcat3.options.add(novo);
	}
	}else{
		idOpcao.innerHTML = "--Vazio--";
	}
}


/* incluir anuncio3 */
function Dados33(valor,valor2){
	try{ ajax = new ActiveXObject("Microsoft.XMLHTTP"); }
	catch(e){
		try{ ajax = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch(ex){
			try{ ajax = new XMLHttpRequest(); }
			catch(exc){
				alert("Esse browser não tem recursos para uso do Ajax");
				ajax = null;
			}
		}
	}
	if(ajax){
		document.forms[0].listSubcat4.options.length = 1;
		document.forms[0].cat4.disabled = true;
		document.getElementById("botao_cont").style.display = 'none';
		idOpcao  = document.getElementById("opcoes3");
		ajax.open("POST", "sistemas/1_subcat3.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.onreadystatechange = function() {
			if(ajax.readyState < 4){
				document.forms[0].listSubcat4.options.length = 1;
				idOpcao.innerHTML = "--Carregando--";
			}
			if(ajax.readyState == 4 ){
				if(ajax.responseXML) {
					processXML33(ajax.responseXML);
					document.forms[0].cat4.disabled = false;
					document.forms[0].cat4.style.display = 'block';
				}else{
					idOpcao.innerHTML = "--Nenhum item disponível--";
					document.forms[0].cat4.style.display = 'none';
					document.forms[0].cat4.disabled = true;
				}
			}
		}
		var params = "test2="+valor+"&test3="+valor2;
		ajax.send(params);
	}
}

function processXML33(obj){
	var dataArray = obj.getElementsByTagName("categoria");
	document.forms[0].listSubcat4.options.length = 0;
	if(dataArray.length > 0) {
	for(var i = 0 ; i < dataArray.length ; i++){
		var item = dataArray[i];
		var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
		var descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
		
		var novo = document.createElement("option");
			novo.setAttribute("id", "opcoes3");
			novo.value = codigo;
			novo.text  = descricao;
			document.forms[0].listSubcat4.options.add(novo);
	}
	}else{
		idOpcao.innerHTML = "--Vazio--";
		document.forms[0].cat4.style.display = 'none';
	}
}

function show1(element){
	if(document.getElementById(element).style.display = 'none'){
		document.getElementById(element).style.display = 'block'; }
}
function show2(id, visibility){
	document.getElementById(id).style.display = visibility;
}


function confirmar_excluir(valor){
	if(window.confirm ('Deseja realmente excluir esse anúncio?')){
		//window.alert(' Continuando.. ');
		location.href='Conta.php?produtos&excluir='+valor;
	}else{
		
	}
}

function confirmar_excluir2(valor){
	if(window.confirm ('Deseja realmente excluir esse anúncio?')){
		//window.alert(' Continuando.. ');
		location.href='Conta.php?services&excluir='+valor;
	}else{
		
	}
}

function endereco(valor1,valor2){
	window.open(valor1+"produto?loja="+valor2,"Endereço", 'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,width=617,height=595,top=190,left=350');
}


function abre(arquivo,metodo,div){
	try{ ajax = new ActiveXObject("Microsoft.XMLHTTP"); }
	catch(e){
		try{ ajax = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch(ex){
			try{ ajax = new XMLHttpRequest(); }
			catch(exc){
				alert("Esse browser não tem recursos para uso do Ajax");
				ajax = null;
			}
		}
	}
	div_base = "";
	valor = 0;
	valor++;
	div_base = div;
	ajax.open(metodo,arquivo+"&n="+valor);
	ajax.onreadystatechange=conteudo
	ajax.send(null)
}
function conteudo() {
	nova_div = div_base;
	//document.getElementById(nova_div).innerHTML="Verificando..."
	if(ajax.readyState==4){
		document.getElementById(nova_div).innerHTML=ajax.responseText
	}
}


function enviar_msg(valor1,valor2,valor3){
	window.open(valor1+"enviar-mensagem/"+valor2+"/"+valor3,"Mensagem", 'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,width=510,height=530,top=190,left=360');
}

