/*|---------------------------------->>  <<----------------------------------|

Include para ser usado na estrutura padrão dos sites. deve chamado 
no arquivo head.inc.php.

Sr. Programador, todas as funções em javascript que serão utilizadas no site
deverão serem declaradas apenas neste arquivo.

|---------------------------------->>  <<----------------------------------|*/
// Função abre nova janela
// utilização: 											PROPRIEDADES
//abrejanela('PAGINA.htm','TITULO','scrollbars=yes,resizable=no,width=500,height=400')"



function criaObjetoAjax(){
	
	var httprequest=null;
	/* Mozilla, Safari, FireFox ... */
    if( window.XMLHttpRequest ){
    	
       httprequest = new XMLHttpRequest();
        
    /* IE */
    } else if( window.ActiveXObject){
        try{
            httprequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e){
            try{
                httprequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    
    if(httprequest != null && httprequest != undefined){
		return httprequest;
    }else{
    	return null;
    } 
    
}


function fechar()
{
	document.getElementById('popup').style.display='none';
}

function refresh()
{
 location = 'ajaxcontador.php';
}
	function valida_login(fcad)
{
	if(fcad.usuario.value=='')
	{
		 alert('Campo login vazio.');
		 fcad.usuario.focus();
		 return false;
	}
	if(fcad.senha.value=='')
	{
		 alert('Campo senha vazio.');
		 fcad.senha.focus();
		 return false;
	}
 fcad.submit();
}
function janela(www,h,w)
{
var height = window.screen.height - 160;
var width = window.screen.width;
var top = (height- h)/2;
var left = (width - w)/2;
window.open(www,"nova","top=" + top + ",left="+ left +",width="+w+",height="+h+",toolbar=no,location=no,status=no,menubar=no,scrollbars=no,scrolling=no,resizable=no")
} 


function mostrar_texto(tblObj)
		{ 
		  var x = document.getElementById('teste');
		  if(tblObj.style.display=="none") {
			tblObj.style.display = "block";
			
		  }
		  else {
			tblObj.style.display = "none";
		  }
		 return false;
		}

								function createRequestObject(){
	var request_;
	var browser = navigator.appName;

	if(browser == "Microsoft Internet Explorer"){
	 	request_ = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
	 	request_ = new XMLHttpRequest();
	}

	return request_;
}

var http = createRequestObject();
function getInfo2(url){
	http.open('get', url);
	http.onreadystatechange = handleInfo;
	http.send(null);
}

function getInfo(){
   
	http.open('get','ajaxcontador.php');
	http.onreadystatechange = handleInfo;
	http.send(null);
}

function handleInfo(){
	/*if(http.readyState == 1){
	 	document.getElementById('cont').innerHTML = 'Loading...';
	}*/
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById('contador').innerHTML = response;
	}
}
var xmlhttp = createRequestObject();


function _getAjax (pagina, obj)
{
	//var getstr = "?";
	var getstr = "";//string que guardara os parametros passados via post
	var i;
	//******************************************************
	
	// Concatena POST pelo elements
	for (i=0; i<obj.elements.length; i++)
	{
		//alert(obj.elements[i].tagName);
			if (obj.elements[i].tagName == "TEXTAREA")
			{
				{
					getstr += obj.elements[i].name + "=" + escape(obj.elements[i].value) + "&"; }
			}
			if (obj.elements[i].tagName == "INPUT")
			{
				if (obj.elements[i].type == "text") 	{ getstr += obj.elements[i].name + "=" + escape(obj.elements[i].value) + "&"; }
				if (obj.elements[i].type == "hidden") 	{ getstr += obj.elements[i].name + "=" + escape(obj.elements[i].value) + "&"; }
				if (obj.elements[i].type == "password") { getstr += obj.elements[i].name + "=" + escape(obj.elements[i].value) + "&"; }
				if (obj.elements[i].type == "checkbox") {
					if (obj.elements[i].checked) { getstr += obj.elements[i].name + "=" + escape(obj.elements[i].value) + "&"; }
					else { getstr += obj.elements[i].name + "=&"; }
				}
				if (obj.elements[i].type == "radio")
				{
					if (obj.elements[i].checked) { getstr += obj.elements[i].name + "=" + escape(obj.elements[i].value) + "&"; }
				}
			}
			else if (obj.elements[i].tagName == "SELECT")
			{
				var sel = obj.elements[i];
				getstr += sel.name + "=" + escape(sel.options[sel.selectedIndex].value) + "&";
			}
	}
	
	
	_makeRequest (pagina, getstr);
	return false;//para retornar e naum enviar quando apertar enter
}




function getPage(url, campo){   
	
         	         	
         	
    //Abre a url
	
	var _httpRequest = criaObjetoAjax();
 	var conteudo=document.getElementById(campo);
	
	if(_httpRequest == null){
				
		alert('Requisição não aceita, tente novamente');
		return false;
		
	}else{
		
		conteudo.innerHTML='<img src="images/loading.gif" style="margin-top:40%;margin-left:38%;">';	
		document.body.scrollTop='0';
			
	} 
		
    _httpRequest.open("GET", url,true);

    //Executada quando o navegador obtiver o c?digo

    _httpRequest.onreadystatechange=function() {
        if (_httpRequest.readyState==4){
            
        	var texto = _httpRequest.responseText;
            
            //Exibe o texto no div conte?do
            var conteudo = document.getElementById(campo);

            conteudo.innerHTML = texto;
            
            var titulo = ':: ESTUDIO LIVRE ::';
            
           	ajaxHistory.add("document.getElementById('"+campo+"').innerHTML = unescape('"+escape(texto)+"');document.title = unescape('"+escape(titulo)+"');desabilitaDivsFlutuantes();");      	
            	
         	document.title = titulo;  	  
         	
         	        
            
        }
    }
    _httpRequest.send(null);
}



function getPageNoHistory(url, campo){   
	
         	         	
         	
    //Abre a url
	
	var _httpRequest = criaObjetoAjax();
 	var conteudo=document.getElementById(campo);
	
	if(_httpRequest == null){
				
		alert('Requisição não aceita, tente novamente');
		return false;
		
	}else{
		
		conteudo.innerHTML='<img src="images/loading.gif" style="margin-top:40%;margin-left:38%;">';	
		document.body.scrollTop='0';
			
	} 
		
    _httpRequest.open("GET", url,true);

    //Executada quando o navegador obtiver o c?digo

    _httpRequest.onreadystatechange=function() {
        if (_httpRequest.readyState==4){
            
        	var texto = _httpRequest.responseText;
            
            //Exibe o texto no div conte?do
            var conteudo = document.getElementById(campo);

            conteudo.innerHTML = texto;       	        
            
        }
    }
    _httpRequest.send(null);
}


function _makeRequest(url, parameters)
{
	
	
	var _httpRequest = criaObjetoAjax();
	
	if(_httpRequest == null){
		
		document.getElementById('load').style.display='none';
		if(document.getElementById('btnSalvar')!=null)
			document.getElementById('btnSalvar').disabled=false;
		
		alert('Requisição não aceita, tente novamente');
		return false;
		
	}else{
				
		document.getElementById('load').style.display='block';

		if(document.getElementById('btnSalvar')!=null)
			document.getElementById('btnSalvar').disabled=true;
			
	} 
	
	// Parâmetros para POST
	
	
	_httpRequest.onreadystatechange = function(){
		
		if (_httpRequest.readyState == 4)
		{			
			
			if (_httpRequest.status == 200)
			{
				
				document.getElementById('load').style.display='none';
				if(document.getElementById('btnSalvar')!=null)
					document.getElementById('btnSalvar').disabled=false;
				result = _httpRequest.responseText;
				eval(result);
			}			
		}	
	}
	
	
	_httpRequest.open('POST', url, true);
	_httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
	_httpRequest.setRequestHeader("Content-length", parameters.length);
	_httpRequest.setRequestHeader("Connection", "close");
	_httpRequest.send(parameters);

}


function _alertContents()
{
	if (_httpRequest.readyState == 4)
	{
		
		var status='';
		try{
			status = _httpRequest.status;
		}
		catch(e){
			alert('Problemas de conexão com a internet, verifique sua conexão e tente novamente.');
			document.getElementById('load').style.display='none';
			if(document.getElementById('btnSalvar')!=null)
				document.getElementById('btnSalvar').disabled=false;
			return false;
		}
		
		if (status == 200)
		{
			document.getElementById('load').style.display='none';
			if(document.getElementById('btnSalvar')!=null)
				document.getElementById('btnSalvar').disabled=false;
			result = _httpRequest.responseText;
			eval(result);
		}
		else
		{
			alert('Problemas de conexão com a internet, verifique sua conexão e tente novamente.');
			document.getElementById('load').style.display='none';
			if(document.getElementById('btnSalvar')!=null)
				document.getElementById('btnSalvar').disabled=false;
			return false;
		}
	}
}





function evita_letra3(tecla) {
	if (tecla.keyCode < 49 || tecla.keyCode > 57) 
		tecla.returnValue = false;
}
function FormataValor3(campo,tammax,teclapres) 
	{

		var tecla = teclapres.keyCode;
		var vr = campo.value;
		vr = vr.replace( "/", "" );
		vr = vr.replace( "/", "" );
		vr = vr.replace( ",", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		tam = vr.length;
	
		if (tam < tammax && tecla != 8){ tam = vr.length + 2 ; }
	
		if (tecla == 8 ){	tam = tam - 1 ; }
			
		if ( tecla == 8 || (tecla >= 48 && tecla <= 57) || (tecla >= 96 && tecla <= 105) ){
			if ( tam <= 2 ){ 
				campo.value = vr ; }
			tam = tam - 1;
			if ( (tam > 2) && (tam <= 5) ){
				campo.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam) ; }
			if ( (tam >= 6) && (tam <= 8) ){
				campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
			if ( (tam >= 9) && (tam <= 11) ){
				campo.value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
			if ( (tam >= 12) && (tam <= 14) ){
				campo.value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
			if ( (tam >= 15) && (tam <= 17) ){
				campo.value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam) ;}
		}
	}

	function valida_numero(ConteudoCampo)
	{
 		if ((((event.keyCode) > 47) && ((event.keyCode) < 58)))
		{
     		return(true);
		}
 		else 
		{
     		return(false);
		}
	}
	
	function FormataNumero2(Conteudo)
	{
		var teste;
		teste=String(Conteudo);
		
		Conteudo=String(Conteudo);
		var trocaP = /\./g;
		//var trocaP =".";
		var Flag=0;
		
		for (i = 0; (i < Conteudo.length); i++)
		{
			if(Conteudo.substr(i,1)==".")
			{
				Flag=1;
				
				var fim;
				
				fim=Conteudo.substr(i+1,Conteudo.length-i-1)
				Conteudo=Conteudo.substr(0,i+3);
			}
		}
		
	   	if(Flag==0)
		{
			Conteudo=String(Conteudo+".00");
		}

		NumDig = String(Conteudo);
	   	TamDig = NumDig.length;
	   	Contador = 0;
		Flag2=0;
		
	   if (TamDig > 0)
		{
			numer = "";
		  	for (i = TamDig; (i >= 0); i--)
			{
				
			  if ((parseInt(NumDig.substr(i,1))>=0) && (parseInt(NumDig.substr(i, 1))<=9))
				{
				 	Contador++;
				 	if ((Contador == 3) && Flag2==0)
				  	{
						numer = ","+numer;
				   		Contador = 0;
						Flag2=1;
				   	}
				 	else if ((Contador == 3) && Flag2==1)
				  	{
						numer = "."+numer;
				   		Contador = 0;
				  	}
				 	numer = NumDig.substr(i, 1)+numer;
				}
			}
			
		  	return numer;
			
		}
	}
	
function trimAll(sString) 
{
  while (sString.substring(0,1) == ' ')
   {
     sString = sString.substring(1, sString.length);
   }
  while (sString.substring(sString.length-1, sString.length) == ' ')
   {
     sString = sString.substring(0,sString.length-1);
   }
  return sString;
}


function rightTrim(sString) 
{
   while (sString.substring(sString.length-1, sString.length) == ' ')
    {
      sString = sString.substring(0,sString.length-1);
    }
      return sString;
}



function leftTrim(sString) 
{
   while (sString.substring(0,1) == ' ')
     {
       sString = sString.substring(1, sString.length);
     }
   return sString;
}


function formatar(src, mask) 
{
  var i = src.value.length;
  var saida = mask.substring(0,1);
  var texto = mask.substring(i)
if (texto.substring(0,1) != saida) 
  {
	src.value += texto.substring(0,1);
  }
}

function abrejanela(url,nome,propriedades){ 
   window.open(url,nome,propriedades);
}

//Checa o campo E-Mail
function verifica_mail(email){
	var campo = email;
	//se a "@" não existe e é o primeiro caractere 
	if (campo.indexOf("@") < 1) return false
	//se o caracter antes da "@" é "." 
	if(campo.charAt(campo.indexOf("@")-1) == ".") return false;
	//se a última incidência de "." está antes da @ 
	if (campo.lastIndexOf(".") <= campo.indexOf("@")) return false;
	//se o último caracter é ponto,
	if (campo.lastIndexOf(".")  == (campo.length-1)) return false; 
	
	return true;
}

function val_cnpj(numero) {
	//numero = numero1.value;
	dig_1 = 0;
	dig_2 = 0;
	controle_1 = 5;
	controle_2 = 6;

if ( (numero.length != 18)  || (numero.substring(2, 3) != ".") || (numero.substring(6, 7) != ".") || (numero.substring(10, 11) != "/") || (numero.substring(15, 16) != "-") ) {
     return false;
}else{ 
  	   numero = (numero.substring(0, 2)) + "" + (numero.substring(3, 6)) + "" + (numero.substring(7, 10))+ "" + (numero.substring(11, 15)) + "" + (numero.substring(16, 18)) 
	   for ( i=0 ; i < 12 ; i++) {
	        dig_1 = dig_1 + parseFloat(numero.substring(i, i+1) * controle_1);
	          controle_1 = controle_1 - 1;
	        if (i == 3) {
	           controle_1 = 9;
	        }
	   }
	   
	   resto = dig_1 % 11;
	   dig_1 = 11 - resto;
	   
	   if ((resto == 0) || (resto == 1)){
	        dig_1 = 0;
	   }
	   
	   for ( i=0 ; i < 12 ; i++) {
	        dig_2 = dig_2 + parseInt(numero.substring(i, i+1) * controle_2);
	          controle_2 = controle_2 - 1;
	        if (i == 4) {
	           controle_2 = 9;
	        }
	   }
	   
	   dig_2 = dig_2 + (2 * dig_1);
	   resto = dig_2 %11;
	   dig_2 = 11 - resto;
	   
	   if ((resto == 0) || (resto == 1)){
	        dig_2 = 0;
	   }
	   
	   dig_ver = (dig_1 * 10) + dig_2;
	   
	   if (dig_ver != parseFloat(numero.substring(numero.length-2,numero.length))) {
	          return false;
	   }
 }
 return true;
}

function FormataCPF(Campo, teclapres){

	var tecla = teclapres.keyCode;

	var vr = new String(Campo.value);
	vr = vr.replace(".", "");
	vr = vr.replace(".", "");
	vr = vr.replace(".", "");
	vr = vr.replace("/", "");
	vr = vr.replace("-", "");

	tam = vr.length + 1 ;

	
	if (tecla != 9 && tecla != 8){
		if (tam >= 10 && tam < 12) {
			Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,tam-9);
		} else if (tam >= 7 && tam < 10) {
			Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,tam-6);
		} else if (tam > 3 && tam < 7) {
			Campo.value = vr.substr(0, 3) + '.' + vr.substr(3, tam);
		}
	}
}

function FormataCNPJ(Campo, teclapres){

	var tecla = teclapres.keyCode;

	var vr = new String(Campo.value);
	vr = vr.replace(".", "");
	vr = vr.replace(".", "");
	vr = vr.replace("/", "");
	vr = vr.replace("-", "");

	tam = vr.length + 1 ;

	
	if (tecla != 9 && tecla != 8){
		if (tam > 2 && tam < 6)
			Campo.value = vr.substr(0, 2) + '.' + vr.substr(2, tam);
		if (tam >= 6 && tam < 9)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5);
		if (tam >= 9 && tam < 13)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8);
		if (tam >= 13 && tam < 15)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12);
		}
}

