﻿// JScript source code

// 116 home
// 117 publicidade
// 126 editorial
// 124 cenas
// 127 cd
// 128 dam

function MontaMenu(menu, pageInit, preferencia)
{
    if (pageInit != true)
    {
        if (MenuId != null)
        {
            if (MenuId != menu)
               dhtmlHistory.add('TrocaMenu&menuId=' + menu, null);
        }
    }
    
    if (preferencia != null)
        document.getElementById('MenuPrincipal').innerHTML = CreateMenu(menu,preferencia);
    else
        document.getElementById('MenuPrincipal').innerHTML = CreateMenu(menu);

    if (document.getElementById('TextoRodape') != null)
        document.getElementById('TextoRodape').innerHTML = GetTextPainelBottom(menu);
        
    document.getElementById('aviso_pesquisa_ajax').style.display = 'none';
    document.getElementById('aviso_pesquisa').style.display = 'none';
    document.getElementById('aviso_buscaAvancada').style.display = 'none';
    document.getElementById('aviso_buscaAvancadaAssinatura').style.display = 'none';
    document.getElementById('aviso_buscaConteudoDiferente').style.display = 'none';
    
    if(document.getElementById('divMesaLuz') != null)
        document.getElementById("divMesaLuz").style.display = 'none';
        
    if(document.getElementById('mesaespaco') != null)
        document.getElementById('mesaespaco').style.height = '0px';    
    
    if (document.getElementById('ctl00_editorial_date_ajax') != null)
        document.getElementById('ctl00_editorial_date_ajax').options[0].selected = true;
    
    if (document.getElementById('ctl00_editorial_date') != null)
        document.getElementById('ctl00_editorial_date').options[0].selected = true;
    
    var dm;
    switch(menu)
    {
        case EnumMenu.Home:
            dm = 'PainelInicial';
            break;
        case EnumMenu.Publicidade:
            dm = 'PainelPublicidade';
            break;
        case EnumMenu.Editorial:
            dm = 'PainelEditorial';
            break;
        case EnumMenu.Cenas:
            dm = 'PainelCenas';
            break;
        case EnumMenu.Cd:
            dm = 'PainelCds';
            break;
        case EnumMenu.Dam:
            dm = 'PainelDAM';
            break;
        case EnumMenu.Panther:
            dm = 'PainelPanther';
            break;
    }

    if(pageInit != true)
    {
        OcultarDivsGerenciar();
        ExibirDivMenu(dm);
        document.getElementById('ctl00_pesquisa_campo').value = TextoPesquisa(menu);
    }
}

function CreateMenu(menuId,preferencia)
{
    
    if (EnumMenu == null)
        return '';
    
            
    MenuId = menuId;
    if(MenuId != EnumMenu.Editorial)
        OrigemBusca = EnumOrigemBusca.Publicidade;
    else
        OrigemBusca = EnumOrigemBusca.Editorial;

    var strHtml = '<table class="menu" id="menu" width="934" border="0" cellspacing="1" cellpadding="0"><tr>';

    if(menuId == EnumMenu.Home)
        strHtml += '<td width="154" height="23" class="menu_home" id="menu_home" style="background:#E2E2E2; font-size:10px;"><span style="cursor:pointer;" onclick="VoltarParaHome();MontaMenu(\'' + EnumMenu.Home + '\')">home</span></td>';
    else
        strHtml += '<td width="154" height="23" class="menu_home" id="menu_home" style="font-size:10px;"><a href="javascript:" onmouseover="menu_rollover(\'menu_home\')" onmouseout="menu_rollout(\'menu_home\')" onclick="VoltarParaHome();MontaMenu(\'' + EnumMenu.Home + '\')">home</a></td>';
    
    if(menuId == EnumMenu.Publicidade)
        strHtml += '<td width="156" height="23" class="menu_publicidade" id="menu_publicidade" style="background: #E2E2E2; font-size:10px;"><span style="cursor:pointer;" onclick="VoltarParaHome();MontaMenu(\'' + EnumMenu.Publicidade + '\');">publicidade</span></td>';
    else
        strHtml += '<td width="156" height="23" class="menu_publicidade" id="menu_publicidade" style="font-size:10px;"><a href="javascript:" onmouseover="menu_rollover(\'menu_publicidade\')" onmouseout="menu_rollout(\'menu_publicidade\')" onclick="VoltarParaHome();MontaMenu(\'' + EnumMenu.Publicidade + '\');">publicidade</a></td>';
    
    if(menuId == EnumMenu.Editorial)
        strHtml += '<td width="155" height="23" class="menu_editorial" id="menu_editorial" style="background: #E2E2E2;font-size:10px;"><span style="cursor:pointer;" onclick="VoltarParaHome();MontaMenu(\'' + EnumMenu.Editorial + '\')">editorial</span></td>';
    else
        strHtml += '<td width="155" height="23" class="menu_editorial" id="menu_editorial" style="font-size:10px;"><a href="javascript:" onmouseover="menu_rollover(\'menu_editorial\')" onmouseout="menu_rollout(\'menu_editorial\')" onclick="VoltarParaHome();MontaMenu(\'' + EnumMenu.Editorial + '\')">editorial</a></td>';
    
    if(menuId == EnumMenu.Cenas)
        strHtml += '<td width="154" height="23" class="menu_cenas" id="menu_cenas"" style="background: #E2E2E2;font-size:10px;"><span style="cursor:pointer;" onclick="VoltarParaHome();MontaMenu(\'' + EnumMenu.Cenas + '\')">cenas</span></td>';
    else
        strHtml += '<td width="154" height="23" class="menu_cenas" id="menu_cenas" style="font-size:10px;"><a href="javascript:" onmouseover="menu_rollover(\'menu_cenas\')" onmouseout="menu_rollout(\'menu_cenas\')" onclick="VoltarParaHome();MontaMenu(\'' + EnumMenu.Cenas + '\')">cenas</a></td>';
    
    if(menuId == EnumMenu.Cd)
        strHtml += '<td width="154" height="23" class="menu_cd" id="menu_cd" style="background: #E2E2E2;font-size:10px;"><span style="cursor:pointer;" onclick="VoltarParaHome();MontaMenu(\'' + EnumMenu.Cd + '\')">cd</span></td>';
    else
        strHtml += '<td width="154" height="23" class="menu_cd" id="menu_cd" style="font-size:10px;"><a href="javascript:" onmouseover="menu_rollover(\'menu_cd\')" onmouseout="menu_rollout(\'menu_cd\')" onclick="VoltarParaHome();MontaMenu(\'' + EnumMenu.Cd + '\')">cd</a></td>';
    
    if(menuId == EnumMenu.Dam)
        strHtml += '<td width="154" height="23" class="menu_dam" id="menu_dam" style="background: #E2E2E2;font-size:10px;"><span style="cursor:pointer;" onclick="VoltarParaHome();MontaMenu(\'' + EnumMenu.Dam + '\')">360º</span></td>';
    else
        strHtml += '<td width="154" height="23" class="menu_dam" id="menu_dam" style="font-size:10px;"><a href="javascript:" onmouseover="menu_rollover(\'menu_dam\')" onmouseout="menu_rollout(\'menu_dam\')" onclick="VoltarParaHome();MontaMenu(\'' + EnumMenu.Dam + '\')">360º</a></td>';
    
    if(menuId == EnumMenu.Panther)
        strHtml += '<td width="154" height="23" class="menu_panther" id="menu_Panther" style="background: #E2E2E2;font-size:10px;"><span style="cursor:pointer;" onclick="VoltarParaHome();MontaMenu(\'' + EnumMenu.Panther + '\')">Assinaturas</span></td>';
    else
        strHtml += '<td width="154" height="23" class="menu_panther" id="menu_Panther" style="font-size:10px;"><a href="javascript:" onmouseover="menu_rollover(\'menu_Panther\')" onmouseout="menu_rollout(\'menu_Panther\')" onclick="VoltarParaHome();MontaMenu(\'' + EnumMenu.Panther + '\')">Assinaturas</a></td>';
    
    strHtml += '</table>';

    AlterarCores();

//    var hashValue = window.location.hash;
//    if (hashValue == null || hashValue == undefined || hashValue.length < 40)
//    {
        //if (preferencia != true)
            Pre_Sets();
//    }

    return strHtml;
}

function Pre_Sets()
{
    document.getElementById('ctl00_paginacao').selectedIndex = 1;
    document.getElementById('ctl00_busca_boolean').selectedIndex = 0;
    document.getElementById('ctl00_plano').selectedIndex = 0;
    document.getElementById('ctl00_orientacao_horizontal').checked = false;
    document.getElementById('ctl00_orientacao_vertical').checked = false;
    document.getElementById('ctl00_orientacao_panoramica').checked = false;
    document.getElementById('ctl00_orientacao_quadrada').checked = false;
    document.getElementById('ctl00_estilo_pb').checked = false;
    document.getElementById('ctl00_estilo_ilustracao').checked = false;
    document.getElementById('ctl00_estilo_colorido').checked = false;
    document.getElementById('ctl00_estilo_fotografia').checked = false;    
    document.getElementById('ctl00_pessoas').selectedIndex = 0

    document.getElementById('ctl00_publicidade_colecoes_dc').selectedIndex = 0;
    document.getElementById('ctl00_publicidade_colecoesRF').selectedIndex = 0;
    document.getElementById('ctl00_editorial_list').selectedIndex = 0;            
    document.getElementById('ctl00_publicidade_somentecd').selectedIndex = 0;
    document.getElementById('ctl00_publicidade_categorias').selectedIndex = 0;
    document.getElementById('ctl00_publicidade_ordemAlfabetica').selectedIndex = 0; 
    document.getElementById('ctl00_preco').selectedIndex = 0; 
    
    pesquisa_avancada(document.getElementById('pesquisa_avancada').style.display);
    //pesquisa_panther('none');
    
    if (MenuId == EnumMenu.Home)
    {
        EnablePublicidade(false);
        EnableEditorial(false);
        EnableSearchALL(false);
        EnableCenas(false);
        
        CheckPublicidade(false);
        CheckSearchALL(false);
        CheckCenas(false);
        CheckEditorial(false);

        document.getElementById('ctl00_publicidade').checked = false;
        document.getElementById('ctl00_publicidade').disabled = false;
        document.getElementById('ctl00_publicidade_search_ajax').checked = false;
        document.getElementById('ctl00_publicidade_search_ajax').disabled = false;
    }
    else if(MenuId == EnumMenu.Publicidade)
    {
        EnableCenas(false);
        EnableEditorial(false);
        EnablePublicidade(false);
        EnableSearchALL(false);
        
        CheckPublicidade(true);
        CheckSearchALL(false);
        CheckCenas(false);
        CheckEditorial(false);
        
        document.getElementById('ctl00_publicidade_port_ajax').checked = true;
        document.getElementById('ctl00_publicidade_lingua_port').checked = true;
        
    }
    else if(MenuId == EnumMenu.Editorial)
    {
        EnableCenas(false);
        EnableEditorial(false);
        EnablePublicidade(false);
        EnableSearchALL(false);
        
        CheckEditorial(true);
        CheckPublicidade(false);
        CheckSearchALL(false);
        CheckCenas(false);

    }
    else if(MenuId == EnumMenu.Cenas)
    {
        EnableCenas(false);
        EnableEditorial(true);
        EnablePublicidade(true);
        EnableSearchALL(true);
        
        CheckSearchALL(false);
        CheckCenas(true);
        CheckPublicidade(false);
        CheckEditorial(false);
    }
    else if (MenuId == EnumMenu.Cd)
    {
        EnableSearchALL(false);
        CheckSearchALL(false);
        document.getElementById('ctl00_somente_cd').checked = true;
        CheckCd(document.getElementById('ctl00_somente_cd'));
    }
    else if (MenuId == EnumMenu.Dam)
    {
        EnablePublicidade(true);
        EnableEditorial(false);
        EnableSearchALL(false);
        EnableCenas(false);
        
        CheckSearchALL(false);
        CheckCenas(false);
        CheckEditorial(false);
        CheckPublicidade(true);

        document.getElementById('ctl00_publicidade').checked = false;
        document.getElementById('ctl00_publicidade').disabled = false;
        
        document.getElementById('ctl00_publicidade_search_ajax').checked = false;
        document.getElementById('ctl00_publicidade_search_ajax').disabled = false;    
    }
    else if (MenuId == EnumMenu.Panther)
    {
        //document.getElementById('pesquisa_panther').style.display = 'block';

        EnablePublicidade(false);
        EnableEditorial(false);
        EnableSearchALL(false);
        EnableCenas(false);

        CheckSearchALL(false);
        CheckCenas(false);
        CheckEditorial(false);
        CheckPublicidade(false);

        document.getElementById('ctl00_publicidade').checked = false;
        document.getElementById('ctl00_publicidade').disabled = false;

        document.getElementById('ctl00_publicidade_search_ajax').checked = false;
        document.getElementById('ctl00_publicidade_search_ajax').disabled = false;

        pesquisa_opcoes('none', '0');
        pesquisa_avancada('none');

        //document.getElementById('pesquisa_avancada_abrir').style.display = 'none';
        //document.getElementById('pesquisa_avancada_fechar').style.display = 'none';
    }
}

