// JavaScript Document

// Link Absoluto
var URLAbsoluta = "/"

//galeria de fotos 

function trocaFoto(qualFoto,qualLegenda,qualCaminho) {
	document.getElementById('aFoto').src = qualCaminho + qualFoto;
	document.getElementById('aFoto').name = qualFoto;
	document.getElementById('aFoto').alt = qualLegenda;
		
}

function abreFoto(qualFoto,qualLegenda,qualCaminho,qualArquivoAlta,textoFechar) {
	var oCaminho = qualCaminho 
	var ScrollTop;

	document.getElementById('aFotoAmp').src = oCaminho + qualFoto;	
	document.getElementById('lbxLegenda').innerHTML = qualLegenda;
	document.getElementById('spnFechar').innerHTML = textoFechar;
	document.getElementById('divLightbox').style.display = 'block';
	document.getElementById('divLightbox').style.position = 'absolute';
	
	if(qualArquivoAlta != '')
	{
	    document.getElementById('imgDownload').style.display = 'block';
	    document.getElementById('lnkDownload').style.display = 'block';
	    document.getElementById('lnkDownload').href = oCaminho + qualArquivoAlta;
	    document.getElementById('lnkDownload1').href = oCaminho + qualArquivoAlta;
	     document.getElementById('lnkDownload1').style.display = 'block';
	}
	else
	{
	    document.getElementById('imgDownload').style.display = 'none';
	    document.getElementById('lnkDownload').style.display = 'none';
        document.getElementById('lnkDownload1').style.display = 'none';
	}

	if (navigator.userAgent.indexOf('Firefox')!=-1){
	    // FIREFOX
        ScrollTop = window.pageYOffset;
        ScrollLeft = window.innerWidth;
        WindowHeight = document.documentElement.clientHeight;
	    document.getElementById('divLightbox').style.top = (ScrollTop + (WindowHeight/2)).toString() + 'px'; ;
	    document.getElementById('divLightbox').style.left =  ((ScrollLeft)/2).toString() + 'px';
    }
    else if (navigator.userAgent.indexOf('MSIE 6.0')!=-1){
	    // IE 6.0
        ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
        ScrollLeft = window.innerWidth;
        WindowHeight = document.documentElement.clientHeight;
	    document.getElementById('divLightbox').style.top = ScrollTop + (WindowHeight/2);
	    //document.getElementById('divLightbox').style.left =  (ScrollLeft)/2;
    }
    else {
        // IE
        ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
        ScrollLeft = document.body.offsetWidth;
        WindowHeight = document.documentElement.clientHeight;
	    document.getElementById('divLightbox').style.top = ScrollTop + (WindowHeight/2);
	    document.getElementById('divLightbox').style.left =  (ScrollLeft)/2;
    }
}

function abreFotoMiniGal(qualFoto,qualLegenda,qualAutor,qualCaminho,qualArquivoAlta,textoFechar) {
	var oCaminho = qualCaminho 
	var ScrollTop;

	document.getElementById('aFotoAmp').src = oCaminho + qualFoto;	
	document.getElementById('lbxAutorMiniGal').innerHTML = qualAutor;
	document.getElementById('lbxLegendaMiniGal').innerHTML = qualLegenda;
	document.getElementById('spnFechar').innerHTML = textoFechar;
	document.getElementById('divLightbox').style.display = 'block';
	document.getElementById('divLightbox').style.position = 'absolute';
	
	if(qualArquivoAlta != '')
	{
	    document.getElementById('imgDownload').style.display = 'block';
	    document.getElementById('lnkDownload').style.display = 'block';
	    document.getElementById('lnkDownload').href = oCaminho + qualArquivoAlta;
	    document.getElementById('lnkDownload1').href = oCaminho + qualArquivoAlta;
	     document.getElementById('lnkDownload1').style.display = 'block';
	}
	else
	{
	    document.getElementById('imgDownload').style.display = 'none';
	    document.getElementById('lnkDownload').style.display = 'none';
        document.getElementById('lnkDownload1').style.display = 'none';
	}

	if (navigator.userAgent.indexOf('Firefox')!=-1){
	    // FIREFOX
        ScrollTop = window.pageYOffset;
        ScrollLeft = window.innerWidth;
        WindowHeight = document.documentElement.clientHeight;
	    document.getElementById('divLightbox').style.top = (ScrollTop + (WindowHeight/2)).toString() + 'px'; ;
	    document.getElementById('divLightbox').style.left =  ((ScrollLeft)/2).toString() + 'px';
    }
    else if (navigator.userAgent.indexOf('MSIE 6.0')!=-1){
	    // IE 6.0
        ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
        ScrollLeft = window.innerWidth;
        WindowHeight = document.documentElement.clientHeight;
	    document.getElementById('divLightbox').style.top = ScrollTop + (WindowHeight/2);
	    //document.getElementById('divLightbox').style.left =  (ScrollLeft)/2;
    }
    else {
        // IE
        ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
        ScrollLeft = document.body.offsetWidth;
        WindowHeight = document.documentElement.clientHeight;
	    document.getElementById('divLightbox').style.top = ScrollTop + (WindowHeight/2);
	    document.getElementById('divLightbox').style.left =  (ScrollLeft)/2;
    }
}

