
function PararVT(){
		document.getElementById('MP').stop();
}
function Inicio(){
 document.getElementById('anun').style.display='none';
 document.getElementById('conta').style.display='none';
 //window.setTimeout("PararVT();",1000); //PARA A EXECUIÇÃO DO VÍDEO
 window.onscroll = MoverCaixa2; //MOVE IFRAME DE ACORDO COM O DESLOCAMENTO DAS BARRAS DE ROLAGEM
 el = document.getElementsByTagName('ljTxt');
 el = document.getElementsByTagName('div');
 for(i=0;i<el.length;i++){
  var e=el[i];
  if(e.id=='logo'){ e.innerHTML="<a href='http://www.meucarango.com'><img src='img/logo_carango.png' border=0></a>";  } 
  if(e.id=='BtC1'){ 
  	//e.innerHTML="<table class=Bt2><tr><td align=right>"+e.innerHTML+"</td><td><img src='img/bt_seta2.png'></td></tr></table>"; 
	e.onclick = MostrarConta;	
  } 
 // if(e.id=='conta'){ e.onclick = alert; }
  if(e.id=='BtC2' || e.id=='BtC3'){ e.innerHTML="<table class=Bt2a><tr><td align=center width=145>"+e.innerHTML+"</td><td><img src='img/bt_seta.png'></td></tr></table>"; } 
  if(e.id=='BtC4' ){ e.innerHTML="<table class=Bt2b><tr><td align=center>"+e.innerHTML+"</td><td width=20><img src='img/bt_seta.png'></td></tr></table>"; } 
  if(e.id=='BtC5' ){ e.innerHTML="<table class=Bt2c><tr><td align=center>"+e.innerHTML+"</td><td width=20><img src='img/bt_seta.png'></td></tr></table>"; }
  if(e.id=='sites'){ e.innerHTML="Sites do grupo:&nbsp;&nbsp;&nbsp;<a href='http://www.meucarango.com/tv' target='_blank'>meucarango.com/tv</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href='http://www.guiameucarango.com.br' target='_blank'>guiameucarango.com.br</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href='http://www.usadonovo.com.br' target='_blank'>usadonovo.com.br</a>"; }
  if(e.id=='regiao'){ 
  	if (document.getElementById('sUf').innerHTML.length==2){ valor=document.getElementById('sUf').innerHTML}
	else{valor="Nordeste";}
	e.innerHTML="<table><tr><td align=right class=txt>"+e.innerHTML+"</td><td><table cellpadding=0 cellspacing=0><tr><td><img src='img/combo_left.png'></td><td><DIV class=relativo><div id=Ufs></div></div></td><td><input id=UfsT class=borda2 value='"+valor+"'></td><td width=3></td><td background='img/combo_right.gif'><div id=Cb1>&nbsp;</div></td></tr></table></td></tr></table>"; 
  } 
  if(e.id=='BtO1' || e.id=='BtO2' || e.id=='BtO3' || e.id=='BtO4' || e.id=='BtO5' || e.id=='BtO6' || e.id=='BtO7' || e.id=='BtO8'){
  	e.onmouseover = Alterar;
	e.onmouseout = Alterar;
  }
  if(e.id==document.getElementById('sMenu').innerHTML && e.id!=''){e.style.backgroundImage="url('img/bg_cinza2.gif')";}
  if(e.id=='Ufs'){
   	 e.style.display='none';
 	 e.innerHTML="<div id=uf lang=Ufs>Nordeste</div><div id=uf lang=Ufs>AL</div><div id=uf lang=Ufs>BA</div><div id=uf lang=Ufs>PB</div><div id=uf lang=Ufs>PE</div><div id=uf lang=Ufs>RN</div><div id=uf lang=Ufs>SE</div>";
  }
  if(e.id.indexOf('Txt')==2){e.style.display='none';}
 }
 el = document.getElementsByTagName('div');
 for(i=0;i<el.length;i++){
  var e=el[i];
  if(e.id=='uf'){
  	e.onmouseover = AlterarCombo;
	e.onmouseout = AlterarCombo;
	if(e.lang.indexOf('.asp')>0){e.onclick = ClicarComboL;}
	else{e.onclick = ClicarCombo;}
  }
  if(e.id=='Cb1'){
  	e.style.cursor='pointer';
 	e.onclick = MostrarCombo;
  }
 } 
 el = document.getElementsByTagName('input');
 for(i=0;i<el.length;i++){
  var e=el[i];
  if(e.size*1==100){
	e.onfocus = ClicarI;
  }else{e.readOnly=false;}
  if(e.type=='image'){
	e.onclick = MostrarCombo2;
  }
 } 
 e = document.getElementById('dir');
 e.innerHTML=document.getElementById('PLat').innerHTML; 
 e = document.getElementById('pub2');
 e.innerHTML=document.getElementById('B4').innerHTML;
 e = document.getElementById('centro');
 //e.innerHTML=e.innerHTML.replace(/ftmin/g,"../ftmin");
 //e.innerHTML=e.innerHTML.replace(/ftgnd/g,"../ftgnd");
 //e.innerHTML=e.innerHTML.replace(/imagens/g,"../imagens");
 //e.innerHTML=e.innerHTML.replace(/desenhos/g,"../desenhos");
 //e.innerHTML=e.innerHTML.replace(/favoritos[/]/g,"../favoritos/");
 //e.innerHTML=e.innerHTML.replace(/fotogrd.asp/g,"../fotogrd.asp");
 //e.innerHTML=e.innerHTML.replace(/faixapreco.asp/g,"../faixapreco.asp");
 //e.innerHTML=e.innerHTML.replace(/enviamail.asp/g,"../enviamail.asp");
 //e.innerHTML=e.innerHTML.replace(/anuncieAQUI.swf/g,"../anuncieAQUI.swf");
 //e.innerHTML=e.innerHTML.replace(/estilo[/]/g,"../estilo/");
 //e.innerHTML=e.innerHTML.replace(document.getElementById('pub2').innerHTML,"");
 //e = document.getElementById('publicidade');
 //e.innerHTML=e.innerHTML.replace(/desenhos/g,"../desenhos");
 e = document.getElementById('buscas');
 e.style.display='';
 //document.onkeyup = VerTecla;
 document.onkeydown = VerTecla;
 window.setTimeout("try{document.getElementById('floater').style.display='none';}catch(err){}",30000);
 //window.setTimeout("try{document.getElementById('floater2').style.display='none';}catch(err){}",30000);
 try{ 
 	for(i=2;i<5;i++)
		document.getElementById("m"+i+"D").style.display='none';				
 }catch(err){}
}
function VerTecla(evt){
	var combo="";	
	var cb=document.getElementById('ljTxt');
	if(cb.style.display==""){combo='ljTxt';}
	cb=document.getElementById('ccTxt');
	if(cb.style.display==""){combo='ccTxt';}
	if(combo.length>0){	  
	  var keyCode = (window.event)?event.keyCode:evt.which;
	  if(document.activeElement.type!="text" && document.activeElement.type!="password" && keyCode!=27){
		cb=document.getElementById(combo);
		var txt=cb.innerHTML.toUpperCase();
		var dv=txt.split("</DIV>");
		if(keyCode==40 || keyCode==38){
			if(keyCode==40){ 
				cb.scrollTop = cb.scrollTop + 16;
			}else{
				cb.scrollTop = cb.scrollTop - 16;
			}
			return false;
		}else{			
		  for(i=0;i<(dv.length-1);i++){			
			letra = dv[i].split(">");						
			if(letra[1].charCodeAt(0)*1>=keyCode*1)				
				break;
		  }		
		  cb.scrollTop = i*16;		    
		}
	  }else{
		try{
		  cb=document.getElementById(combo);
		  cb.style.display="none";
		}catch(err){}
	  }
	}		
}
var ComboVisivel;
function MostrarCombo2(){
	ComboVisivel=this.id;
	el = document.getElementsByTagName('input');
 	for(i=0;i<el.length;i++){
  		var e=el[i];
  		if(e.type=='image' && e.id!=this.id){  
		  try{
			var cb=document.getElementById(e.id+'Txt');	
			cb.style.display='none';
		  }catch(erro) {}
		}
 	} 
	var cb=document.getElementById(this.id+'Txt');
	if(this.id=='lj'){ 
		if(cb.style.display=='none'){
			cb.style.display='';
			if(cb.innerHTML.indexOf('Aguarde...')>0)
				MontarComboXML('combolojas_xml.asp?tp=0&uf='+document.getElementById('sUf').innerHTML+'&t='+Math.random(), 'ljTxt');
		}else{cb.style.display='none';}
	}else if(this.id=='cc'){ 
		if(cb.style.display=='none'){
			cb.style.display='';
			if(cb.innerHTML.indexOf('Aguarde...')>0)
				MontarComboXML('combolojas_xml.asp?tp=1&uf='+document.getElementById('sUf').innerHTML+'&t='+Math.random(), 'ccTxt');
		}else{cb.style.display='none';}
	}else if(this.id=='cd'){ 
		window.location.href="carro.asp?pg=totais.asp&tipo=cidade&op=2";
	}else if(this.id=='mr'){ 
		window.location.href="carro.asp?pg=totais.asp&tipo=marca&op=1";
	}else{
            try{
		if(cb.style.display==''){
			cb.style.display='none';
		}else{cb.style.display='';}
            }catch(erro) {}
	}
}
function ClicarI(){
	this.blur();
}
function ClicarCombo(){
	document.getElementById(this.lang).style.display='none';
	document.getElementById(this.lang+'T').value=this.innerHTML;	
	document.location.href='carro.asp?pg=home.asp&uf='+this.innerHTML.replace('Nordeste','&op=all&comb=1');
}
function ClicarComboL(){
	document.getElementById(ComboVisivel+'TxtT').value=this.innerHTML;
	document.getElementById(ComboVisivel+'Txt').style.display='none';
	document.location.href=this.lang;
	//alert(this.lang);	
}
function MostrarCombo(){
	var cb=document.getElementById('Ufs');
	if(cb.style.display==''){
		cb.style.display='none';
	}else{cb.style.display='';}
}
function MostrarConta(){
	//alert(this.id);
	if(document.getElementById('conta').style.display==''){
		document.getElementById('conta').style.display='none';
		document.getElementById('pub2').style.display='';		
	}else{
		document.getElementById('u').value="";
		document.getElementById('p').value="";		
		document.getElementById('conta').style.display='';
		document.getElementById('pub2').style.display='none'
		document.getElementById('u').focus();
	}
}
function AlterarCombo(){
	if(this.style.backgroundImage==''){
		this.style.backgroundImage="url('img/bg_orange.gif')";
		this.style.backgroundPosition="0px -15px";
		this.style.color="white";
	}else{this.style.backgroundImage="";this.style.color="black";}
}
function Alterar(){
	if(this.style.backgroundImage==''){
		this.style.backgroundImage="url('img/bg_orange.gif')";
		if(this.innerHTML.indexOf('Anunciar')>0){
			document.getElementById('anun').style.display='';
		}
	}else if(this.style.backgroundImage.indexOf('bg_orange.gif')>0){
		this.style.backgroundImage="";
		if(this.innerHTML.indexOf('Anunciar')>0){
			document.getElementById('anun').style.display='none';
		}
	}
}
//############################################ SCROLL ############################################
function MoverCaixa2(){	
			MyEval('DBox','style.top', document.documentElement.scrollTop+'px');
			MyEval('DBox','style.left', document.documentElement.scrollLeft+'px');
			MyEval('iDBox','style.top', document.documentElement.scrollTop+'px');
			MyEval('iDBox','style.left', document.documentElement.scrollLeft+'px');
}	
//############################################ BUSCA ############################################
function EnviarPesq(obj){
		if(obj.txtcarro.value.length>0){
		 	obj.action=obj.action+"&busca="+obj.txtcarro.value;
			return true;
		}else{alert('Digite a marca ou o modelo do veículo!');obj.txtcarro.focus(); return false;}
	}