function ApplyCD()
{
    document.getElementById('ctl00_publicidade_search_ajax').checked = true;
    document.getElementById('ctl00_publicidade_layout').checked = false;
    document.getElementById('ctl00_publicidade_RF').checked = true;
    document.getElementById('ctl00_publicidade_port_RF_ajax').checked = true;
    document.getElementById('ctl00_somente_cd').checked = true; 
    document.getElementById('ctl00_publicidade').checked = true; 
    document.getElementById('ctl00_publicidade_lingua_eng').checked = false; 
    document.getElementById('ctl00_publicidade_eng_ajax').checked = false;
    document.getElementById('ctl00_cd_lingua_port').checked = true;
    document.getElementById('ctl00_publicidade_colecoesRF').disabled = true;
    document.getElementById('ctl00_publicidade_search_ajax').disabled = true;
    document.getElementById('ctl00_publicidade_layout').disabled = true;
    document.getElementById('ctl00_publicidade').disabled = true;    
    document.getElementById('ctl00_publicidade_lingua_port').disabled = true;
    document.getElementById('ctl00_publicidade_port_ajax').disabled = true;
    document.getElementById('ctl00_publicidade_lingua_eng').disabled = true; 
    document.getElementById('ctl00_publicidade_eng_ajax').disabled = true;
    document.getElementById('ctl00_publicidade_DC').disabled = true; 
    document.getElementById('ctl00_publicidade_colecoes_dc').disabled = true; 
    document.getElementById('ctl00_publicidade_port_DC_ajax').disabled = true;
    document.getElementById('ctl00_publicidade_port_RF').disabled = true; 
    document.getElementById('ctl00_cd_lingua_port').disabled = false;
    document.getElementById('ctl00_cd_lingua_eng').disabled = false;
}

// Exibe o flash e oculta as divs de busca
// Chamar esta função quando criar um novo menu
function HiddenDivs()
{
    document.getElementById('PainelInicial').style.display = 'block';
    document.getElementById('ctl00_DvTblResultado').scrollTop = 0;
    document.getElementById('ctl00_DvTblResultado').style.display = 'none';
    document.getElementById('PainelLegenda').style.display = 'none';
    document.getElementById('PainelResultados').style.display = 'none';
    document.getElementById('PainelResultadosBottom').style.display = 'none';
    document.getElementById('ConteudoDinamico').style.display = 'none';
    document.getElementById("tabelaResultado").style.display = 'none';
}

function AlternaTextoPublicidade()
{
    if (document.getElementById('ctl00_pesquisa_campo').value == 'somente pesquisas em português' ||
        document.getElementById('ctl00_pesquisa_campo').value == 'somente pesquisas em inglês' ||
        document.getElementById('ctl00_pesquisa_campo').value == 'pesquise aqui sua imagem' ||
        document.getElementById('ctl00_pesquisa_campo').value == '')
    {
        if (document.getElementById('ctl00_publicidade_search_ajax').checked)
        {
            if (document.getElementById('ctl00_publicidade_port_ajax').checked)
                document.getElementById('ctl00_pesquisa_campo').value = 'somente pesquisas em português';
            else
                document.getElementById('ctl00_pesquisa_campo').value = 'somente pesquisas em inglês';
        }
        else if (document.getElementById('ctl00_editorial_ajax').checked)
        {
            document.getElementById('ctl00_pesquisa_campo').value = 'somente pesquisas em inglês';
        }
        else if (document.getElementById('ctl00_cenas_ajax').checked)
        {
            document.getElementById('ctl00_pesquisa_campo').value = 'somente pesquisas em inglês';
        }
    }
}

function TextoPesquisa(menuId)
{
    if (menuId == EnumMenu.Editorial || menuId == EnumMenu.Cenas ||  menuId == EnumMenu.Panther)
        return 'somente pesquisas em inglês';
    else if (menuId == EnumMenu.Publicidade)
    {
        if (document.getElementById('ctl00_publicidade_port_ajax').disabled)
            return 'somente pesquisas em inglês';
        else
            return 'somente pesquisas em português';
    }
	else if (menuId == EnumMenu.Cd)
        return 'somente pesquisas em português';
    else
        return 'pesquise aqui sua imagem';
}

function AlterarSetas(estilo)
{
	var i =1;
	while (i <= 9)
	{
	    if (document.getElementById('seta' + i) != null)
		    document.getElementById('seta' + i).className = estilo;
		i=i+1;
	}
	if (window.frames['iframelogin'].document.getElementById('setausr') != null)
	{
		window.frames['iframelogin'].document.getElementById('setausr').className = estilo;
		window.frames['iframelogin'].document.getElementById('setapass').className = estilo;
	}
}

function AlterarOK(cor)
{
	if (window.frames['iframelogin'].document.getElementById('botaook') != null)
	{
		window.frames['iframelogin'].document.getElementById('botaook').style.color = cor;
	}
}

function AlterarCores()
{    
	var estilo = '';
    switch(MenuId)
    {
        case EnumMenu.Home:        
            document.getElementById('Buscar').style.color = '#0EA1BB';
            document.getElementById('PesquisaAvancada').style.color = '#0EA1BB';
            document.getElementById('PesquisaAvancadaFechar').style.color = '#0EA1BB';
			AlterarOK('#0EA1BB');
            $('a').mouseover(function () {$(this).css("color","#0EA1BB");});  
            $('a').mouseout(function () {$(this).css("color","#7E7E7E");});     
            $('a').each(function () {$(this).css("color","#7E7E7E");});    
            
            var bodyRows = $("#pesquisa a");
            bodyRows.each(function () {$(this).css("color","#0EA1BB");});  
		    bodyRows.mouseover(function () {$(this).css("color","#7E7E7E");});
			bodyRows.mouseout(function () {$(this).css("color","#0EA1BB");});
			
            estilo = 'seta_home';
			AlterarSetas(estilo);
			AlterarCoresLinks('#0EA1BB');
        break;
        
        case EnumMenu.Publicidade:
            document.getElementById('Buscar').style.color = '#F98800';
            document.getElementById('PesquisaAvancada').style.color = '#F98800';
            document.getElementById('PesquisaAvancadaFechar').style.color = '#F98800';
			AlterarOK('#F98800');
            $('a').mouseover(function () {$(this).css("color","#F98800");});  
            $('a').mouseout(function () {$(this).css("color","#7E7E7E");});     
            $('a').each(function () {$(this).css("color","#7E7E7E");}); 

            var bodyRows = $("#pesquisa a");
            bodyRows.each(function () {$(this).css("color","#F98800");});				
            bodyRows.mouseover(function () {$(this).css("color","#7E7E7E");});	
            bodyRows.mouseout(function () {$(this).css("color","#F98800");});
                
            estilo = 'seta_public';  
		    AlterarSetas(estilo);
			AlterarCoresLinks('#F98800');
        break;
        
        case EnumMenu.Editorial:
            document.getElementById('Buscar').style.color = '#F53B00';
            document.getElementById('PesquisaAvancada').style.color = '#F53B00';
            document.getElementById('PesquisaAvancadaFechar').style.color = '#F53B00';
            AlterarOK('#F53B00');
            $('a').mouseover(function () {$(this).css("color","#F53B00");});  
            $('a').mouseout(function () {$(this).css("color","#7E7E7E");});     
            $('a').each(function () {$(this).css("color","#7E7E7E");}); 
            
            var bodyRows = $("#pesquisa a");
            bodyRows.each(function () {$(this).css("color","#F53B00");});
            bodyRows.mouseover(function () {$(this).css("color","#7E7E7E");});
			bodyRows.mouseout(function () {$(this).css("color","#F53B00");});

            estilo = 'seta_editorial';  
			AlterarSetas(estilo);
            AlterarCoresLinks('#F53B00');
        break;
        
        case EnumMenu.Cenas:
            document.getElementById('Buscar').style.color = '#099A21';
            document.getElementById('PesquisaAvancada').style.color = '#099A21';
            document.getElementById('PesquisaAvancadaFechar').style.color = '#099A21';
            AlterarOK('#099A21');
            $('a').mouseover(function () {$(this).css("color","#099A21");});  
            $('a').mouseout(function () {$(this).css("color","#7E7E7E");});     
            $('a').each(function () {$(this).css("color","#7E7E7E");}); 
            
            var bodyRows = $("#pesquisa a");
            bodyRows.each(function () {$(this).css("color","#099A21");}); 
			bodyRows.mouseover(function () {$(this).css("color","#7E7E7E");});
			bodyRows.mouseout(function () {$(this).css("color","#099A21");});

            estilo = 'seta_cena';  
			AlterarSetas(estilo); 
            AlterarCoresLinks('#099A21');
        break;
        
        case EnumMenu.Cd:
            document.getElementById('Buscar').style.color = '#DD0085';
            document.getElementById('PesquisaAvancada').style.color = '#DD0085';
            document.getElementById('PesquisaAvancadaFechar').style.color = '#DD0085';
            AlterarOK('#DD0085');
            $('a').mouseover(function () {$(this).css("color","#DD0085");});  
            $('a').mouseout(function () {$(this).css("color","#7E7E7E");});     
            $('a').each(function () {
            $(this).css("color","#7E7E7E");}); 
            
            var bodyRows = $("#pesquisa a");
            bodyRows.each(function () {$(this).css("color","#DD0085");}); 
			bodyRows.mouseover(function () {$(this).css("color","#7E7E7E");});
			bodyRows.mouseout(function () {$(this).css("color","#DD0085");});

            estilo = 'seta_cd';
			AlterarSetas(estilo);
            AlterarCoresLinks('#DD0085');
        break;
        
        case EnumMenu.Dam:
            document.getElementById('Buscar').style.color = '#DB33FF';
            document.getElementById('PesquisaAvancada').style.color = '#DB33FF';
            document.getElementById('PesquisaAvancadaFechar').style.color = '#DB33FF';
            AlterarOK('#DB33FF');
            $('a').mouseover(function () {$(this).css("color","#DB33FF");});  
            $('a').mouseout(function () {$(this).css("color","#7E7E7E");});     
            $('a').each(function () {$(this).css("color","#7E7E7E");}); 
            
            var bodyRows = $("#pesquisa a");
            bodyRows.each(function () {$(this).css("color","#DB33FF");}); 
			bodyRows.mouseover(function () {$(this).css("color","#7E7E7E");});
			bodyRows.mouseout(function () {$(this).css("color","#DB33FF");});

            estilo = 'seta_dam';  
			AlterarSetas(estilo);                 
            AlterarCoresLinks('#DB33FF');
        break;
        
        case EnumMenu.Panther:
            document.getElementById('Buscar').style.color = '#2e0da7';
            document.getElementById('PesquisaAvancada').style.color = '#2e0da7';
            document.getElementById('PesquisaAvancadaFechar').style.color = '#2e0da7';
            AlterarOK('#2e0da7');
            $('a').mouseover(function () {$(this).css("color","#2e0da7");});
            $('a').mouseout(function () {$(this).css("color","#7E7E7E");});     
            $('a').each(function () {$(this).css("color","#7E7E7E");}); 
            
            var bodyRows = $("#pesquisa a");
            bodyRows.each(function () {$(this).css("color","#2e0da7");}); 
			bodyRows.mouseover(function () {$(this).css("color","#7E7E7E");});
			bodyRows.mouseout(function () {$(this).css("color","#2e0da7");});

            estilo = 'seta_panther';
			AlterarSetas(estilo);
            AlterarCoresLinks('#2e0da7');
        break;
    }
    SetasPaginas('s',9,estilo);
}

