///////////////////////////////////////////////////////////////////////////////////
///		Funções da página CepAlterar.asp
///
///////////////////////////////////////////////////////////////////////////////////
try{
	xmlhttp2 = new XMLHttpRequest();
}catch(ee){
	try{
		xmlhttp2 = new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){
		try{
			xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(E){
			xmlhttp2 = false;
		}
	}
}


function carregaModeloP(){

	valor = document.getElementById('sltMarcaP').value;
	var url="../Inc/Ajax.php?tipoAcao=preencheComboModelo&MarcaId="+valor;
		
		//alert(url);
		//return false;
		
		//window.open(url);
		fila[fila.length] = ['sltModeloP',url,'preencheCombo']; // vai para ajax.js... 

		if( (ifila+1) == fila.length ){
			ajax();
		}
		
		document.getElementById('sltModeloP').disabled = false;
}
function carregaModelo(){
	valor = document.getElementById('sltMarca').value;
	var url="../Inc/Ajax.php?tipoAcao=preencheComboModelo&MarcaId="+valor;
		//window.open(url);
		fila[fila.length] = ['sltModelo',url,'preencheCombo']; // vai para ajax.js... 

		if( (ifila+1) == fila.length ){
			ajax();
		}
		
		document.getElementById('sltModelo').disabled = false;
}


function DeletarFoto(foto,anuncioId,NomeFoto,valor){
	
	document.frmCadastros.action = "Anuncio_Deletar_Imagem.php?AnuncioId="+anuncioId+"&CampoFoto="+foto+"&Arquivo="+NomeFoto;
	document.frmCadastros.submit();
	/*
		var url="../Inc/Ajax.php?tipoAcao=DeletarFoto&Foto="+foto+"&AnuncioId="+anuncioId+"&NomeFoto="+NomeFoto;
		window.open(url);
		return false;
		fila[fila.length] = ['tbFotos',url,'carregadiv']; // vai para ajax.js... 
		
		if( (ifila+1) == fila.length ){
			ajax();
		}
		document.getElementById('divInsereFoto'+valor).style.display = 'block';
		
	
*/
}
function carregaAnoFim(){
	valor = document.getElementById('sltAnoInicialP').value;
	var url="../Inc/Ajax.php?tipoAcao=preencheComboAnoFim&AnoIni="+valor;
		//window.open(url);
		fila[fila.length] = ['sltAnoFinalP',url,'preencheCombo']; // vai para ajax.js... 

		if( (ifila+1) == fila.length ){
			ajax();
		}
		
		document.getElementById('sltAnoFinalP').disabled = false;
}


function carregaEstado(){
		valor = document.getElementById('Regiao').value;
		var url = "CepAjax.asp?tipoAcao=preencheComboEstado&regiaoId="+valor;
		fila[fila.length] = ['estado',url,'preencheCombo'];  // 'estado' é o objeto a ser criado no preenche combo...
		if( (ifila+1) == fila.length ){
			ajax();
		}
		document.getElementById('cidade').options.length = 0; //deixa combo estado em branco
}

function carregaCidade(){
		valor = document.getElementById('estado').value;
		var url = "CepAjax.asp?tipoAcao=preencheComboCidade&estadoId="+valor;
		//window.open(url)
		fila[fila.length] = ['cidade',url,'preencheCombo']; 
		if( (ifila+1) == fila.length ){
			ajax();
		}
}


/* 		FormataReais()
		Autor: Francisco C Paulino - Tofinha (fcptofinha@globo.com) 
		Data: 08/11/2002 - 11:55hs
		Função: Script que formata Valores em reais ao digitar 
*/

function FormataReais(fld, milSep, decSep, e) {
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode == 13) return true;
		key = String.fromCharCode(whichCode);// Valor para o código da Chave
	if (strCheck.indexOf(key) == -1) return false; // Chave inválida
		len = fld.value.length;
	for(i = 0; i < len; i++)
		if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
			aux = '';
	for(; i < len; i++)
		if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
			aux += key;
	len = aux.length;
	if (len == 0) fld.value = '';
	if (len == 1) fld.value = '0'+ decSep + '0' + aux;
	if (len == 2) fld.value = '0'+ decSep + aux;
	if (len > 2) {
		aux2 = '';
		for (j = 0, i = len - 3; i >= 0; i--) {
			if (j == 3) {
				aux2 += milSep;
				j = 0;
			}
			aux2 += aux.charAt(i);
			j++;
		}
		fld.value = '';
		len2 = aux2.length;
		for (i = len2 - 1; i >= 0; i--)
			fld.value += aux2.charAt(i);
		fld.value += decSep + aux.substr(len - 2, len);
	}
return false;
}

/*
	tudoMaiusculo()
	Autor: Leonardo Barbosa
	Data: 06/08/2008
	Função: Converter a string digitada para caixa-alta

*/

function tudoMaiusculo(){
	alert(document.getElementById("tbPlaca").value);
	return false;
//letra = letra.toUpperCase();	
}

