// JavaScript Document

var lastDivOpen = false;

function func_slideDiv (id) {
	
	//alert(id)
	if(document.getElementById("t").value != ""){
		lastDivOpen = document.getElementById("t").value
		document.getElementById("t").value = ""
	}
	
	if (lastDivOpen) {
		if (lastDivOpen != id) {
			$("#div_"+lastDivOpen).slideUp();
			$("#div_"+id).slideDown();
		}
	} else {
		$("#divResposta_"+id).slideDown();
	}
	lastDivOpen = id;
	
}

//função AJAX para reconhecer o browser
function getBrowser() {
if (window.XMLHttpRequest) { 
	a=new XMLHttpRequest(); } //Objeto nativo (FF/Safari/Opera7.6+)
else {
  try { 
	 a=new ActiveXObject("Msxml2.XMLHTTP");  //activeX (IE5.5+/MSXML2+)
  }   
  catch(e) {
	try { 
 a=new ActiveXObject("Microsoft.XMLHTTP"); //activeX (IE5+/MSXML1)
	}   
	catch(e) { /* O navegador nÃ£o tem suporte */ 
 a=false; 
	}
  }
} 
return a;
}


//função AJAX para executar a solicitação do usuario
function func_ajax(caminhoPagina,nomeDiv){
	valor = caminhoPagina
	ajax = getBrowser();
	if(ajax){
		ajax.open("GET",valor, true);
		ajax.onreadystatechange = function(){
			if(ajax.readyState != 4){
				document.getElementById(nomeDiv).innerHTML = "Carregando...";
			}
			if(ajax.readyState == 4){
				if(ajax.status == 200) {
					 document.getElementById(nomeDiv).innerHTML = ajax.responseText;
       			} else {
					document.getElementById(nomeDiv).innerHTML = "Não encontrado!"
      			}
			}
		}
		ajax.send(null);
	}
}


function func_abre(str){
	
	for(i=0; i < document.getElementById("totalR").value ; i++){
		
		document.getElementById("divPilotos"+i).style.display = 'none'
		
	}
	
	document.getElementById("divPilotos"+str).style.display = ''
}

function func_mudaCor(hexa, div){
	
	document.getElementById(div).style.backgroundColor = hexa;
	
}

function func_selecionaPiloto(cmpCh){
	
	if(document.getElementById(cmpCh).checked == true){
		
		document.getElementById(cmpCh).checked = false;

	}else{
		
		document.getElementById(cmpCh).checked = true;	
	
	}
}

function func_excluir(caminho){
	if(confirm("Você deseja excluir esse registro?")==true){
		window.location = caminho
	}
}

function func_redirect(caminho){
	
	window.location = caminho
}