function AlterarCoresLinks(cor)
{
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_hlAssinatura');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_hlCopa2010');
    
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_hlContratoImagens');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_hlContratoCenas');

    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_hlNovaMesa');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_btExcluir');

    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_btMeuPedido');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_btMeusDados');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_btAutorizacao');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_lbVerificar');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_lkSalvarCad');

    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_btExcluir');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_btSalvar');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_btFaturamento');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_btClearence');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_btSolicitarOrcamento');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_btProrrogarReserva');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_btReserva');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_btRemoverReserva');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_btEnviarAutorizacao');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_btVoltar');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_btFecharPedido2');

    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_lbPalavraClarificador');
    LinksTrocaCor(cor,'ctl00_ContentPlaceHolder1_lkEnviar');
}

function LinksTrocaCor(cor,controle)
{
    if (document.getElementById(controle) != null)
    {
        document.getElementById(controle).style.color = cor;
        $('#' + controle).css("color",cor);
        $('#' + controle).mouseover(function () {$(this).css("color",cor);});
        $('#' + controle).mouseout(function () {$(this).css("color",cor);});        
    }
}

function MostraCapaCD(params)
{
    var dados = params.split(',,');

    var aux = ' '+
    '<table width="934" border="0" class="search_pag2" style="font-size:11px;padding:0 25px;" cellpadding="0" cellspacing="0"> '+
    '   <tr> '+
    '       <td> '+
    '           <table width="864" class="checks" style="" align="center" border="0"> '+
    '           <tr> '+
    '               <td valign="middle" align="left" width="140" height="145"> '+
    '                   <img src="'+ dados[0] +'">'+
    '               </td> '+
    '               <td width="140" valign="top" > '+
    '                   <span style="line-height:16px;font-size:10px"> '+
    '                       <b style="color:#DD0085">' + dados[6] + '</b><br />'+
    '                       <img id="seta1" src="../../templates/img/pt-BR/setas/seta_cd.gif"/>&nbsp;'+ dados[7] +' - '+ dados[1] + '<br /> '+
    '                       <img id="seta2" src="../../templates/img/pt-BR/setas/seta_cd.gif"/>&nbsp;'+ dados[8] +' - '+ dados[2] +' '+ dados[26] + '<br /> '+
    '                       <img id="seta3" src="../../templates/img/pt-BR/setas/seta_cd.gif"/>&nbsp;'+ dados[9] +' '+ dados[16] + '<br /> '+
    '                       <img id="seta4" src="../../templates/img/pt-BR/setas/seta_cd.gif"/>&nbsp;'+ dados[10] +' - '+ dados[11] + '<br /><br /> '+
	'    				</span>'+
    '                   <a onclick="Add(\''+ dados[5] +'\',\'9\')" style="cursor:pointer" onmouseout="stl();" onmouseover="window.top.status=\'Salvar CD na mesa de luz\';return true;"> '+
    '                      <img src="../../templates/img/pt-br/ico_mesadeluz.gif" title="Adicionar a Mesa de Luz" alt="Adicionar a Mesa de Luz" /></a>&nbsp;'+
    '                   <a onclick="Add(\''+ dados[5] +'\',\'10\')" style="cursor:pointer" onmouseout="stl();" onmouseover="window.top.status=\'Comprar CD\';return true;"> '+
    '                      <img src="../../templates/img/pt-br/ico_comprar.gif" title="Comprar"  alt="Comprar" /></a>&nbsp; '+
    '               </td> '+
    '               <td width="160" valign="top" style="line-height:16px;font-size:10px">'+
    '                   <span style="line-height:16px;font-size:10px"> '+
    '                       &nbsp;<br /> '+
    '                       <img id="seta5" style="color:#DD0085" src="../../templates/img/pt-BR/setas/seta_cd.gif"/>&nbsp;'+ dados[15] + '<br /> '+
    '                       <img id="seta6" style="color:#DD0085" src="../../templates/img/pt-BR/setas/seta_cd.gif"/>&nbsp;'+ dados[27] + '<br /> '+
    '                       &nbsp;&nbsp;'+ dados[3] + '<br /> '+
	'                       &nbsp;&nbsp;(frete não incluso)<br /> '+
	'    				</span>'+	
    '               </td> '+
    '           </tr> '+
    '           </table> '+
    '       </td> '+
    '   </tr> '+
    '</table>';

    return aux;
}

function LimpaTabela()
{
    document.getElementById('ctl00_DvTblResultado').scrollTop = 0;

    var tbl = document.getElementById('tabelaResultado');
    var lastRow = tbl.rows.length; 
    while (lastRow > 0) 
    { 
        tbl.deleteRow(lastRow - 1);  
        lastRow = tbl.rows.length; 
    }
    BlocosCarregados = new Array();
    ContPag = 0;

    document.getElementById("tabelaResultado").style.display = 'none';
    
}

function OcultarDivsGerenciar()
{
    var i;
    
    for(i = 0; i < contDivsGerenciar; i++)
    {
        if (document.getElementById(divsGerenciar[i]) != null)
            document.getElementById(divsGerenciar[i]).style.display = 'none';
    }
}

function ExibirDivMenu(divMenu)
{
    if (document.getElementById(divMenu) != null)
        document.getElementById(divMenu).style.display = 'block';
}

function VoltarParaHome()
{
    if (document.getElementById('ConteudoDaPagina') != null)
        document.getElementById('ConteudoDaPagina').style.display = 'none';
}

function SetasPaginas(prefixo,qtd,estilo)
{
	var i =1;
	while (i <= qtd)
	{
	    var elemento = prefixo + i;
        if (document.getElementById(elemento) != null)
        {
            document.getElementById(elemento).className = estilo;
        }
		i=i+1;
	}
}

function EhEditorial()
{
    if(MenuId == EnumMenu.Editorial)
        return true;
    
    return false;
}

function ZerarClarificador()
{
    isClarificar = false;
    clarificar = '';
    buscarClarificador = false;
}

function hashProxima(hashAtual)
{
    var auxCacheKeyArray = document.getElementById('ctl00_ArrayCacheKey').value.split(',');
    var indexCache = -1;
    alert(auxCacheKeyArray);
    for (var i = 0; i < auxCacheKeyArray.length; i++)
    {
        if (unescape(auxCacheKeyArray[i]) == unescape(hashAtual))
            indexCache = i;
    }
    
    return auxCacheKeyArray[indexCache + 1];
}

function hashAnterior(hashAtual)
{
    var auxCacheKeyArray = document.getElementById('ctl00_ArrayCacheKey').value.split(',');
    var indexCache = 1;
    
    for (var i = 0; i < auxCacheKeyArray.length; i++)
    {
        if (unescape(auxCacheKeyArray[i]) == unescape(hashAtual))
            indexCache = i;
    }
        
    return auxCacheKeyArray[indexCache - 1];
}

function exibeDivMesaLuz()
{
    if (document.getElementById("log") != null)
        document.getElementById("log").value = '1';

    if (existeResultado())
    {
        if (document.getElementById("divMesaLuz") != null)
            document.getElementById("divMesaLuz").style.display = 'block';
        return true;
    }
    else
    {
        if (document.getElementById("divMesaLuz") != null)
            document.getElementById("divMesaLuz").style.display = 'none';
        return false;
    }
}

function existeResultado()
{
    if (document.getElementById("tabelaResultado") != null)
        return (document.getElementById("tabelaResultado").style.display == 'block');
    else
        return false;
}

function atualizaIFrameLogin()
{
    window.frames['iframelogin'].location.reload();
}
function corThumb_Remove(pFotoId,pOrigem)
{
    mudaCorThumb(pFotoId,'0',pOrigem);
}

function corThumb_Seleciona(pFotoId,pOrigem)
{
    mudaCorThumb(pFotoId,'1',pOrigem);
}