//############################################ BANNERS ############################################
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//############################################ D H T M L ############################################
var CBox;
function MontarComboXML(cmd,combo){
	CBox=combo;
	if (document.getElementById){ //Verifica se o Browser suporta DHTML.
		if (window.XMLHttpRequest) 
		{
			HttpReq = new XMLHttpRequest();
			HttpReq.onreadystatechange = XMLHttpTxt;
			HttpReq.open("GET", cmd, true);
			HttpReq.send(null);
		} 
		else if (window.ActiveXObject) 
		{
			HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpReq) 
			{
				HttpReq.onreadystatechange = XMLHttpTxt;				
				HttpReq.open("GET", cmd, true);
				HttpReq.send();
			}
		}
	}
}
function XMLHttpTxt(){  
	if (HttpReq.readyState == 4 && HttpReq.status == 200){
		var result = HttpReq.responseXML;
		var serie = result.getElementsByTagName("loja");
		document.getElementById(CBox).innerHTML="";
		if(serie.length>15){document.getElementById(CBox).style.height='179px';}
		//alert(serie.length);
		for (var i = 1; i <= serie.length*1; i++){
			new_opcao = create_opcao(serie[i-1]);
			document.getElementById(CBox).appendChild(new_opcao);
		}
		el = document.getElementsByTagName('div');
 		for(i=0;i<el.length;i++){
  		  var e=el[i];
  		  if(e.id=='uf' && e.lang.length>10){
  			e.onmouseover = AlterarCombo;
			e.onmouseout = AlterarCombo;
			e.onclick = ClicarComboL;}
  		}
		
	}
}