//Valida o cpf 
function val_cpf(numero2) {
  dig_1 = 0;
  dig_2 = 0;
  controle_1 = 10;
  controle_2 = 11;
  lsucesso = 1;
  
  var numero = numero2.substr(0,3) + numero2.substr(4,3) + numero2.substr(8,3) + numero2.substr(12,2);
  
  if (numero == "00000000000" || numero == "11111111111" || numero == "22222222222" || numero == "33333333333" || numero == "44444444444" || numero == "55555555555" || numero == "66666666666" || numero == "77777777777" || numero == "88888888888" || numero == "99999999999") {
  	return false;
  }
  
  if ((numero.length != 11) && (numero.length != 0)) {
     return false;
  }
  else {
     for ( i=0 ; i < 9 ; i++) {
        dig_1 = dig_1 + parseInt(numero.substring(i, i+1) * controle_1);
          controle_1 = controle_1 - 1;
     }
    
     resto = dig_1 % 11;
     dig_1 = 11 - resto;
     if ((resto == 0) || (resto == 1)) {
          dig_1 = 0;
     }
     for ( i=0 ; i < 9 ; i++) {
          dig_2 = dig_2 + parseInt(numero.substring(i, i + 1) * controle_2);
        controle_2 = controle_2 - 1;
     }
     dig_2 = dig_2 + 2 * dig_1;
     resto = dig_2 % 11;
     dig_2 = 11 - resto;
     if ((resto == 0) || (resto == 1)) {
        dig_2 = 0;
     }
     dig_ver = (dig_1 * 10) + dig_2;
     if (dig_ver != parseFloat(numero.substring(numero.length-2,numero.length))) {
          return false;
        }
  }

return true;
}