function mudaCorThumb(pFotoId,pSeleciona,pOrigem)
{
    if (document.getElementById("log") != null)
        if (document.getElementById("log").value != '1')
            return;

    // pinta os icones

    var aux_seleciona = (pSeleciona=='1')?'-on':'';
    if (pOrigem == 'm')
    {
        if (document.getElementById('ic_m_' + pFotoId) != null)
        {
            if(MenuId == EnumMenu.Home)
            {
                if (pSeleciona=='1')
                    document.getElementById('ic_m_' + pFotoId).src = '../../templates/img/pt-br/ico_mesadeluz-on.gif';
                else
                    document.getElementById('ic_m_' + pFotoId).src = '../../templates/img/pt-br/ico_mesadeluz.gif';
            }
            else if(MenuId == EnumMenu.Publicidade)
            {
                if (pSeleciona=='1')
                    document.getElementById('ic_m_' + pFotoId).src = '../../templates/img/pt-br/ico_mesadeluz-on_publi.gif';
                else
                    document.getElementById('ic_m_' + pFotoId).src = '../../templates/img/pt-br/ico_mesadeluz.gif';
            }
            else if(MenuId == EnumMenu.Editorial)
            {
                if (pSeleciona=='1')
                    document.getElementById('ic_m_' + pFotoId).src = '../../templates/img/pt-br/ico_mesadeluz-on_ed.gif';
                else
                    document.getElementById('ic_m_' + pFotoId).src = '../../templates/img/pt-br/ico_mesadeluz.gif';
            }
            else if(MenuId == EnumMenu.Cenas)
            {
                if (pSeleciona=='1')
                    document.getElementById('ic_m_' + pFotoId).src = '../../templates/img/pt-br/ico_mesadeluz-on_cena.gif';
                else
                    document.getElementById('ic_m_' + pFotoId).src = '../../templates/img/pt-br/ico_mesadeluz.gif';
            }
            else if(MenuId == EnumMenu.Cd)
            {
                if (pSeleciona=='1')
                    document.getElementById('ic_m_' + pFotoId).src = '../../templates/img/pt-br/ico_mesadeluz-on_cd.gif';
                else
                    document.getElementById('ic_m_' + pFotoId).src = '../../templates/img/pt-br/ico_mesadeluz.gif';
            }
            else if(MenuId == EnumMenu.Dam)
            {
                if (pSeleciona=='1')
                    document.getElementById('ic_m_' + pFotoId).src = '../../templates/img/pt-br/ico_mesadeluz-on_dam.gif';
                else
                    document.getElementById('ic_m_' + pFotoId).src = '../../templates/img/pt-br/ico_mesadeluz.gif';
            }
        }
    }
    else
    {
        if (document.getElementById('ic_c_' + pFotoId) != null)
        {
            if(MenuId == EnumMenu.Home)
            {
                if (pSeleciona=='1')
                    document.getElementById('ic_c_' + pFotoId).src = '../../templates/img/pt-br/ico_comprar-on.gif';
                else
                    document.getElementById('ic_c_' + pFotoId).src = '../../templates/img/pt-br/ico_comprar.gif';
            }
            else if(MenuId == EnumMenu.Publicidade)
            {
                if (pSeleciona=='1')
                    document.getElementById('ic_c_' + pFotoId).src = '../../templates/img/pt-br/ico_comprar-on_publi.gif';
                else
                    document.getElementById('ic_c_' + pFotoId).src = '../../templates/img/pt-br/ico_comprar.gif';
            }
            else if(MenuId == EnumMenu.Editorial)
            {
                if (pSeleciona=='1')
                    document.getElementById('ic_c_' + pFotoId).src = '../../templates/img/pt-br/ico_comprar-on_ed.gif';
                else
                    document.getElementById('ic_c_' + pFotoId).src = '../../templates/img/pt-br/ico_comprar.gif';
            }
            else if(MenuId == EnumMenu.Cenas)
            {
                if (pSeleciona=='1')
                    document.getElementById('ic_c_' + pFotoId).src = '../../templates/img/pt-br/ico_comprar-on_cena.gif';
                else
                    document.getElementById('ic_c_' + pFotoId).src = '../../templates/img/pt-br/ico_comprar.gif';
            }
            else if(MenuId == EnumMenu.Cd)
            {
                if (pSeleciona=='1')
                    document.getElementById('ic_c_' + pFotoId).src = '../../templates/img/pt-br/ico_comprar-on_cd.gif';
                else
                    document.getElementById('ic_c_' + pFotoId).src = '../../templates/img/pt-br/ico_comprar.gif';
            }
            else if(MenuId == EnumMenu.Dam)
            {
                if (pSeleciona=='1')
                    document.getElementById('ic_c_' + pFotoId).src = '../../templates/img/pt-br/ico_comprar-on_dam.gif';
                else
                    document.getElementById('ic_c_' + pFotoId).src = '../../templates/img/pt-br/ico_comprar.gif';
            }
        }
    }

    // pinta o quadro
    
    var existeIconeMesa = false;
    var temIconeMesa = false;
    var existeIconeCarrinho = false;
    var temIconeCarrinho = false;
    if (document.getElementById('ic_m_' + pFotoId) != null)
    {
        existeIconeMesa = true;
        if (document.getElementById('ic_m_' + pFotoId).src.indexOf('ico_mesadeluz.gif') == -1)
            temIconeMesa = true;
    }
    if (document.getElementById('ic_c_' + pFotoId) != null)
    {
        existeIconeCarrinho = true;
        if (document.getElementById('ic_c_' + pFotoId).src.indexOf('ico_comprar.gif') == -1)
            temIconeCarrinho = true;
    }
    
    if ( (existeIconeMesa && temIconeMesa) || (existeIconeCarrinho && temIconeCarrinho) )
    {
        if (document.getElementById('td_' + pFotoId) != null)
            document.getElementById('td_' + pFotoId).className = 'bx-foto-on';
    }
    else
    {
        if (document.getElementById('td_' + pFotoId) != null)
            document.getElementById('td_' + pFotoId).className = 'bx-foto';
    }
}

function addMesaLuzOuCarrinho(id,op)
{
    if(document.getElementById("log").value == '1')
    {
        if (op == 3)       // mesa
            window.frames['iframeMesa'].postAssincronoStart('', '', '', id, 'im', '', 'pesq', 'salvar');

        else if (op == 4)  // carrinho
            window.frames['iframeMesa'].postAssincronoStart('', '1', '', id, 'im', '', 'pesq', 'salvarcarrinho');

        else if (op == 5)  // mesa (ampliada)
            this.window.top.opener.top.frames['iframeMesa'].postAssincronoStart('', '', '', id, 'im', '', 'pesq', 'salvar');

        else if (op == 6)  // carrinho (ampliada)
            this.window.top.opener.top.frames['iframeMesa'].postAssincronoStart('', '1', '', id, 'im', '', 'pesq', 'salvarcarrinho');

        else if (op == 9)  // mesa (cd)
            window.frames['iframeMesa'].postAssincronoStart('', '', id, '', 'cd', '', 'pesq', 'salvar');

        else if (op == 10) // carrinho (cd)
            window.frames['iframeMesa'].postAssincronoStart('', '1', id, '', 'cd', '', 'pesq', 'salvarcarrinho');

        // Sempre 'maximiza' e opcionalmente 'minimiza' após 3 segundos
        max();    
        if (get_minimizaAutomaticamente() == '1')
            setTimeout("min()", 4000);
    }
    else
    {
        if (op == 3 || op == 5 || op == 9) // mesa
            alert('Para salvar esta imagem a mesa de luz, é preciso estar logado.');
        else if (op == 4 || op == 6  || op == 10) // carrinho
            alert('Para comprar esta imagem, é preciso estar logado.');
    }
}

function Add(id,op)
{
    dwn(id,op);
}

function dwn(id, op, origem,panther)
{
    var executaRe = 1;
    if(origem == null)
        origem = 0;

    var downloadHiresRF = document.getElementById('download_hires_rf').value;
    if (downloadHiresRF != '1')
        url = '../dotnet/ls.aspx?op=' + op + '&id=' + id + '&oripesq=' + origem;
    else
        url = '../dotnet/ls.aspx?op=' + op + '&id=' + id + '&oripesq=' + origem + '&downloadHiresRF=1';

    if (panther == 1)
        url += '&panther=1';

    if (document.getElementById('ctl00_cenas').checked)
        url = url + '&video=1'

    if(document.getElementById("log").value == '1')
    {
        if (op == 2)
        {
            document.getElementById('frameSalvarEnviar').src = url;
            executaRe = 0;
        }
    }
    if (executaRe == 1)
        re(url);
}

function stsm()
{
    this.window.top.status='Salvar imagem na mesa de luz';
}

function re(url)
{
    try
    {
        document.getElementById('iframeMesa').src = url;
    }
    catch(e)
    {

    }
}

function Add(id,op)
{
    dwn(id,op);
}

function verificaImagensSelecionadas()
{
    // de-seleciona antigas

    /*
    if(MenuId == EnumMenu.Cenas)
    {
        var VideosCarrinho_Ant = getArrayVideosCarrinho_Ant();
        for(var i=0; i < VideosCarrinho_Ant.length; i++)
            corThumb_Remove(VideosCarrinho_Ant[i],'c');
        
        var VideosMesaDeLuz_Ant = getArrayVideosMesaDeLuz_Ant();
        for(var i=0; i < VideosMesaDeLuz_Ant.length; i++)
            corThumb_Remove(VideosMesaDeLuz_Ant[i],'m');
    }
    else
    {
    */
        var ImagensCarrinho_Ant = getArrayImagensCarrinho_Ant();
        for(var i=0; i < ImagensCarrinho_Ant.length; i++)
            corThumb_Remove(ImagensCarrinho_Ant[i],'c');
        
        var ImagensMesaDeLuz_Ant = getArrayImagensMesaDeLuz_Ant();
        for(var i=0; i < ImagensMesaDeLuz_Ant.length; i++)
            corThumb_Remove(ImagensMesaDeLuz_Ant[i],'m');
    //}

    document.getElementById('ArrayImagensMesaDeLuz_Ant').value = '';
    document.getElementById('ArrayImagensCarrinho_Ant').value = '';
    //document.getElementById('ArrayVideosMesaDeLuz_Ant').value = '';
    //document.getElementById('ArrayVideosCarrinho_Ant').value = '';

    // seleciona novas
    /*    
    if(MenuId == EnumMenu.Cenas)
    {
        var VideosCarrinho = getArrayVideosCarrinho();
        for(var i=0; i < VideosCarrinho.length; i++)
            corThumb_Seleciona(VideosCarrinho[i],'c');
        
        var VideosMesaDeLuz = getArrayVideosMesaDeLuz();
        for(var i=0; i < VideosMesaDeLuz.length; i++)
            corThumb_Seleciona(VideosMesaDeLuz[i],'m');
    }
    else
    {
    */
        var ImagensCarrinho = getArrayImagensCarrinho();
        for(var i=0; i < ImagensCarrinho.length; i++)
            corThumb_Seleciona(ImagensCarrinho[i],'c');
        
        var ImagensMesaDeLuz = getArrayImagensMesaDeLuz();
        for(var i=0; i < ImagensMesaDeLuz.length; i++)
            corThumb_Seleciona(ImagensMesaDeLuz[i],'m');
    //}
}