function create_opcao(serie) 
{ 
	var new_opcao = document.createElement("DIV"); 
	var texto = document.createTextNode(serie.childNodes[0].data); 	
	new_opcao.setAttribute("id","uf"); 		
	
	new_opcao.setAttribute("lang","carro.asp?loja="+serie.childNodes[0].data.replace("&","")+"&pg=verloja.asp&codloja="+serie.getAttribute("id")+"&tp="+serie.getAttribute("tp"));
	new_opcao.setAttribute("title",serie.childNodes[0].data);	
	new_opcao.appendChild(texto); //Adiciona o texto a OPTION.
	return new_opcao; // Retorna a nova OPTION.
	//new_opcao.innerHTML= texto;
	//new_opcao.setAttribute("id",serie.getAttribute("id")); 
}
//############################################ L O G I N ############################################
function SelLogin(){
	u=document.getElementById('u').value;
	p=document.getElementById('p').value;
	if(u.length>0){
	  if(p.length>0){
		if(u.indexOf('@')<1){
			document.getElementById('frmljuser').value=u;
			document.getElementById('frmljpass').value=p;
			document.getElementById('fLoja').submit();
		}else{
			document.getElementById('user').value=u;
			document.getElementById('pass').value=p;
			document.getElementById('fPart').submit();
		}
	  }else{alert('Digite a senha!');document.getElementById('p').focus(); }
	}else{alert('Digite seu usuário!');document.getElementById('u').focus(); }
	return false;
}
function Esqueci(){
	u=document.getElementById('u').value;
	if(u.length>0){
		if(u.indexOf('@')<1){
                      window.open("Novo/LerSenha.asp?user="+u,"Altera");
		}else{
                      window.open("particular2008/partsenha.asp?user="+u,"Altera");
		}
	}else{alert('Preencha corretamente o campo Usuário e clique novamente em Esqueci!');document.getElementById('u').focus(); }
}
//############################################ N O T Í C I A ############################################
function MostrarNoticia(cod){
	document.getElementById('iDBox').style.display='';
	document.getElementById('DBox').style.display='';
	document.getElementById('mapBox').style.display='none';
	document.getElementById('fecBox').style.display='';
	document.getElementById('notBox').style.display='';
	window.open('detnoticia.asp?c='+cod,'not2'); 
	//alert(cod);
}
//############################################ B A N N E R ############################################
function Esconde(){
	document.getElementById('BFlash').style.display='none';
}
function close(){
    try{
	document.getElementById('floater').style.display='none';}
    catch(err){}
    try{
	document.getElementById('BFlash').style.display='none';}
    catch(err){}
}
function closeG(){
	document.getElementById('floaterG').style.display='none';
}
//############################################ A B A S ############################################
function MudarAba(aba){
		try{
			for(i=1;i<5;i++){
				document.getElementById("m"+i).style.background='url(img/bg_m'+i+'_off.png)';
				document.getElementById("m"+i+"D").style.display='none';	
				document.getElementById("m"+i+"A").style.color='white';		
			}
		}catch(err){}
		document.getElementById(aba).style.background= 'url(img/bg_'+aba+'_on.png)';
		document.getElementById(aba+"D").style.display= '';
		document.getElementById(aba+"A").style.color='#666666';	
		//="img/bg_"+aba+"_on.png";	
	}
