/*FUNÇÃO SLIDE DESTAQUES*/
$(document).ready(
	function() {
		/* SLIDE */
		var legenda = $("#legenda");
		
		legenda.css("opacity", 0.8);
		
		$(".imagens-slide").cycle({
			fx: "turnLeft",
			speed: 500,
			timeout: 4000,
			next: "#voltar",
			prev: "#avancar",
			pause: 1,
			before: showHidePaleta,
			after: mostraLegenda
		});
		
		function mostraLegenda() {
			legenda.html("<a href='" + this.href + "' target='"+this.target+"'>" + $(this).attr("rel") + "</a>");
			legenda.slideDown(300);
		}
		function showHidePaleta() {
			legenda.slideUp(300);
			legenda.empty();
		}
	}
);


/*FUNÇÃO TOOLTIPS*/
$(function() {
	$('.tooltip').tooltip({
		track: true,
		delay: 0,
		showURL: false,
		showBody: " - ",
		fade: 100
	});
})

/*LIGHTBOX*/
$(function() {
        $('.lightbox').lightBox();
});

/*RETORNO ENVIO DE FORMULARIO*/

function Retorno() {
	var obj = document.getElementById('tela2');
	var obj2 = document.getElementById('retorno');
	if(obj.style.display == "none") {
  		obj.style.display = "";
		obj2.style.display = "";
 	} else {
  		obj.style.display = "none";
		obj2.style.display = "none";
 	}	
}
function mostraOculta(ObjMu) {
	var val2=document.getElementById(ObjMu);
	if(val2.style.display == "none") {
  		val2.style.display = "";
 	} else {
  		val2.style.display = "none";
 	}
}
/*FUNÇÃO AJAX*/

var navegador = navigator.userAgent.toLowerCase(); //Cria e atribui à variável global 'navegador' (em caracteres minúsculos) o nome e a versão do navegador

//Cria uma variável global chamada 'xmlhttp'
var xmlhttp; 


//Função que inicia o objeto XMLHttpRequest

function objetoXML() {

if (navegador.indexOf('msie') != -1) { //Internet Explorer

var controle = (navegador.indexOf('msie 5') != -1) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP'; //Operador ternário que adiciona o objeto padrão do seu navegador (caso for o IE) à variável 'controle'

try {

xmlhttp = new ActiveXObject(controle); //Inicia o objeto no IE

} catch (e) { }

} else { //Firefox, Safari, Mozilla

xmlhttp = new XMLHttpRequest(); //Inicia o objeto no Firefox, Safari, Mozilla

}

}

/*ENVIAR FORMULARIO*/

function enviarForm(url, campos, destino, Nform) {
Retorno();

//Atribui à variável 'elemento' o elemento que irá receber a página postada
var elemento = document.getElementById(destino); 
//Executa a função objetoXML()
objetoXML(); 
//Se o objeto de 'xmlhttp' não estiver true
if (!xmlhttp) {
//Insere no 'elemento' o texto atribuído
elemento.innerHTML = 'Impossível iniciar o objeto XMLHttpRequest.'; 

return;

} else { 

//Insere no 'elemento' o texto atribuído
elemento.innerHTML = 'Processando...'; 

}

xmlhttp.onreadystatechange = function () {

//Se a requisição estiver completada
if (xmlhttp.readyState == 4 || xmlhttp.readyState == 0) { 

//Se o status da requisição estiver OK
if (xmlhttp.status == 200) {
//Insere no 'elemento' a página postada
elemento.innerHTML = xmlhttp.responseText;
document.getElementById(Nform).reset();
} else { 

//Insere no 'elemento' o texto atribuído
elemento.innerHMTL = 'Página não encontrada!'; 

}

}

}

//Abre a página que receberá os campos do formulário
xmlhttp.open('POST', url+'?'+campos, true);
//Envia o formulário com dados da variável 'campos' (passado por parâmetro)
xmlhttp.send(campos); 


}