// get Arrays

function getArrayImagensCarrinho()
{
    if (document.getElementById('ArrayImagensCarrinho') != null)
        return document.getElementById('ArrayImagensCarrinho').value.split(',');
    else
        return new array();
}
function getArrayImagensMesaDeLuz()
{
    if (document.getElementById('ArrayImagensMesaDeLuz') != null)
        return document.getElementById('ArrayImagensMesaDeLuz').value.split(',');
    else
        return new array();
}
function getArrayVideosCarrinho()
{
    if (document.getElementById('ArrayVideosCarrinho') != null)
        return document.getElementById('ArrayVideosCarrinho').value.split(',');
    else
        return new array();
}
function getArrayVideosMesaDeLuz()
{
    if (document.getElementById('ArrayVideosMesaDeLuz') != null)
        return document.getElementById('ArrayVideosMesaDeLuz').value.split(',');
    else
        return new array();
}

// get Arrays Ant

function getArrayImagensCarrinho_Ant()
{
    if (document.getElementById('ArrayImagensCarrinho_Ant') != null)
        return document.getElementById('ArrayImagensCarrinho_Ant').value.split(',');
    else
        return new array();
}
function getArrayImagensMesaDeLuz_Ant()
{
    if (document.getElementById('ArrayImagensMesaDeLuz_Ant') != null)
        return document.getElementById('ArrayImagensMesaDeLuz_Ant').value.split(',');
    else
        return new array();
}
function getArrayVideosCarrinho_Ant()
{
    if (document.getElementById('ArrayVideosCarrinho_Ant') != null)
        return document.getElementById('ArrayVideosCarrinho_Ant').value.split(',');
    else
        return new array();
}
function getArrayVideosMesaDeLuz_Ant()
{
    if (document.getElementById('ArrayVideosMesaDeLuz_Ant') != null)
        return document.getElementById('ArrayVideosMesaDeLuz_Ant').value.split(',');
    else
        return new array();
}

// set Arrays

function setArrayImagensMesaDeLuz(pArrayImagens)
{
    document.getElementById('ArrayImagensMesaDeLuz_Ant').value = document.getElementById('ArrayImagensMesaDeLuz').value;
    document.getElementById('ArrayImagensMesaDeLuz').value = pArrayImagens
}
function setArrayImagensCarrinho(pArrayImagens)
{
    document.getElementById('ArrayImagensCarrinho_Ant').value = document.getElementById('ArrayImagensCarrinho').value;
    document.getElementById('ArrayImagensCarrinho').value = pArrayImagens
}
function setArrayVideosMesaDeLuz(pArrayVideos)
{
    document.getElementById('ArrayVideosMesaDeLuz_Ant').value = document.getElementById('ArrayVideosMesaDeLuz').value;
    document.getElementById('ArrayVideosMesaDeLuz').value = pArrayVideos
}
function setArrayVideosCarrinho(pArrayVideos)
{
    document.getElementById('ArrayVideosCarrinho_Ant').value = document.getElementById('ArrayVideosCarrinho').value;
    document.getElementById('ArrayVideosCarrinho').value = pArrayVideos
}

function sta()
{
    this.window.top.status = 'Ampliar Imagem';
}
function stl() {this.window.top.status='';} 
 
// int, string, string, int, string, string, bool
function RetornaPathImagem(tamanho, nomeArquivo, origemColecao, idColecao, NomeColecao, numeroCatalogo, includeURL)
{
    var strRet = "";//StringBuilder
    var strCaminhoInicial = "";
    
    if(includeURL)
        strRet += urlRepositorio + '/';
    else
        strRet += '/';

    //Seleciona o caminho inicial da imagen de acordo com o tamanho escolhido
    switch(tamanho)
    {
        case eTamanhoImagem.Ampliacao:
            strCaminhoInicial = pastaAmpliacao;
        case eTamanhoImagem.LayoutA3:
            strCaminhoInicial = caminhoFotoLayout;
        case eTamanhoImagem.Thumbnail:
            strCaminhoInicial = pastaThumb;
    }
    
    strRet += strCaminhoInicial + '/';
    
    if(tamanho != eImagemLayoutA3)
        strRet += MontaCaminhoImagem(origemColecao, idColecao, NomeColecao, numeroCatalogo, nomeArquivo);
    else
    {
        strRet += numeroCatalogo;
        strRet += '/';
        strRet += 'layout/';
        strRet += nomeArquivo;
    }
    
    if(tamanho == eImagemLayoutA3)
        strRet.replace("//", "/");

    var retorno = strRet;
    
    if(retorno.substr(0, 1) == '\\' && retorno.indexOf(':') >= 0)
        retorno = retorno.remove(0, 1);
    
    return retorno;
}
//string, int, string, string, string
function MontaCaminhoImagem(origemColecao, idColecao, nomeColecao, numeroCatalogo, nomeArquivo)
{
    var strRet = "";// StringBuilder
    strRet += origemColecao;
    strRet += '/';
    strRet += PadLeft(idColecao, '0', 4);
    strRet += '-';
    strRet += nomeColecao;
    strRet += '/';
    strRet += numeroCatalogo;
    strRet += '/';
    strRet += nomeArquivo;

    return strRet;
}

function controlaVisibilidadeIcones()
{
    if (document.getElementById('nivelUsuario') != null && document.getElementById('download_layout_rf') != null && document.getElementById('download_hires_rf') != null)
    {
        var download_hires_rf = document.getElementById('download_hires_rf').value;
        if (download_hires_rf == '1')
        {
            if (document.getElementById('divLegendaHiRes') != null)
                document.getElementById('divLegendaHiRes').style.display = 'inline';

            var divHiRes = document.getElementsByName('divHiResRF');
            for(var j=0; j<divHiRes.length; j++)
                divHiRes[j].style.display = 'inline';
        }

        var nivelUsuario = document.getElementById('nivelUsuario').value;
        if (nivelUsuario >= 4)
        {
            var download_layout_rf = document.getElementById('download_layout_rf').value;
            if (download_layout_rf == '1')
            {
                var divLayout = document.getElementsByName('divLayout');

                for(var i=0; i<divLayout.length; i++)
                    divLayout[i].style.display = 'inline';
            }

            if (document.getElementById('divLegendaLayout') != null)
                document.getElementById('divLegendaLayout').style.display = 'inline';

            var divLayoutDC = document.getElementsByName('divLayoutDC');
            for(var i=0; i<divLayoutDC.length; i++)
                divLayoutDC[i].style.display = 'inline';

            if (nivelUsuario == 5)
            {   
                if (document.getElementById('divLegendaHiRes') != null)
                    document.getElementById('divLegendaHiRes').style.display = 'inline';

                var divHiRes = document.getElementsByName('divHiRes');
                for(var j=0; j<divHiRes.length; j++)
                    divHiRes[j].style.display = 'inline';
            }
        }
    }
}

function setNivelUsuario(nivel, download_layout_rf, download_hires_rf)
{
    if (document.getElementById('nivelUsuario') != null)
        document.getElementById('nivelUsuario').value = nivel;
    if (document.getElementById('download_layout_rf') != null)
        document.getElementById('download_layout_rf').value = download_layout_rf;
    if (document.getElementById('download_hires_rf') != null)
        document.getElementById('download_hires_rf').value = download_hires_rf;
}

function BuscaAvancadaEmUso()
{
    if (document.getElementById('ctl00_paginacao') != null)
    {
        if (document.getElementById('ctl00_paginacao').selectedIndex != 1)
            return true;
        if (document.getElementById('ctl00_busca_boolean').selectedIndex > 0)
            return true;
        if (document.getElementById('ctl00_plano').selectedIndex > 0)
            return true;
        if (document.getElementById('ctl00_orientacao_horizontal').checked)
            return true;
        if (document.getElementById('ctl00_orientacao_vertical').checked)
            return true;
        if (document.getElementById('ctl00_orientacao_panoramica').checked)
            return true;
        if (document.getElementById('ctl00_orientacao_quadrada').checked)
            return true;
        if (document.getElementById('ctl00_estilo_pb').checked)
            return true;
        if (document.getElementById('ctl00_estilo_ilustracao').checked)
            return true;
        if (document.getElementById('ctl00_estilo_colorido').checked)
            return true;
        if (document.getElementById('ctl00_estilo_fotografia').checked)
            return true;              
        if (document.getElementById('ctl00_pessoas').selectedIndex > 0)
            return true;
        if (document.getElementById('ctl00_preco').selectedIndex > 0)
            return true;
            
            
        if (document.getElementById('desativouAvisoBuscaAvancada').value == '0')
        {
            if (MenuId == 116) // Home
            {
                if (document.getElementById('ctl00_editorial').checked)
                {
                    if (document.getElementById('ctl00_publicidade_lingua_port').checked)
                        return true;
                }
                else
                {
                    if (document.getElementById('ctl00_publicidade_lingua_eng').checked)
                        return true;
                }
            }
            else if (MenuId == 117) // Publicidade
            {
                if (document.getElementById('ctl00_publicidade_lingua_eng').checked)
                    return true;

                if (! document.getElementById('ctl00_publicidade_DC').checked)
                    return true;
                if (! document.getElementById('ctl00_publicidade_RF').checked)
                    return true;
            }
            else if (MenuId == 126) // Editorial
            {
                if (document.getElementById('ctl00_publicidade_lingua_port').checked)
                    return true;
            }
        }

        if (document.getElementById('ctl00_publicidade_port_RF').checked)
            return true;
        if (document.getElementById('ctl00_publicidade_layout').checked)
            return true;

        if (document.getElementById('ctl00_editorial_date').selectedIndex > 0)
            return true;

        if (document.getElementById('ctl00_data_especifica').value != 'dd/mm/aaaa')
            return true;

        if (MenuId == 116) // Home
        {
            if (document.getElementById('ctl00_publicidade').checked)
            {
                if (! document.getElementById('ctl00_publicidade_DC').checked)
                    return true;
                if (! document.getElementById('ctl00_publicidade_RF').checked)
                    return true;
            }

            if (document.getElementById('ctl00_editorial').checked)
            {
                if (! document.getElementById('ctl00_editorial_tipo_animais').checked)
                    return true;
                if (! document.getElementById('ctl00_editorial_tipo_arte').checked)
                    return true;
                if (! document.getElementById('ctl00_editorial_tipo_ciencia').checked)
                    return true;
                if (! document.getElementById('ctl00_editorial_tipo_criativo').checked)
                    return true;
                if (! document.getElementById('ctl00_editorial_tipo_entretenimento').checked)
                    return true;
                if (! document.getElementById('ctl00_editorial_tipo_esporte').checked)
                    return true;
                if (! document.getElementById('ctl00_editorial_tipo_gastronomia').checked)
                    return true;
                if (! document.getElementById('ctl00_editorial_tipo_historia').checked)
                    return true;
                if (! document.getElementById('ctl00_editorial_tipo_noticias').checked)
                    return true;
                if (! document.getElementById('ctl00_editorial_tipo_viagens').checked)
                    return true;
            }
        }
        else
        {
            if (document.getElementById('ctl00_search_all').checked)
                return true;
        }

        if (MenuId == 117) // Publicidade
        {
            if (! document.getElementById('ctl00_publicidade_DC').checked)
                return true;
            if (! document.getElementById('ctl00_publicidade_RF').checked)
                return true;
        }
        
        if (MenuId == 126 || (MenuId == 116 && document.getElementById('ctl00_editorial').checked)) // Editorial
        {
            if (! document.getElementById('ctl00_editorial_tipo_animais').checked)
                return true;
            if (! document.getElementById('ctl00_editorial_tipo_arte').checked)
                return true;
            if (! document.getElementById('ctl00_editorial_tipo_ciencia').checked)
                return true;
            if (! document.getElementById('ctl00_editorial_tipo_criativo').checked)
                return true;
            if (! document.getElementById('ctl00_editorial_tipo_entretenimento').checked)
                return true;
            if (! document.getElementById('ctl00_editorial_tipo_esporte').checked)
                return true;
            if (! document.getElementById('ctl00_editorial_tipo_gastronomia').checked)
                return true;
            if (! document.getElementById('ctl00_editorial_tipo_historia').checked)
                return true;
            if (! document.getElementById('ctl00_editorial_tipo_noticias').checked)
                return true;
            if (! document.getElementById('ctl00_editorial_tipo_viagens').checked)
                return true;
        }
        else
        {
            if (document.getElementById('ctl00_editorial_tipo_animais').checked)
                return true;
            if (document.getElementById('ctl00_editorial_tipo_arte').checked)
                return true;
            if (document.getElementById('ctl00_editorial_tipo_ciencia').checked)
                return true;
            if (document.getElementById('ctl00_editorial_tipo_criativo').checked)
                return true;
            if (document.getElementById('ctl00_editorial_tipo_entretenimento').checked)
                return true;
            if (document.getElementById('ctl00_editorial_tipo_esporte').checked)
                return true;
            if (document.getElementById('ctl00_editorial_tipo_gastronomia').checked)
                return true;
            if (document.getElementById('ctl00_editorial_tipo_historia').checked)
                return true;
            if (document.getElementById('ctl00_editorial_tipo_noticias').checked)
                return true;
            if (document.getElementById('ctl00_editorial_tipo_viagens').checked)
                return true;
        }        

        if (MenuId != 124) // Cenas
        {
            if (document.getElementById('ctl00_cenas').checked)
                return true;
        }

        if (MenuId != 127) // Cd
        {
            if (document.getElementById('ctl00_somente_cd').checked)
                return true;
        }
        else
        {
             //if (document.getElementById('ctl00_cd_lingua_port').checked)
            //    return true;
          if (document.getElementById('ctl00_cd_lingua_eng').checked)
              return true;
        }

        if (document.getElementById('ctl00_publicidade_colecoes_dc').selectedIndex > 0)
            return true;
        if (document.getElementById('ctl00_publicidade_colecoesRF').selectedIndex > 0)
            return true;
        if (document.getElementById('ctl00_editorial_list').selectedIndex > 0)
            return true;
        if (document.getElementById('ctl00_publicidade_somentecd').selectedIndex > 0)
            return true;
        if (document.getElementById('ctl00_publicidade_categorias').selectedIndex > 0)
            return true;
        if (document.getElementById('ctl00_publicidade_ordemAlfabetica').selectedIndex > 0)
            return true;
            
                
    }
    return false;
}

