function GetXMLHttp() {
	if(navigator.appName == "Microsoft Internet Explorer"){
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		xmlHttp = new XMLHttpRequest();
	}
	return xmlHttp;
}

function abrirPag(valor){  
	var url = valor;  
	
	document.getElementById('ajaxContext').style.height = 'auto';
	$('#pane').jScrollPane({showArrows:true, scrollbarWidth: 9, arrowSize: 9});
	
	xmlRequest.open("GET",url,true);  
	xmlRequest.onreadystatechange = mudancaEstado;  
	xmlRequest.send(null);  
	
	return url;  
}  

function mudancaEstado(){  
	if (xmlRequest.readyState == 4){  
		document.getElementById("ajaxContext").innerHTML = xmlRequest.responseText;  
		$('#pane').jScrollPane({showArrows:true, scrollbarWidth: 9, arrowSize: 9});
	}  
}

function projetosEstado(uf){
	if(document.getElementById("caixa_estados") != null){
		$('#caixa_estados').slideDown(250);
		document.getElementById("caixa_estados").style.visibility = 'visible';
		if(document.getElementById('pane').style.display == 'none' || document.getElementById('pane').style.display == ''){
			document.getElementById('pane').style.display = 'block';
			$('#pane').jScrollPane({showArrows:true, scrollbarWidth: 9, arrowSize: 9});
		}
		document.getElementById('mapa').src = 'common/img/mapa_'+uf+'.gif';
		abrirPag('common/inc/projetos_estado.php?uf='+uf);
	}
}

function seta(tipo){
	if(tipo == 'right'){
		var seta = document.getElementById('setaright');
		if(seta.name == 'off'){
			seta.src = 'common/img/galeria/seta_right_on.gif';
			seta.name = 'on';
		}else if(seta.name == 'on'){
			seta.src = 'common/img/galeria/seta_right.gif';
			seta.name = 'off';
		}
	}else if(tipo == 'left'){
		var seta = document.getElementById('setaleft');
		if(seta.name == 'off'){
			seta.src = 'common/img/galeria/seta_left_on.gif';
			seta.name = 'on';
		}else if(seta.name == 'on'){
			seta.src = 'common/img/galeria/seta_left.gif';
			seta.name = 'off';
		}
	}
}

function galeria(id,dir){
	document.getElementById('imgMaior').src = 'common/img/galeria/'+dir+'/img'+id+'.jpg';
}

function pagina(tipo){
	// COMO USAR:
	// Insira na sua pagina o trexo de codigo abaixo:
	// <?php $n=8; $pasta='teatro'; include_once('common/inc/inc_galeria.php')?>
	
	// ONDE:
	//		$n = numero de imagens
	//		$pasta = nome do diretorio onde se encontra as imagens.
	//			Exemplo(common/img/galeria/NOME DO DIRETORIO/img1.jpg);
	
	// OBS: USAR SEMPRE O MESMO PADRÃO DE NOME PARA AS IMAGENS (img1.jpg, img2.jpg, img3.jpg, imgN.jpg, ...) Idem para as Thumbs.
	
	var i = 1;
	while((document.getElementById('pagina'+i) == null || document.getElementById('pagina'+i).style.display == 'none') && i<10){ i++; } // Limite de 10 paginas
	var pagina = document.getElementById('pagina'+i);
	var anterior = document.getElementById('pagina'+(i-1));
	var proximo = document.getElementById('pagina'+(i+1));
	
	if(tipo == 'proximo'){
		if(proximo != null){
			pagina.style.display = 'none';
			proximo.style.display = 'block';
		}
	}else if(tipo == 'anterior'){
		if(anterior != null){
			pagina.style.display = 'none';
			anterior.style.display = 'block';
		}
	}
}

/*
 DETECTAR SE O USUARIO POSSUI FLASH
*/
var strContentVersion = 5;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
	var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	for (var i = 0; i < words.length; ++i) {
		if (isNaN(parseInt(words[i])))
		continue;
		var strPluginVersion = words[i]; 
	}
	var strFlashCanPlay = strPluginVersion >= strContentVersion;
} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('strFlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & strContentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}