﻿

function criaXMLHttp() {
	if (typeof XMLHttpRequest != "undefined") 
		return new XMLHttpRequest();
	else if (typeof ActiveXObject != "undefined") { // suporte ao IE 7
		var aVersoes = ["MSXML2.XMLHttp.6.0", "MSXML2.XMLHttp.5.0",
		"MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0",
		"MSXML2.XMLHttp", "Microsoft.XMLHttp"
		];
		for (var i = 0; i < aVersoes.length; i++){
			try{
				return new ActiveXObject(aVersoes[i]);
			}catch (e) {}
		}
	}
	// se nenhum objeto xmlhttp for suportado
	throw new Error("Seu browser nao suporta AJAX");
}

function abrePagina(url,div){
	var oXMLHttp = criaXMLHttp();
	oXMLHttp.open("get",url, true);
	oXMLHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	oXMLHttp.onreadystatechange = function (){

		if(oXMLHttp.readyState == 1)
			abrePaginaExibir('<p>Carregando......</p>',div);
		if(oXMLHttp.readyState == 4)
			abrePaginaExibir(oXMLHttp.responseText,div);
	};
	oXMLHttp.send(null);
}
function abrePaginaExibir(sTxt,div){
    var divStatus = document.getElementById(div);
	divStatus.innerHTML = sTxt;
}



$(function(){
	//Funções para compatibilidade dos IEs
	if (jQuery.browser.msie) {
		//Adiciona o :hover a todos os elementos no IE6, através da class .hover
		if(parseInt(jQuery.browser.version) == 6){
			$("button, li, a, h3, tr, img, .border2")
				.hover(
					function(){ $(this).addClass("hover") },
					function(){ $(this).removeClass("hover") }
				)
		}
		//-----
		//Adiciona o :focus a todos os elementos nos IEs, através da class .focus
		$("input, textarea, a, button, h3")
			.focus(function(){ $(this).addClass("focus") })
			.blur(function(){ $(this).removeClass("focus") })
		//-----
	}
	//-----
	
	//transparencia_divs_do_meio
	$('.clientes img').fadeTo('slow',0.2);
	$('.clientes img').hover(function(){$(this).fadeTo('slow',1.0)},
	function(){$(this).fadeTo('slow',0.2)}
	)
	//fim: transparencia_divs_do_meio
	
	// Indique a um amigo
	$(".indique").click(function(){ $("#indicar").animate({'top':'0'}, 'fast') })
	$("#indicar button").click(function(){ $("#indicar").animate({'top':'-200px'}, 'fast') })
	//-----
	
	// Muda o texto a direita ao passar o mouse sobre os links
	$('.clientes a, .clientes a').hover(function(){
		$('.pessoaltxt h2').text($(this).text());
		$('.pessoaltxt span').text($(this).attr("title"));
	}, function(){
	});
	//-----
	
	// Muda o texto a direita ao passar o mouse sobre os links
	$('#mapa_atuacao a').hover(function(){
		var a = $(this);
		//$('.pessoaltxt h2').text($(a + ' h2').text());
		$('.pessoaltxt span').html($(a).html());
	}, function(){
	});
	//-----
	
	jQuery(function(){jQuery('a.topo').click(function(e){var $c = jQuery(this).parents();$c.stop().scrollTo( 0, {speed:1000,axis:$c.attr('id'), queue:true} );});});
	
	function toggle(el, alvo){
	$(el).click(function(){
		$(this).toggleClass("expanded").blur()
		$(alvo).slideToggle()
	})
	};
});