function BuscaAvancadaAssinatura_EmUso()
{
    if (! document.getElementById('ctl00_chksubscription').checked)
        return true;
    
    if (document.getElementById('ctl00_rdbIllustration').checked)
        return true;
    if (document.getElementById('ctl00_rdbPhoto').checked)
        return true;

    if (document.getElementById('ctl00_chkModelRelease').checked)
        return true;
    if (document.getElementById('ctl00_chkPropertyRealese').checked)
        return true;
    if (document.getElementById('ctl00_chkComercial').checked)
        return true;
    if (document.getElementById('ctl00_chkMerchan').checked)
        return true;
    if (document.getElementById('ctl00_rdbColor').checked)
        return true;
    if (document.getElementById('ctl00_rdbBW').checked)
        return true;

    if (document.getElementById('ctl00_ddlCategory').selectedIndex > 0)
        return true;

    if (document.getElementById('ctl00_chkPortrait').checked)
        return true;
    if (document.getElementById('ctl00_chkLandscape').checked)
        return true;
    if (document.getElementById('ctl00_chkSquare').checked)
        return true;
    if (document.getElementById('ctl00_chkPanoramic').checked)
        return true;

    if (document.getElementById('ctl00_ddlSize').selectedIndex > 0)
        return true;
    if (document.getElementById('ctl00_ddlEmotions').selectedIndex > 0)
        return true;
    if (document.getElementById('ctl00_ddlGender').selectedIndex > 0)
        return true;
    if (document.getElementById('ctl00_ddlPeopleNumber').selectedIndex > 0)
        return true;

    if (document.getElementById('ctl00_rdbColorBlack').checked)
        return true;
    if (document.getElementById('ctl00_rdbColorYellow').checked)
        return true;
    if (document.getElementById('ctl00_rdbColorPink').checked)
        return true;
    if (document.getElementById('ctl00_rdbColorlightblue').checked)
        return true;
    if (document.getElementById('ctl00_rdbColorgrey').checked)
        return true;
    if (document.getElementById('ctl00_rdbColororange').checked)
        return true;
    if (document.getElementById('ctl00_rdbColorpurple').checked)
        return true;
    if (document.getElementById('ctl00_rdbColorlightgreen').checked)
        return true;
    if (document.getElementById('ctl00_rdbColorwhite').checked)
        return true;
    if (document.getElementById('ctl00_rdbColorred').checked)
        return true;
    if (document.getElementById('ctl00_rdbColordarkblue').checked)
        return true;
    if (document.getElementById('ctl00_rdbColordarkgreen').checked)
        return true;

    return false;
}

function resetarBuscaAvancadaAssinatura()
{
    document.getElementById('desativouAvisoBuscaAvancada').value = '1';

    document.getElementById('ctl00_chksubscription').checked = true;
    
    document.getElementById('ctl00_rdbIllustration').checked = false;
    document.getElementById('ctl00_rdbPhoto').checked = false;

    document.getElementById('ctl00_chkModelRelease').checked = false;
    document.getElementById('ctl00_chkPropertyRealese').checked = false;
    document.getElementById('ctl00_chkComercial').checked = false;
    document.getElementById('ctl00_chkMerchan').checked = false;
    document.getElementById('ctl00_rdbColor').checked = false;
    document.getElementById('ctl00_rdbBW').checked = false;

    document.getElementById('ctl00_ddlCategory').selectedIndex = 0;

    document.getElementById('ctl00_chkPortrait').checked = false;
    document.getElementById('ctl00_chkLandscape').checked = false;
    document.getElementById('ctl00_chkSquare').checked = false;
    document.getElementById('ctl00_chkPanoramic').checked = false;

    document.getElementById('ctl00_ddlSize').selectedIndex = 0;
    document.getElementById('ctl00_ddlEmotions').selectedIndex = 0;
    document.getElementById('ctl00_ddlGender').selectedIndex = 0;
    document.getElementById('ctl00_ddlPeopleNumber').selectedIndex = 0;

    document.getElementById('ctl00_rdbColorBlack').checked = false;
    document.getElementById('ctl00_rdbColorYellow').checked = false;
    document.getElementById('ctl00_rdbColorPink').checked = false;
    document.getElementById('ctl00_rdbColorlightblue').checked = false;
    document.getElementById('ctl00_rdbColorgrey').checked = false;
    document.getElementById('ctl00_rdbColororange').checked = false;
    document.getElementById('ctl00_rdbColorpurple').checked = false;
    document.getElementById('ctl00_rdbColorlightgreen').checked = false;
    document.getElementById('ctl00_rdbColorwhite').checked = false;
    document.getElementById('ctl00_rdbColorred').checked = false;
    document.getElementById('ctl00_rdbColordarkblue').checked = false;
    document.getElementById('ctl00_rdbColordarkgreen').checked = false;

    document.getElementById('aviso_buscaAvancadaAssinatura').style.display = 'none';
    document.getElementById('aviso_buscaConteudoDiferente').style.display = 'none';

    var pcha = document.getElementById('ctl00_pesquisa_campo').value;
    if (pcha != 'pesquise aqui sua imagem' && pcha != 'somente pesquisas em português' && pcha != 'somente pesquisas em inglês')
    {
        pagina=1;
        BuscarDados('new');
    }
}

