/* 
 * PROCERGS - Companhia de Processamento de Dados do Estado do Rio Grande do Sul
 * 
 * Desenvolvedor: Frederico S. Ayestaran
 * Data: 01/08/2011
 */

$(document).ready(function(){
    var time_destaque;
    var botao_clicado = 1;
    var tempo_destaques = 5.0; //segundos
    var quantidade_destaques = $('.btnDestaque').length;
	
    //$('div#marcador01').css('background-image', 'url(../imagens/marcador01h.png)');
    //$('div#marcador01').replaceWith("<div id='marcador01' class='marcadorOn' style='line-height: 27px;'>1</div>");
    $('div#marcador01').removeClass('marcadorOff').addClass('marcadorOn');

    /*
	$('.btnSegurado1').click(function(e){
		////trocaDiv('s');
		//trocaIframe("http://pip.des.procergs.reders/ipe-usuario-logon_inicial.html", 1);
        openModalIframe('ipe-usuario-logon_inicial.html', 788, 500);
		//$('#iframec').attr('scrolling', 'no');
		//http://webgenteste/cgi-bin/webgen2.cgi?TR=ipe-usuario-logon&A10-organiz=IPE&N14-usuario=8796043493001&N8-senha=737747
		//history.go(-2); (problema)
		//trocaIframe("http://pip.des.procergs.reders/include/capa.request.php?TR=ipe-usuario-logon&A10-organiz=IPE&N14-usuario=8796043493001&N8-senha=737747", 1);
	});
	$('.btnSegurado2').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://pip.des.procergs.reders/include/capa.request.php?TR=sbi-grupofamiliar-con", 1);
		//trocaIframe("http://webgenteste/cgi-bin/webgen2.cgi?TR=sbi-grupofamiliar-con", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=24";
	});
	$('.btnSegurado3').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://webgenteste/cgi-bin/webgen2.cgi?TR=sbi-dadoscadastrais-con", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=25";
	});
	$('.btnSegurado4').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://webgenteste/cgi-bin/webgen2.cgi?TR=sbi-dadoscadastrais-atu", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=26";
	});
	$('.btnSegurado5').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://webgenteste/cgi-bin/webgen2.cgi?TR=sbi-senha-con", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=27";
	});
	$('.btnSegurado6').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-histemerg-lista.html", 1);
		//trocaIframe("http://argolida/ipesaudeu/smh-histemerg-lista.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=15";
	});
	$('.btnSegurado7').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-histinternacoes-lista.html", 1);
		//trocaIframe("http://argolida/ipesaudeu/smh-histinternacoes-lista.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=16";
	});
	$('.btnSegurado8').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-histservicos-lista.html", 1);
		//trocaIframe("http://argolida/ipesaudeu/smh-histservicos-lista.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=17";
	});
	$('.btnSegurado9').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-histconsultas-lista.html", 1);
		//trocaIframe("http://argolida/ipesaudeu/smh-histconsultas-lista.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=14";
	});
	$('.btnSegurado10').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://pip.des.procergs.reders/pro/asi-extrato-con.html", 1);
		//trocaIframe("http://argolida/ipesaudeu/asi-extrato-con.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=2";
	});
	$('.btnSegurado11').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://pip.des.procergs.reders/pro/sci-extrato-con.html", 1);
		//trocaIframe("http://argolida/ipesaudeu/sci-extrato-con.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=7";
	});
	$('.btnSegurado12').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://webgenteste/cgi-bin/webgen2.cgi?TR=asi-doc-emissao&N01_cod=3", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=34";
	});
	$('.btnSegurado13').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://webgenteste/cgi-bin/webgen2.cgi?TR=asi-docematraso-seleciona&N01_cod=3", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=35";
	});
	$('.btnSegurado14').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://webgenteste/cgi-bin/webgen2.cgi?TR=asi-doc-emissao&N01_cod=4", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=36";
	});
	$('.btnSegurado15').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://webgenteste/cgi-bin/webgen2.cgi?TR=asi-docematraso-seleciona&N01_cod=4", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=37";
	});
	$('.btnSegurado16').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://webgenteste/cgi-bin/webgen2.cgi?TR=asi-doc-emissao&N01_cod=5", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=38";
	});
	$('.btnSegurado17').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://webgenteste/cgi-bin/webgen2.cgi?TR=asi-docematraso-seleciona&N01_cod=5", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=39";
	});
	$('.btnSegurado18').click(function(e){
		//trocaDiv('s');
		//trocaIframe("http://webgenteste/cgi-bin/webgen2.cgi?TR=sci-doc-seleciona&N01_cod=0", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=40";
	});
	$('.btnPensionista1').click(function(e){
		////trocaDiv('p');
		//trocaIframe("http://pip.des.procergs.reders/ipe-pensionista-logon_inicial.html", 1);
		//$('#iframe').attr('scrolling', 'no');
        openModalIframe('ipe-pensionista-logon_inicial.html', 788, 500);
	});
	$('.btnPensionista2').click(function(e){
		//trocaDiv('p');
		//trocaIframe("http://webgenteste/cgi-bin/webgen2.cgi?TR=sbi-dadoscadastrais-con", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=41";
	});
	$('.btnPensionista3').click(function(e){
		//trocaDiv('p');
		//trocaIframe("http://webgenteste/cgi-bin/webgen2.cgi?TR=sbi-dadoscadastrais-atu", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=42";
	});
	$('.btnPensionista4').click(function(e){
		//trocaDiv('p');
		//trocaIframe("http://webgenteste/cgi-bin/webgen2.cgi?TR=sbi-sen-altera", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=43";
	});
	$('.btnPensionista5').click(function(e){
		//trocaDiv('p');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-histemerg-lista.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=45";
	});
	$('.btnPensionista6').click(function(e){
		//trocaDiv('p');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-histinternacoes-lista.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=46";
	});
	$('.btnPensionista7').click(function(e){
		//trocaDiv('p');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-histservicos-lista.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=47";
	});
	$('.btnPensionista8').click(function(e){
		//trocaDiv('p');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-histconsultas-lista.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=44";
	});
	$('.btnPensionista9').click(function(e){
		//trocaDiv('p');
		//trocaIframe("http://pip.des.procergs.reders/pro/api-ccheque-con.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=1";
	});
	$('.btnPensionista10').click(function(e){
		//trocaDiv('p');
		//trocaIframe("http://pip.des.procergs.reders/pro/sri-declarend-con.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=23";
	});
	$('.btnCredenciado1').click(function(e){
		//trocaDiv('c');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-consulta-aut.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=8";
	});
	$('.btnCredenciado2').click(function(e){
		//trocaDiv('c');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-exame-aut.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=11";
	});
	$('.btnCredenciado3').click(function(e){
		//trocaDiv('c');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-consulta-lista.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=9";
	});
	$('.btnCredenciado4').click(function(e){
		//trocaDiv('c');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-exame-lista.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=12";
	});
	$('.btnCredenciado5').click(function(e){
		//trocaDiv('c');
		//trocaIframe("http://pip.des.procergs.reders/pro/sbi-usuario-consulta_situacao.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=6";
	});
	$('.btnCredenciado6').click(function(e){
		//trocaDiv('c');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-solicitante-con.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=22";
	});
	$('.btnCredenciado7').click(function(e){
		//trocaDiv('c');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-formulario-lista_relacao_consultas.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=13";
	});
	$('.btnCredenciado8').click(function(e){
		//trocaDiv('c');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-relatorio_auditoria-lista.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=21";
	});
	$('.btnCredenciado9').click(function(e){
		//trocaDiv('c');
		//trocaIframe("http://pip.des.procergs.reders/pro/ipecredenc/smh-ga-logon.html?codcredenc=00000000", 1);
		//openModalIframe('http://pip.des.procergs.reders/pro/ipecredenc/smh-ga-logon.html?codcredenc=00000000', 788, 500);
		//window.open('http://pip.des.procergs.reders/pro/ipecredenc/smh-ga-logon.html?codcredenc=00000000', "window","width=900,height=450");
		openModalWindow('http://pip.des.procergs.reders/pro/ipecredenc/smh-ga-logon.html?codcredenc=00000000');
	});
	$('.btnCredenciado10').click(function(e){
		//trocaDiv('c');
		//trocaIframe("http://pip.des.procergs.reders/smh-prest-valida_senha.html", 1);
		//window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=20";
		//window.open('http://pip.des.procergs.reders/pro_ht/smh-prest-valida_senha.html', "window","width=900,height=450");
		openModalWindow('http://pip.des.procergs.reders/pro_ht/smh-prest-valida_senha.html');
	});
	$('.btnCredenciado11').click(function(e){
		//trocaDiv('c');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-honorario-con_cod_livre.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=18";
	});
	$('.btnCredenciado12').click(function(e){
		//trocaDiv('c');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-honorario-con_desc_livre.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=19";
	});
	$('.btnCredenciado13').click(function(e){
		//trocaDiv('c');
		//trocaIframe("http://pip.des.procergs.reders/pro/smh-despesa-con_desc_livre.html", 1);
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=10";
	});
	$('.btnCredenciado14').click(function(e){
		//trocaDiv('c');
		//openModalIframe('http://pip.des.procergs.reders/Tabela Pronto Atendimento.txt', 788, 500);
		//trocaIframe("http://pip.des.procergs.reders/Tabela Pronto Atendimento.txt", 1);
		//window.open('http://pip.des.procergs.reders/Tabela Pronto Atendimento.txt', "window","width=768,height=640");
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=48";
	});
	$('.btnCredenciado15').click(function(e){
		//trocaDiv('c');
		//openModalIframe('http://webgenteste/cgi-bin/webgen2.exe?TR=smh-brasindice-consulta_material&A50_c=\' \'', 788, 500);
		//trocaIframe("http://webgenteste/cgi-bin/webgen2.exe?TR=smh-brasindice-consulta_material&A50_c=' '", 1);
		//window.open('http://webgenteste/cgi-bin/webgen2.exe?TR=smh-brasindice-consulta_material&A50_c=\' \'', "window","width=768,height=640");
		window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=49";
	});
	$('.btnCredenciado16').click(function(e){
		//window.location="http://pip.des.procergs.reders/index.php?model=webgen&id=53";
		//window.open('http://pip.des.procergs.reders/pro_ht/smh-credenciado-logon_inicial.html', "window","width=900,height=450");
		openModalWindow('http://pip.des.procergs.reders/pro_ht/smh-credenciado-logon_inicial.html');
	});
	*/
	
    $('.btnBuscar').click(function(e){
        e.preventDefault();
        //openModalIframe('http://pip.des.procergs.reders/pro/smh-rede-con_credenciada.html', 788, 500);
		
        //<!--http://webgenteste/cgi-bin/webgen2.cgi?TR=smh-rede-lista_medicos&n01_etapa=0&n05_codlocalid=00047&N1_P_grava=0&n04_xxx=0000&n02_tipoProf=01&n03-codespec=104&n03_areaatu=000-->
        //teste post
        //document.getElementById('nomeTR').value= 'smh-rede-lista_medicos';
        //if (document.guia.a45-bairro.selectedIndex == 0) document.getElementById('a45-bairr').value = '';
        //alert(document.guia.n03_areaatu.selectedIndex);
        //alert(document.getElementById('a45-nome-medico').value);
        //document.guia.submit();

        //var iframe_location='http://pip.des.procergs.reders/include/capa.request.php';
        var iframe_location='http://www.ipe.rs.gov.br/include/capa.request.php';
        //var iframe_location='http://webgenteste/cgi-bin/webgen2.cgi';
        //var iframe_location='http://webgenteste/cgi-bin/webgen2.cgi';
        var iframe_location_tag='';
        var iframe_tr='';
        var iframe_distancia='';
        var iframe_bairro='';
        var iframe_cep='';
        if (document.guia.n03_codespec.options.selectedIndex == 0) document.guia.n03_codespec.options.selectedIndex = 1;
        if (document.guia.n03_codespecSD.options.selectedIndex == 0) document.guia.n03_codespecSD.options.selectedIndex = 1;
        if (document.guia.n03_codespecSA.options.selectedIndex == 0) document.guia.n03_codespecSA.options.selectedIndex = 1;
				
        if (document.guia.n03_areaatu.selectedIndex == 0) document.guia.n03_areaatu.selectedIndex = 1;
        if (document.getElementById('n08-cep').value == 'CEP') document.getElementById('n08-cep').value = '';
        //if (document.getElementById('a45_bairr').value == 'Bairro') document.getElementById('a45_bairr').value = '';
        if (document.getElementById('a45-nome-medico').value == 'Nome Prestador') document.getElementById('a45-nome-medico').value = '';
		
        if (document.getElementById('a45-nome-medico').value != '') 
            iframe_tr='smh-rede-lista_credenciados_nome';

        if (document.guia.n02_tipoProf.selectedIndex == 0) {
            iframe_tr='erro_s';
        } else if ((iframe_tr == '') && (document.guia.n02_tipoProf.selectedIndex == 1)) {
            iframe_tr='smh-rede-lista_medicos';
        //iframe_tr='smh-rede-lista_medicos_novoipe';
        } else if ((iframe_tr == '') && (document.guia.n02_tipoProf.selectedIndex == 2)) {
            iframe_tr='smh-rede-lista_servicos_buco';
        } else if ((iframe_tr == '') && (document.guia.n02_tipoProf.selectedIndex == 3)) {
            iframe_tr='smh-rede-lista_hospitais';
        //iframe_tr='smh-rede-lista_hospitais_novoipe';
        } else if ((iframe_tr == '') && (document.guia.n02_tipoProf.selectedIndex == 4)) {
            iframe_tr='smh-rede-lista_laboratorios';
        } else if ((iframe_tr == '') && (document.guia.n02_tipoProf.selectedIndex == 5)) {
            iframe_tr='smh-rede-lista_clinicas';
        } else if ((iframe_tr == '') && (document.guia.n02_tipoProf.selectedIndex == 6)) {
            iframe_tr='smh-rede-lista_servicos_emergencia';
        } else if ((iframe_tr == '') && (document.guia.n02_tipoProf.selectedIndex == 7)) {
            iframe_tr='smh-rede-lista_servico_especial';
        } else if ((iframe_tr == '') && (document.guia.n02_tipoProf.selectedIndex == 8)) {
            iframe_tr='smh-rede-lista_servico_especial';
        }
        iframe_location = iframe_location +
        '?TR=' + iframe_tr +
        '&n01_etapa=' + '0';
						
        if (((document.guia.n05_codlocalid.selectedIndex == 0) || (document.guia.n05_codlocalid.selectedIndex == 1)) && (document.getElementById('a45-nome-medico').value == '')){
            iframe_tr='erro_l';
        } 
		
        if ((document.guia.n05_codlocalid.selectedIndex != 0) && (document.guia.n05_codlocalid.selectedIndex != 1)) {
            iframe_location = iframe_location +
            '&n05_codlocalid=' + document.guia.n05_codlocalid.options[document.guia.n05_codlocalid.selectedIndex].value;
        } else {
            iframe_location = iframe_location +
            '&n05_codlocalid=';
        }
						
        if ((parseInt(presubmit_numericos(document.getElementById('n4_P_distancia').value)) == 0) || (presubmit_numericos(document.getElementById('n4_P_distancia').value) == '')) {
            iframe_location = iframe_location +
            '&N1_P_grava=' + '0' +
            '&n4_P_distancia=';
        } else if (parseInt(presubmit_numericos(document.getElementById('n4_P_distancia').value)) <= 100) {
            iframe_distancia = parseInt(presubmit_numericos(document.getElementById('n4_P_distancia').value));
            iframe_location = iframe_location +
            '&N1_P_grava=' + '1' +
            '&n4_P_distancia=' + iframe_distancia;
        } else {
            iframe_distancia = 100;
            iframe_location = iframe_location +
            '&N1_P_grava=' + '1' +
            '&n4_P_distancia=' + iframe_distancia;
        }
		
        iframe_location = iframe_location +
        '&n02_tipoProf=' + document.guia.n02_tipoProf.options[document.guia.n02_tipoProf.selectedIndex].value;

        if (document.guia.n02_tipoProf.selectedIndex == 1) {
            iframe_location = iframe_location +
            '&n03-codespec=' + document.guia.n03_codespec.options[document.guia.n03_codespec.selectedIndex].value;
        } else if (document.guia.n02_tipoProf.selectedIndex == 7) {
            iframe_location = iframe_location +
            '&n03-codespec=' + document.guia.n03_codespecSD.options[document.guia.n03_codespecSD.selectedIndex].value;
        } else if (document.guia.n02_tipoProf.selectedIndex == 8) {
            iframe_location = iframe_location +
            '&n03-codespec=' + document.guia.n03_codespecSA.options[document.guia.n03_codespecSA.selectedIndex].value;
        } else {
            iframe_location = iframe_location +
            '&n03-codespec=';
        }
        iframe_location = iframe_location +
        '&n03_areaatu=' + document.guia.n03_areaatu.options[document.guia.n03_areaatu.selectedIndex].value +
        '&a45-nome-medico=' + document.getElementById('a45-nome-medico').value;

        if (document.getElementById('n05_codlocalid').value == '00047') {
            iframe_cep = presubmit_numericos(document.getElementById('n08-cep').value);
            iframe_location = iframe_location +
            '&n08-cep=' + iframe_cep;
        }
        if ((document.getElementById('n05_codlocalid').value == '00047') && (document.guia.a45_bairr.selectedIndex != 0) && (document.guia.a45_bairr.selectedIndex != 1)) {
        //if ((document.getElementById('n05_codlocalid').value == '00047') && (document.getElementById('a45_bairr').value != 'Bairro') && (document.getElementById('a45_bairr').value != '')) {
            iframe_bairro = document.guia.a45_bairr.options[document.guia.a45_bairr.selectedIndex].text;
            //iframe_bairro = document.getElementById('a45_bairr').value;
			//iframe_bairro = iframe_bairro.replace(" ", "___");
			//iframe_bairro = iframe_bairro.replace("'", "____");
			while (iframe_bairro.indexOf(" ") != -1) { iframe_bairro = iframe_bairro.replace(" ", "___"); }
			while (iframe_bairro.indexOf("'") != -1) { iframe_bairro = iframe_bairro.replace("'", "____"); }
            iframe_location = iframe_location +
            '&a45-bairr=' + iframe_bairro;
        }

        //alert(iframe_location);
        if (document.guia.n03_codespec.options.selectedIndex == 1) document.guia.n03_codespec.options.selectedIndex = 0;
        if (document.guia.n03_codespecSD.options.selectedIndex == 1) document.guia.n03_codespecSD.options.selectedIndex = 0;
        if (document.guia.n03_codespecSA.options.selectedIndex == 1) document.guia.n03_codespecSA.options.selectedIndex = 0;
        if (document.guia.n03_areaatu.selectedIndex == 1) document.guia.n03_areaatu.selectedIndex = 0;
        if (document.getElementById('n08-cep').value == '') document.getElementById('n08-cep').value = 'CEP';
        //if (document.getElementById('a45_bairr').value == '') document.getElementById('a45_bairr').value = 'Bairro';
        if (document.getElementById('a45-nome-medico').value == '') document.getElementById('a45-nome-medico').value = 'Nome Prestador';

        if ((iframe_tr == 'smh-rede-lista_credenciados_nome') && (iframe_distancia > 0)) {
            alert('Ao pesquisar por nome, não incluir distância para cidades próximas!');
        } else if ((iframe_tr == 'smh-rede-lista_credenciados_nome') && (iframe_cep != ''))	{
            alert('Ao pesquisar por nome, não incluir CEP!');
        } else if ((iframe_tr == 'smh-rede-lista_credenciados_nome') && (iframe_bairro != ''))	{
            alert('Ao pesquisar por nome, não incluir bairro!');
        } else if (iframe_tr == 'erro_s') {
            alert("Selecione um serviço");
        } else if (iframe_tr == 'erro_l') {
            alert("Selecione uma localidade");
        } else {
            //alert(iframe_location);
            trocaIframe(iframe_location, 0);
        //if((document.getElementById('n05_codlocalid').value == '00382') && (iframe_tr == 'smh-rede-lista_servicos_emergencia')) {
        //	iframe_location = "http://pip.des.procergs.reders/include/capa.request.php";
        //}
        //window.location=iframe_location;
        //iframe_location = 'http://pro-pae-0040.procergs.reders/6/index.htm';

        /*
        iframe_location_tag = "<div class='conteudoB' id='conteudoB'><iframe id='iframe' name='iframe' class='autoHeight' " +
                                                  "style='display:block; margin-right: -15px; margin-left: -15px; margin-top: 0px; padding: 0px; overflow-x: hidden;' " +
                                                  "src='" + iframe_location + "'frameBorder=0 width='635' height='100%' scrolling=no></iframe></div>";
        $('div.conteudoB').replaceWith(iframe_location_tag);
        */
						
        //alert(window.iframe.var1);
        //alert(var1);
        //alert(iframe_location);
        //$('div.conteudoB').load(iframe_location);
						
        //$req = curl_init("http://pro-pae-0040/6/index.htm");
        //curl_setopt($req, CURLOPT_RETURNTRANSFER, TRUE);
        //curl_setopt($req, CURLOPT_BINARYTRANSFER,TRUE);
        //$res = curl_exec($req); curl_close($req);

        //$('div.conteudoB').replaceWith("<div class='conteudoB' id='conteudoB'>" + echo $res + "</div>");
						
        //$('#iframe').attr('height', '705');
        //alert(document.getElementById('iframe').offsetHeight);
        //alert(document.getElementById('iframe').scrollHeight);
        //alert(document.getElementById('iframe').clientHeight);
        //alert(document.getElementById('iframe').scrollTop);
        //alert(document.getElementById('iframe').offsetTop);
        //alert(document.getElementById('iframe').contentWindow.document.body.scrollHeight);
        //alert(document.getElementById('iframe').document.body.scrollHeight);
        //alert(window.iframe.var1);
        //alert(document.getElementById('iframe').var1);
        //document.body.scrollHeight
        //alert(iframe.content.document.getElementsByTagName("body")[0]);
        //alert(iframe.content.document.getElementsById("Layer3"));
        //alert(parseInt(x.document.defaultView.getComputedStyle(iframe.content.document.getElementsByTagName("body")[0], "").getPropertyValue("height")));

        //http://www.pixelmedia.com/blog/dynamic-iframe-height/
        //http://sonspring.com/journal/jquery-iframe-sizing
        //http://www.phinesolutions.com/use-jquery-to-adjust-the-iframe-height.html
        //http://stackoverflow.com/questions/3734478/html-pages-full-height-including-the-content-beyond-the-scroll
						
        //javascript:alert(window.content.document.getElementsByTagName("iframe") )
						
        //var x = window.content;
        //var pageBody = x.window.content.document.getElementsByTagName("body")[0];    
        //var my_pageheight = parseInt(x.document.defaultView.getComputedStyle(pageBody, "").getPropertyValue("height"));

        }
		
    });
	
    //$('#iframe').load(function() {
    //$('body', $('iframe').contents()).html('Hello World!');
    //alert(var1);
    //});
	
    /*
	function getDocumentHeight() {
		if($.browser.msie) { 
			var $temp = $("<div>") 
			.css("position","absolute") 
			.css("left","-10000px") 
			.append($("body").html());   
			$("body").append($temp); 
			var h = $temp.height(); 
			$temp.remove(); 
			return h; 
		} 
		return 
	}*/
	
    /*
	$('.botBuscarReg').click(function(e){
        e.preventDefault();
		var iframe_location='http://pip.des.procergs.reders/pesquisa_agencia.asp';
		iframe_location = iframe_location + '?txtMunicipio=' + document.getElementById('formBusca').value;
		trocaIframe(iframe_location, 1);
	});*/

    /*
	$('#consultaSenha').click(function(e){
        e.preventDefault();
		trocaIframe("http://pip.des.procergs.reders/pro_ht/sbi-senha-altera.html", 1);
	});*/
	
	
    $('.btnDestaque').click(function(e){
        e.preventDefault();
        
        //$('div#marcador01').css('background-image', 'url(../imagens/marcador01.png)');
        //$('div#marcador02').css('background-image', 'url(../imagens/marcador02.png)');
        //$('div#marcador03').css('background-image', 'url(../imagens/marcador03.png)');
        //$('div#marcador04').css('background-image', 'url(../imagens/marcador04.png)');

        clearTimeout(time_destaque);
		
        //alert('Oi!');
        //$('.contInativo').removeClass('contAtivo');
        //$('#dvDestaque_' + $(this).attr('href')).addClass('contAtivo');
        //$('#marcador0' + $(this).attr('href')).addClass('contAtivo');

        //$('div.marcador01').className.replace('marcadorOff','marcadorOn')); 
        //$('div.marcadores').replaceWith('');
        //$(this).replaceWith('');
        //echo "<a href='$i' class='btnDestaque'><div id='marcador0$i' class='marcadorOff' style='line-height: 27px;'>$i</div></a>";
		
        //$('div#marcador0' + $(this).attr('href')).replaceWith("<div id='marcador0" + $(this).attr('href') + " class='marcadorOff' style='line-height: 27px;'>" + $(this).attr('href') + "</div>");
		
        $('div#marcador01, div#marcador02, div#marcador03, div#marcador04').removeClass('marcadorOn').addClass('marcadorOff');
        $('div#marcador0' + $(this).attr('href')).removeClass('marcadorOff').addClass('marcadorOn');

        $('div#tituloDestaque1').css('display', 'none');
        $('div#tituloDestaque2').css('display', 'none');
        $('div#tituloDestaque3').css('display', 'none');
        $('div#tituloDestaque4').css('display', 'none');
        $('div#textoDestaque1').css('display', 'none');
        $('div#textoDestaque2').css('display', 'none');
        $('div#textoDestaque3').css('display', 'none');
        $('div#textoDestaque4').css('display', 'none');
        $('img#imagemDest01').css('display', 'none');
        $('img#imagemDest02').css('display', 'none');
        $('img#imagemDest03').css('display', 'none');
        $('img#imagemDest04').css('display', 'none');

        ////Frederico
        //$('div.tituloDestaque').css('display', 'none');
        $('div#tituloDestaque' + $(this).attr('href')).css('display', '');
        //$('div#tituloDestaque' + $(this).attr('href')).removeClass('tituloDestaque').addClass('tituloDestaque');
        //$('div#tituloDestaque' + $(this).attr('href')).fadeOut(0)
        //$('div#tituloDestaque' + $(this).attr('href')).fadeIn(1400);
        //$('div#marcador0' + $(this).attr('href')).fadeTo("fast", 0.7);   
        //$('div#marcador0' + $(this).attr('href')).fadeTo("slow", 1.0);   
        //$('div#marcador0' + $(this).attr('href')).css('background-image', 'url(../imagens/marcador0' + $(this).attr('href') + 'h.png)');

        //MOSTRA O TEXTO SELECIONADO
        //$('div.textoDestaque').css('display', 'none');
        $('div#textoDestaque' + $(this).attr('href')).css('display', '');
        //$('div#textoDestaque' + $(this).attr('href')).removeClass('textoDestaque').addClass('textoDestaque');
        $('div#textoDestaque' + $(this).attr('href')).fadeOut(0);
        $('div#textoDestaque' + $(this).attr('href')).fadeIn(1400);
        //MOSTRA A FOTO SELECIONADA
        //$('div.fundoImgDestaque').css('display', 'none');
        $('img#imagemDest0' + $(this).attr('href')).css('display', '');
        //$('div#fundoImgDestaque' + $(this).attr('href')).removeClass('fundoImgDestaque').addClass('fundoImgDestaque');
        $('img#imagemDest0' + $(this).attr('href')).fadeOut(0)
        $('img#imagemDest0' + $(this).attr('href')).fadeIn(1400);
		
        time_destaque = setTimeout(trocaDestaque, tempo_destaques * 1000);
    //botao_clicado = $(this).attr('href');
    });
	
    function trocaDestaque(){
        if(botao_clicado == quantidade_destaques){
            botao_clicado = 1;
            $('#marcador01').click();
        }else {
            botao_clicado = botao_clicado + 1;
            var nomeProximoBotao = "#marcador0" + botao_clicado;
            $(nomeProximoBotao).click();
        }
    }

    time_destaque = setTimeout(trocaDestaque, tempo_destaques * 1000);

    $('#irDireita').click(function(e){
        e.preventDefault()
        });
    $('#irEsquerda').click(function(e){
        e.preventDefault()
        });

    $(".dvCarrossel").jCarouselLite({
        btnNext: "#irDireita",
        btnPrev: "#irEsquerda",
        circular: false //TODO: Temporário até corrigir o BUG do componente (jCarouselLite)

    });


    if(!$.browser.chrome && !$.browser.webkit){
        var h = $('.fotoMenor', $('.dvCarrossel')).outerHeight(true);
        //      alert(h);
        $('.dvCarrossel').height(h);
        $('ul', $('.dvCarrossel')).height(h);
        $('li', $('.dvCarrossel')).height(h);
    }

});