function fechaLightbox() {
	document.getElementById('aFotoAmp').src = "/util/img/loader.gif"
	document.getElementById('divLightbox').style.display = 'none';
}



function popup(URL,largura,altura) {
	var width = largura;
	var height = altura;
	var left = 100;
	var top = 100;
	window.open(URL,'popup', 'width='+width+', height='+height+', top='+top+', left='+left+', toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, fullscreen=no');
}


/* GALERA DE VIDEOS */

//Lê idioma
function getURLParamLanguage(objId){
	var strLang;
  	var strHref = window.location.href;

	if ( strHref.indexOf("?") > -1 ){
    	var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    	var aQueryString = strQueryString.split("&");
    	
		//Idioma
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
    		if (aQueryString[iParam].indexOf(objId.toLowerCase() + "=") > -1 ){
        		var aParam = aQueryString[iParam].split("=");
        		strLang = aParam[1];
        		break;
      		}
    	}
		return strLang
	}
}

function getURLParamSubtitle(objId){
	var strLang;
  	var strHref = window.location.href;

	if ( strHref.indexOf("?") > -1 ){
    	var strQueryString = strHref.substr(strHref.indexOf("?"));
    	var aQueryString = strQueryString.split("&");
    	
		//Idioma
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
    		if (aQueryString[iParam].indexOf(objId + "=") > -1 ){
        		var aParam = aQueryString[iParam].split("=");
        		strLang = aParam[1];
        		break;
      		}
    	}
		return strLang
	}
}

function getURLParamFile(objFile){
	var strFile = "";
  	var strHref = window.location.href;

	if ( strHref.indexOf("?") > -1 ){
    	var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    	var aQueryString = strQueryString.split("&");
    	
	
		//Arquivo
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
    		if (aQueryString[iParam].indexOf(objFile.toLowerCase() + "=") > -1 ){
        		var aParam = aQueryString[iParam].split("=");
        		strFile = aParam[1];
        		break;
      		}
    	}
		
		return strFile
	}
}




//APOIE A CAMPANHA 

function trocaWallpaper(idObj, locale) {
	
	var pasta = URLAbsoluta + 'util/downloads/' + locale + '/';
	
	//Troca a imagem grande
	document.getElementById("thumbWall").src = pasta + 'thumbs/wallpapers/182x136/' + idObj + '.jpg';
	
	//Altera os links
	document.getElementById("linkWall800").href = pasta + 'wallpaper/computador/800x600/' + idObj + '.jpg';
	document.getElementById("linkWall1024").href = pasta + 'wallpaper/computador/1024x768/' + idObj + '.jpg';


}

function trocaScreensaver(idObj, locale) {
	
	var pasta = URLAbsoluta + 'util/downloads/' + locale + '/';
	
	//Troca a imagem grande
	document.getElementById("thumbScreen").src = pasta + 'thumbs/screensavers/182x136/'+idObj+'.jpg';
	
	//Altera os links
	document.getElementById("linkScreen").href = pasta + 'screensaver/'+idObj+'.zip';

}



//RIO 2016 HOME - AJUSTAR ALTURA DOS BOXES

 function boxHeightSet() {
 	
		for(var ind=1;ind<=3;ind++) {
			
			var boxEsq = document.getElementById("boxLinha"+ind+"_Esq").offsetHeight;
			var boxDir  = document.getElementById("boxLinha"+ind+"_Dir").offsetHeight;
	
			if (boxEsq > boxDir) {
				document.getElementById("boxLinha"+ind+"_Dir").style.height = boxEsq;
			} else if (boxEsq < boxDir) {
				document.getElementById("boxLinha"+ind+"_Esq").style.height = boxDir;
			}
		}
}

//flash

function montaSWF(url,width,height,FlashVars)
{
    var ret = '';
    ret += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" wmode="transparent" id="MemoConteudo" width="' + width + '" height="' + height + '" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">';
    ret += '<param name="movie" value="' + url + '" />';
    ret += '<param name="quality" value="high" />';
    ret += '<param name="bgcolor" value="#FFFFFF" />';
    ret += '<param name="wmode" value="transparent" />';
    ret += '<param name="allowScriptAccess" value="always" />';
    ret += '<param name="FlashVars" value="' + FlashVars + '" />';
    ret += '<embed src="' + url + '" wmode="transparent" quality="high" bgcolor="#FFFFFF" width="' + width + '" height="' + height + '" name="MemoConteudo" id="MemoConteudo" align="middle" play="true" loop="false" FlashVars="' + FlashVars + '" quality="high" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer">';
    ret += '</embed>';
    ret += '</object>';
    document.write(ret);
}

function adicionaFavoritos(title,url) 
{
    if (window.sidebar) 
    { 
        window.sidebar.addPanel(title, url,""); 
    } 
    else if( document.all ) 
    {
        window.external.AddFavorite( url, title);
    } 
    else if( window.opera && window.print ) 
    {
        return true;
    }
}

function fecharDhtml() {
    document.getElementById("Dhtml").style.display="none";
}