function resetarBuscaAvancada()
{
    document.getElementById('desativouAvisoBuscaAvancada').value = '1';

    // Guarda idioma atual para aplicar logo após o Reset
    var idiomaEmUsoEhPortugues = (document.getElementById('ctl00_publicidade_lingua_port').checked);


    if(MenuId == EnumMenu.Home || MenuId == EnumMenu.Dam)
    {
        // -- Genéricas

        document.getElementById('ctl00_paginacao').selectedIndex = 1;
        document.getElementById('ctl00_busca_boolean').selectedIndex = 0;
        document.getElementById('ctl00_plano').selectedIndex = 0;
        document.getElementById('ctl00_orientacao_horizontal').checked = false;
        document.getElementById('ctl00_orientacao_vertical').checked = false;
        document.getElementById('ctl00_orientacao_panoramica').checked = false;
        document.getElementById('ctl00_orientacao_quadrada').checked = false;
        document.getElementById('ctl00_estilo_pb').checked = false;
        document.getElementById('ctl00_estilo_ilustracao').checked = false;
        
        document.getElementById('ctl00_estilo_colorido').checked = false;
        document.getElementById('ctl00_estilo_fotografia').checked = false;
        
        document.getElementById('ctl00_preco').selectedIndex = 0

        
        document.getElementById('ctl00_pessoas').selectedIndex = 0

        document.getElementById('ctl00_publicidade_colecoes_dc').selectedIndex = 0;
        document.getElementById('ctl00_publicidade_colecoesRF').selectedIndex = 0;
        document.getElementById('ctl00_editorial_list').selectedIndex = 0;            
        document.getElementById('ctl00_publicidade_somentecd').selectedIndex = 0;
        document.getElementById('ctl00_publicidade_categorias').selectedIndex = 0;
        document.getElementById('ctl00_publicidade_ordemAlfabetica').selectedIndex = 0;

        document.getElementById('ctl00_cenas').checked = false;
        document.getElementById('ctl00_cenas_ajax').checked = false;

        document.getElementById('ctl00_somente_cd').checked = false;
        document.getElementById('ctl00_cd_lingua_port').checked = false;
        document.getElementById('ctl00_cd_lingua_eng').checked = false;

        // -- Search ALL

        document.getElementById('ctl00_search_all').checked = (document.getElementById('ctl00_publicidade').checked && document.getElementById('ctl00_editorial').checked);
        document.getElementById('ctl00_search_all_ajax').checked = (document.getElementById('ctl00_publicidade').checked && document.getElementById('ctl00_editorial').checked);

        // -- Publicidade

        if (document.getElementById('ctl00_publicidade').checked)
        {
            document.getElementById('ctl00_publicidade_DC').checked = true;
            document.getElementById('ctl00_publicidade_port_DC_ajax').checked = true;
            document.getElementById('ctl00_publicidade_port_RF').checked = false;

            document.getElementById('ctl00_publicidade_RF').checked = true;
            document.getElementById('ctl00_publicidade_port_RF_ajax').checked = true;
            document.getElementById('ctl00_publicidade_layout').checked = false;
			document.getElementById('ctl00_publicidade_lingua_port').checked = true;
            document.getElementById('ctl00_publicidade_port_ajax').checked = true;
        }
        else
        {
            document.getElementById('ctl00_publicidade_DC').checked = false;
            document.getElementById('ctl00_publicidade_port_DC_ajax').checked = false;
            document.getElementById('ctl00_publicidade_port_RF').checked = false;

            document.getElementById('ctl00_publicidade_RF').checked = false;
            document.getElementById('ctl00_publicidade_port_RF_ajax').checked = false;
            document.getElementById('ctl00_publicidade_layout').checked = false;
			document.getElementById('ctl00_publicidade_lingua_eng').checked = false;
            document.getElementById('ctl00_publicidade_eng_ajax').checked = false;
        }

        // -- Editorial

        document.getElementById('ctl00_editorial_date').SelectedIndex = 0;
        document.getElementById('ctl00_editorial_date_ajax').SelectedIndex = 0;
        document.getElementById('ctl00_data_especifica').text = '';
        document.getElementById('ctl00_data_especifica_ajax').text = '';
        
        document.getElementById('ctl00_editorial_tipo_animais').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_arte').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_ciencia').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_criativo').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_entretenimento').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_esporte').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_gastronomia').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_historia').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_noticias').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_viagens').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_animais2').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_arte2').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_ciencia2').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_criativo2').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_entretenimento2').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_esporte2').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_gastronomia2').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_historia2').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_noticias2').checked = document.getElementById('ctl00_editorial').checked;
        document.getElementById('ctl00_editorial_tipo_viagens2').checked = document.getElementById('ctl00_editorial').checked;
    }
    else
    {
        Pre_Sets();
    }

    

    document.getElementById('aviso_buscaAvancada').style.display = 'none';
    document.getElementById('aviso_buscaConteudoDiferente').style.display = 'none';

    var pcha = document.getElementById('ctl00_pesquisa_campo').value;
    if (pcha != 'pesquise aqui sua imagem' && pcha != 'somente pesquisas em português' && pcha != 'somente pesquisas em inglês')
    {
        pagina=1;
        BuscarDados('new');
    }
}

function GravarPreferenciasBusca(ehHome)
{
    GravarPreferenciasMenu(ehHome);
    
    //GravarPreferencias();
    //GravarPreferenciasAjax();
    //GravarPreferenciasDisponibilidade();
    //GravarPreferenciasDisponibilidadeAjax();
}

function GravarPreferenciasMenu(ehHome)
{
    if (! ehHome)
        createCookie('pref_menu', MenuId, 10);
    else
    {
        if (document.getElementById('ctl00_publicidade').checked)
            createCookie('pref_menu', 117, 10);
        else
            createCookie('pref_menu', 126, 10);
    }
}

function GravarPreferencias()
{
    var valor;
    // 0 - 10
    valor += "paginacao=" + document.getElementById('ctl00_paginacao').selectedIndex + ",";
    valor += "busca_boolean=" + document.getElementById('ctl00_busca_boolean').selectedIndex + ",";
    valor += "plano=" + document.getElementById('ctl00_plano').selectedIndex + ",";
    valor += "orientacao_horizontal=" + document.getElementById('ctl00_orientacao_horizontal').checked + ",";
    valor += "orientacao_vertical=" + document.getElementById('ctl00_orientacao_vertical').checked + ",";
    valor += "orientacao_panoramica=" + document.getElementById('ctl00_orientacao_panoramica').checked + ",";
    valor += "orientacao_quadrada=" + document.getElementById('ctl00_orientacao_quadrada').checked + ",";
    valor += "estilo_pb=" + document.getElementById('ctl00_estilo_pb').checked + ",";
    valor += "estilo_ilustracao=" + document.getElementById('ctl00_estilo_ilustracao').checked + ",";
    valor += "pessoas=" + document.getElementById('ctl00_pessoas').selectedIndex + ",";
    valor += "search_all=" + document.getElementById('ctl00_search_all').checked + ",";
    //11 - 20
    valor += "publicidade=" + document.getElementById('ctl00_publicidade').checked + ",";
    valor += "publicidade_lingua_port=" + document.getElementById('ctl00_publicidade_lingua_port').checked + ",";
    valor += "publicidade_lingua_eng=" + document.getElementById('ctl00_publicidade_lingua_eng').checked + ",";
    valor += "publicidade_DC=" + document.getElementById('ctl00_publicidade_DC').checked + ",";
    valor += "publicidade_port_RF=" + document.getElementById('ctl00_publicidade_port_RF').checked + ",";
    valor += "publicidade_RF=" + document.getElementById('ctl00_publicidade_RF').checked + ",";
    valor += "publicidade_layout=" + document.getElementById('ctl00_publicidade_layout').checked + ",";
    valor += "editorial=" + document.getElementById('ctl00_editorial').checked + ",";
    valor += "editorial_date=" + document.getElementById('ctl00_editorial_date').selectedIndex + ",";
    valor += "data_especifica=" + document.getElementById('ctl00_data_especifica').value + ",";
    //21 - 30
    valor += "editorial_tipo_animais=" + document.getElementById('ctl00_editorial_tipo_animais').checked + ",";
    valor += "editorial_tipo_arte=" + document.getElementById('ctl00_editorial_tipo_arte').checked + ",";
    valor += "editorial_tipo_ciencia=" + document.getElementById('ctl00_editorial_tipo_ciencia').checked + ",";
    valor += "editorial_tipo_criativo=" + document.getElementById('ctl00_editorial_tipo_criativo').checked + ",";
    valor += "editorial_tipo_entretenimento=" + document.getElementById('ctl00_editorial_tipo_entretenimento').checked + ",";
    valor += "editorial_tipo_esporte=" + document.getElementById('ctl00_editorial_tipo_esporte').checked + ",";
    valor += "editorial_tipo_gastronomia=" + document.getElementById('ctl00_editorial_tipo_gastronomia').checked + ",";
    valor += "editorial_tipo_historia=" + document.getElementById('ctl00_editorial_tipo_historia').checked + ",";
    valor += "editorial_tipo_noticias=" + document.getElementById('ctl00_editorial_tipo_noticias').checked + ",";
    valor += "editorial_tipo_viagens=" + document.getElementById('ctl00_editorial_tipo_viagens').checked + ",";
    //31 - 34
    valor += "cenas=" + document.getElementById('ctl00_cenas').checked + ",";
    valor += "somente_cd=" + document.getElementById('ctl00_somente_cd').checked + ",";
    valor += "cd_lingua_port=" + document.getElementById('ctl00_cd_lingua_port').checked + ",";
    valor += "cd_lingua_eng=" + document.getElementById('ctl00_cd_lingua_eng').checked + ",";

    var lista_publicidade_dc = '';
    for(var i = 0; i < document.getElementById('ctl00_publicidade_colecoes_dc').length; i++)
        if(document.getElementById('ctl00_publicidade_colecoes_dc').options[i].selected)
            lista_publicidade_dc += document.getElementById('ctl00_publicidade_colecoes_dc').options[i].value + '|';
    if (lista_publicidade_dc.length > 0) 
        lista_publicidade_dc = lista_publicidade_dc.substring(0, lista_publicidade_dc.length - 1);
    valor += "publicidade_colecoes_dc=" + lista_publicidade_dc + ",";

    var lista_publicidade_rf = '';
    for(var i = 0; i < document.getElementById('ctl00_publicidade_colecoesRF').length; i++)
        if(document.getElementById('ctl00_publicidade_colecoesRF').options[i].selected)
            lista_publicidade_rf += document.getElementById('ctl00_publicidade_colecoesRF').options[i].value + '|';
    if (lista_publicidade_rf.length > 0) 
        lista_publicidade_rf = lista_publicidade_rf.substring(0, lista_publicidade_rf.length - 1);
    valor += "publicidade_colecoesRF=" + lista_publicidade_rf + ",";

    var lista_editorial = '';
    for(var i = 0; i < document.getElementById('ctl00_editorial_list').length; i++)
        if(document.getElementById('ctl00_editorial_list').options[i].selected)
            lista_editorial += document.getElementById('ctl00_editorial_list').options[i].value + '|';
    if (lista_editorial.length > 0) 
        lista_editorial = lista_editorial.substring(0, lista_editorial.length - 1);
    valor += "editorial_list=" + lista_editorial + ",";

    var publicidade_somentecd = '';
    for(var i = 0; i < document.getElementById('ctl00_publicidade_somentecd').length; i++)
        if(document.getElementById('ctl00_publicidade_somentecd').options[i].selected)
            publicidade_somentecd += document.getElementById('ctl00_publicidade_somentecd').options[i].value + '|';
    if (publicidade_somentecd.length > 0) 
        publicidade_somentecd = publicidade_somentecd.substring(0, publicidade_somentecd.length - 1);
    valor += "publicidade_somentecd=" + publicidade_somentecd  + ",";
    
    var publicidade_categorias = '';
    for(var i = 0; i < document.getElementById('ctl00_publicidade_categorias').length; i++)
        if(document.getElementById('ctl00_publicidade_categorias').options[i].selected)
            publicidade_categorias += document.getElementById('ctl00_publicidade_categorias').options[i].value + '|';
    if (publicidade_categorias.length > 0)
        publicidade_categorias = publicidade_categorias.substring(0, publicidade_categorias.length - 1);
    valor += "publicidade_categorias=" + publicidade_categorias  + ",";
    
    var publicidade_ordemAlfabetica = '';
    for(var i = 0; i < document.getElementById('ctl00_publicidade_ordemAlfabetica').length; i++)
        if(document.getElementById('ctl00_publicidade_ordemAlfabetica').options[i].selected)
            publicidade_ordemAlfabetica += document.getElementById('ctl00_publicidade_ordemAlfabetica').options[i].value + '|';
    if (publicidade_ordemAlfabetica.length > 0) 
        publicidade_ordemAlfabetica = publicidade_ordemAlfabetica.substring(0, publicidade_ordemAlfabetica.length - 1);
    valor += "publicidade_ordemAlfabetica=" + publicidade_ordemAlfabetica;

    createCookie('pref_opcoes', valor, 10);
}