function abre_impressao(url) {
	window.open(url, "impressao", "width=600,height=450");
}
//Utilização: onkeypress="evita_letra(event)" onKeydown="FormataHora('NOMEDOCAMPO','NOMEDOFORM',event)" maxlength="5"
function FormataHora(campo,formname,teclapres){
	var tecla = teclapres.keyCode;
	vr = document[formname][campo].value;
	vr = vr.replace( ":", "" );
	tam = vr.length + 1;
	
	if ( tecla != 9 && tecla != 8 ){
		if ( tam > 2 && tam < 5 ){
			document[formname][campo].value = vr.substr( 0, tam - 2  ) + ':' + vr.substr( tam - 2, tam );
		}
	}
}
// FUNÇÃO QUE AUTOCOMPLETA DATA COM '/'
// COMO UTILIZAR:    onkeydown="FormataData(this.name,this.form.name,event);" 
function FormataData(campo,formname,teclapres) { // Máscara para os campos de data
	var tecla = teclapres.keyCode;
	vr = document[formname][campo].value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;

	if ( tecla != 9 && tecla != 8 ){
		if ( tam > 2 && tam < 5 )
			document[formname][campo].value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam );
		if ( tam >= 5 && tam <= 10 )
			document[formname][campo].value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 ); 
	}
}
// COMO UTILIZAR: onkeypress="evita_letra2(event)"
// Não permite digitar letras em um input type=text
function evita_letra2(tecla) {
	if (tecla.keyCode < 48 || tecla.keyCode > 57) 
		tecla.returnValue = false;
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function ToggleAll(checked) {
    len = document.listagem.elements.length;
    var i = 0;
    for(i = 0; i < len; i++) {
        document.listagem.elements[i].checked = checked;
    }
}

function in_array(s,a) {
  for (i = 0; i < a.lenght; i++) {
	  /*if (a[i] == s) {
	  	return true;
	  }*/
	  alert(a[i]+'=='+s.name);
  }
  //return false;
}
//Checa o campo E-Mail
function verifica_mail(email){
	var campo = email;
	//se a "@" não existe e é o primeiro caractere 
	if (campo.indexOf("@") < 1) return false
	//se o caracter antes da "@" é "." 
	if(campo.charAt(campo.indexOf("@")-1) == ".") return false;
	//se a última incidência de "." está antes da @ 
	if (campo.lastIndexOf(".") <= campo.indexOf("@")) return false;
	//se o último caracter é ponto,
	if (campo.lastIndexOf(".")  == (campo.length-1)) return false; 
	
	return true;
}


function exibeFlash(swf, width, height, wmode, cache)
{
	noCache = cache || cache == undefined ? "" : "?" + new Date();
	if(wmode==undefined) wmode="opaque";
	
	monta_swf = "";
	monta_swf += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\""+ width +"\" height=\""+ height +"\" title=\"\">";
	monta_swf += "<param name=\"movie\" value=\""+ swf + noCache +"\" />";
	monta_swf += "<param name=\"quality\" value=\"high\" />";
	monta_swf += "<param name=\"menu\" value=\"0\" />";
	monta_swf += "<param name=\"wmode\" value=\""+ wmode +"\" />";
	monta_swf += "<embed src=\""+ swf + noCache +"\" quality=\"high\" wmode=\""+ wmode +"\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+ width +"\" height=\""+ height +"\"></embed>";
	monta_swf += "</object>";
	
document.write(monta_swf);
}



/*galeria*/

function trocaFoto(id,idPasta,legenda){
	
	var diretorio="uploads/galeria/"+idPasta+"/";
	var peq='fotoPeq'+id;
	
	parent.document.getElementById('fotoGrande').src=diretorio+id+'.jpg';
	document.getElementById(peq).src=diretorio+id+'_thumb_pb.jpg';
	//parent.document.getElementById('fotoLegenda').innerHTML=legenda;
	
}
/*FIM - galeria*/



function trocaVideo(id){//troca a cor do link para saber qual video está tocando
	
	var obj = document.getElementById('videoAtual'); 
	var videoAnterior = obj.value; 
	
	if(videoAnterior!=0){
		//document.getElementById('video_'+videoAnterior).style.color = '#FFF;'; //troca a cor do video anterior
		document.getElementById('video_'+videoAnterior).className = 'titcur'; //troca a cor do video anterior
	}
	
	//document.getElementById('video_'+id).style.color = '#FFA200;'; //troca a cor do video atual
	document.getElementById('video_'+id).className = 'titcurSelec'; //troca a cor do video atual
	obj.value = id; //atualiza a galeria atual
}



function mudaDiv(nome)
{
	obj = document.getElementById(nome);
	if(obj.style.display=='none')
	{
		obj.style.display='block';		
	}else{
		obj.style.display='none';		
	}
}

function fecharDivFlutuante(div){
	document.getElementById(div).style.display='none';
	document.getElementById('lente').style.display='none';
	
	if(document.getElementById('player')!= null){
		document.getElementById('player').style.display='block';	
	}
}

function abreDivFlutuante(div){
	document.getElementById(div).style.display='block';
	document.getElementById('lente').style.display='block';	
	if(document.getElementById('player')!= null){
		document.getElementById('player').style.display='none';
	}
}

function abreEnquete(){
	
	 getPageNoHistory('enqueteResultado.php','enqueteFlutuante');
	 abreDivFlutuante('divFlutuanteResultado');
	
	 var titulo = ':: ESTUDIO LIVRE - ENQUETE ::';
	 ajaxHistory.add("abreEnquete();");
	 document.title = titulo; 
         	
}

function abreContato(){
	
	 getPageNoHistory('contato.php','contatoFlutuante');
	 abreDivFlutuante('divFlutuanteContato');
	
	 var titulo = ':: ESTUDIO LIVRE - CONTATO ::';
	 ajaxHistory.add("abreContato();");
	 document.title = titulo; 
	
         	
}

function abreVideo(id,tabela,abrev){
	
	trocaVideo(unescape(id));
	getPageNoHistory('ajaxVideo.php?id='+escape(id)+'&tabela='+tabela+'&abrev='+abrev,'player');
	
	var titulo = ':: ESTUDIO LIVRE - VÍDEOS ::';
	ajaxHistory.add("abreVideo('"+id+"','"+tabela+"','"+abrev+"');desabilitaDivsFlutuantes();");
	document.title = titulo; 
         	
}

function desabilitaDivsFlutuantes(){
	
	var obj = document.getElementById('displaydivFlutuanteEmail');
	var obj2 = document.getElementById('divFlutuanteResultado');
	var obj2 = document.getElementById('divFlutuanteContato');
	var obj3 = document.getElementById('player');
	var obj4 = document.getElementById('lente');
	
	if(obj!=null)
		obj.style.display='none';
	
	if(obj2!=null)
		obj2.style.display='none';
	
	if(obj3!=null)
		obj3.style.display='block';
		
	if(obj4!=null)
		obj4.style.display='none';
	
}