function GravarPreferenciasDisponibilidade()
{
    var valor;
    // 0 - 10
    valor += "paginacao=" + document.getElementById('ctl00_paginacao').disabled + ",";
    valor += "busca_boolean=" + document.getElementById('ctl00_busca_boolean').disabled + ",";
    valor += "plano=" + document.getElementById('ctl00_plano').disabled + ",";
    valor += "orientacao_horizontal=" + document.getElementById('ctl00_orientacao_horizontal').disabled + ",";
    valor += "orientacao_vertical=" + document.getElementById('ctl00_orientacao_vertical').disabled + ",";
    valor += "orientacao_panoramica=" + document.getElementById('ctl00_orientacao_panoramica').disabled + ",";
    valor += "orientacao_quadrada=" + document.getElementById('ctl00_orientacao_quadrada').disabled + ",";
    valor += "estilo_pb=" + document.getElementById('ctl00_estilo_pb').disabled + ",";
    valor += "estilo_ilustracao=" + document.getElementById('ctl00_estilo_ilustracao').disabled + ",";
    valor += "pessoas=" + document.getElementById('ctl00_pessoas').disabled + ",";
    valor += "search_all=" + document.getElementById('ctl00_search_all').disabled + ",";
    //11 - 20
    valor += "publicidade=" + document.getElementById('ctl00_publicidade').disabled + ",";
    valor += "publicidade_lingua_port=" + document.getElementById('ctl00_publicidade_lingua_port').disabled + ",";
    valor += "publicidade_lingua_eng=" + document.getElementById('ctl00_publicidade_lingua_eng').disabled + ",";
    valor += "publicidade_DC=" + document.getElementById('ctl00_publicidade_DC').disabled + ",";
    valor += "publicidade_port_RF=" + document.getElementById('ctl00_publicidade_port_RF').disabled + ",";
    valor += "publicidade_RF=" + document.getElementById('ctl00_publicidade_RF').disabled + ",";
    valor += "publicidade_layout=" + document.getElementById('ctl00_publicidade_layout').disabled + ",";
    valor += "editorial=" + document.getElementById('ctl00_editorial').disabled + ",";
    valor += "editorial_date=" + document.getElementById('ctl00_editorial_date').disabled + ",";
    valor += "data_especifica=" + document.getElementById('ctl00_data_especifica').disabled + ",";
    //21 - 30
    valor += "editorial_tipo_animais=" + document.getElementById('ctl00_editorial_tipo_animais').disabled + ",";
    valor += "editorial_tipo_arte=" + document.getElementById('ctl00_editorial_tipo_arte').disabled + ",";
    valor += "editorial_tipo_ciencia=" + document.getElementById('ctl00_editorial_tipo_ciencia').disabled + ",";
    valor += "editorial_tipo_criativo=" + document.getElementById('ctl00_editorial_tipo_criativo').disabled + ",";
    valor += "editorial_tipo_entretenimento=" + document.getElementById('ctl00_editorial_tipo_entretenimento').disabled + ",";
    valor += "editorial_tipo_esporte=" + document.getElementById('ctl00_editorial_tipo_esporte').disabled + ",";
    valor += "editorial_tipo_gastronomia=" + document.getElementById('ctl00_editorial_tipo_gastronomia').disabled + ",";
    valor += "editorial_tipo_historia=" + document.getElementById('ctl00_editorial_tipo_historia').disabled + ",";
    valor += "editorial_tipo_noticias=" + document.getElementById('ctl00_editorial_tipo_noticias').disabled + ",";
    valor += "editorial_tipo_viagens=" + document.getElementById('ctl00_editorial_tipo_viagens').disabled + ",";
    //31 - 40
    valor += "cenas=" + document.getElementById('ctl00_cenas').disabled + ",";
    valor += "somente_cd=" + document.getElementById('ctl00_somente_cd').disabled + ",";
    valor += "cd_lingua_port=" + document.getElementById('ctl00_cd_lingua_port').disabled + ",";
    valor += "cd_lingua_eng=" + document.getElementById('ctl00_cd_lingua_eng').disabled + ",";
    valor += "publicidade_colecoes_dc=" + document.getElementById('ctl00_publicidade_colecoes_dc').disabled + ",";
    valor += "publicidade_colecoesRF=" + document.getElementById('ctl00_publicidade_colecoesRF').disabled + ",";
    valor += "editorial_list=" + document.getElementById('ctl00_editorial_list').disabled + ",";
    valor += "publicidade_somentecd=" + document.getElementById('ctl00_publicidade_somentecd').disabled + ",";
    valor += "publicidade_categorias=" + document.getElementById('ctl00_publicidade_categorias').disabled + ",";
    valor += "publicidade_ordemAlfabetica=" + document.getElementById('ctl00_publicidade_ordemAlfabetica').disabled;
    
    createCookie('pref_disponivel', valor, 10);
}

function GravarPreferenciasAjax()
{
    var valor;

    // 0 - 5
    valor += "publicidade_search_ajax=" + document.getElementById('ctl00_publicidade_search_ajax').checked + ",";
    valor += "publicidade_port_ajax=" + document.getElementById('ctl00_publicidade_port_ajax').checked + ",";
    valor += "publicidade_eng_ajax=" + document.getElementById('ctl00_publicidade_eng_ajax').checked + ",";
    valor += "publicidade_port_DC_ajax=" + document.getElementById('ctl00_publicidade_port_DC_ajax').checked + ",";
    valor += "publicidade_port_RF_ajax=" + document.getElementById('ctl00_publicidade_port_RF_ajax').checked + ",";
    valor += "editorial_ajax=" + document.getElementById('ctl00_editorial_ajax').checked + ",";
    // 6 - 15
    valor += "editorial_tipo_animais2=" + document.getElementById('ctl00_editorial_tipo_animais2').checked + ",";
    valor += "editorial_tipo_arte2=" + document.getElementById('ctl00_editorial_tipo_arte2').checked + ",";
    valor += "editorial_tipo_ciencia2=" + document.getElementById('ctl00_editorial_tipo_ciencia2').checked + ",";
    valor += "editorial_tipo_criativo2=" + document.getElementById('ctl00_editorial_tipo_criativo2').checked + ",";
    valor += "editorial_tipo_entretenimento2=" + document.getElementById('ctl00_editorial_tipo_entretenimento2').checked + ",";
    valor += "editorial_tipo_esporte2=" + document.getElementById('ctl00_editorial_tipo_esporte2').checked + ",";
    valor += "editorial_tipo_gastronomia2=" + document.getElementById('ctl00_editorial_tipo_gastronomia2').checked + ",";
    valor += "editorial_tipo_historia2=" + document.getElementById('ctl00_editorial_tipo_historia2').checked + ",";
    valor += "editorial_tipo_noticias2=" + document.getElementById('ctl00_editorial_tipo_noticias2').checked + ",";
    valor += "editorial_tipo_viagens2=" + document.getElementById('ctl00_editorial_tipo_viagens2').checked + ",";
    // 16 - 21
    valor += "editorial_date_ajax=" + document.getElementById('ctl00_editorial_date_ajax').selectedIndex + ",";
    valor += "data_especifica_ajax=" + document.getElementById('ctl00_data_especifica_ajax').value + ",";
    valor += "search_all_ajax=" + document.getElementById('ctl00_search_all_ajax').checked + ",";
    valor += "cenas_ajax=" + document.getElementById('ctl00_cenas_ajax').checked + ",";
//  valor += "cenas_DC_ajax=" + document.getElementById('ctl00_cenas_DC_ajax').checked + ",";
//  valor += "cenas_RF_ajax=" + document.getElementById('ctl00_cenas_RF_ajax').checked + ",";
    
    createCookie('pref_opcoes_ajax', valor, 10);
}

function GravarPreferenciasDisponibilidadeAjax()
{
    var valor;

    // 0 - 5
    valor += "publicidade_search_ajax=" + document.getElementById('ctl00_publicidade_search_ajax').disabled + ",";
    valor += "publicidade_port_ajax=" + document.getElementById('ctl00_publicidade_port_ajax').disabled + ",";
    valor += "publicidade_eng_ajax=" + document.getElementById('ctl00_publicidade_eng_ajax').disabled + ",";
    valor += "publicidade_port_DC_ajax=" + document.getElementById('ctl00_publicidade_port_DC_ajax').disabled + ",";
    valor += "publicidade_port_RF_ajax=" + document.getElementById('ctl00_publicidade_port_RF_ajax').disabled + ",";
    valor += "editorial_ajax=" + document.getElementById('ctl00_editorial_ajax').disabled + ",";
    // 6 - 15
    valor += "editorial_tipo_animais2=" + document.getElementById('ctl00_editorial_tipo_animais2').disabled + ",";
    valor += "editorial_tipo_arte2=" + document.getElementById('ctl00_editorial_tipo_arte2').disabled + ",";
    valor += "editorial_tipo_ciencia2=" + document.getElementById('ctl00_editorial_tipo_ciencia2').disabled + ",";
    valor += "editorial_tipo_criativo2=" + document.getElementById('ctl00_editorial_tipo_criativo2').disabled + ",";
    valor += "editorial_tipo_entretenimento2=" + document.getElementById('ctl00_editorial_tipo_entretenimento2').disabled + ",";
    valor += "editorial_tipo_esporte2=" + document.getElementById('ctl00_editorial_tipo_esporte2').disabled + ",";
    valor += "editorial_tipo_gastronomia2=" + document.getElementById('ctl00_editorial_tipo_gastronomia2').disabled + ",";
    valor += "editorial_tipo_historia2=" + document.getElementById('ctl00_editorial_tipo_historia2').disabled + ",";
    valor += "editorial_tipo_noticias2=" + document.getElementById('ctl00_editorial_tipo_noticias2').disabled + ",";
    valor += "editorial_tipo_viagens2=" + document.getElementById('ctl00_editorial_tipo_viagens2').disabled + ",";
    // 16 - 21
    valor += "editorial_date_ajax=" + document.getElementById('ctl00_editorial_date_ajax').disabled + ",";
    valor += "data_especifica_ajax=" + document.getElementById('ctl00_data_especifica_ajax').disabled + ",";
    valor += "search_all_ajax=" + document.getElementById('ctl00_search_all_ajax').disabled + ",";
    valor += "cenas_ajax=" + document.getElementById('ctl00_cenas_ajax').disabled + ",";
//  valor += "cenas_DC_ajax=" + document.getElementById('ctl00_cenas_DC_ajax').disabled + ",";
//  valor += "cenas_RF_ajax=" + document.getElementById('ctl00_cenas_RF_ajax').disabled;
    
    createCookie('pref_disponivel_ajax', valor, 10);
}

function createCookie(name,value,days)
{
    var expires;
    if (days)
    {
	    var date = new Date();
	    date.setTime(date.getTime()+(days*24*60*60*1000));
	    expires = "; expires="+date.toGMTString();
    }
    else 
        expires = "";

    document.cookie = name+"="+value+expires+"; path=/";
}