/* Sam.JS */

function showPopUp(page,name,width,height) {
  window.open(page, name, "menubar=0,toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=0,width="+width+",height="+height+",top=50,left=100");			
}

function showEmConstrucao() {
  window.open("em_construcao.htm", "EMCONSTRUCAO", "menubar=0,toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=0,width=400,height=400,top=50,left=100");			
}

function openWindowOdonto() {
   window.open("http://www.crownodonto.com.br/novosite/associado.aspx", "Odonto");			
}

function carteiras() {
   window.open("tiss/carteiras.htm", "Carteiras", "menubar=0,toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0,width=800,height=160,top=180,left=0");			
}

function vendas() {
   window.open("vendas.php", "FormVendas", "menubar=0,toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0,width=460,height=500,top=50,left=150");			
}

function videoTissNet() {
   w = 825;
   h = screen.height - 150;
   h = screen.height - 150;
   l = (screen.width - w)/2;
   window.open("tiss/apresentacao_tissnet.htm", "VideoTissNet", "menubar=0,toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0,width="+w+",height="+h+",top=20,left="+l+"");			
}

function openInstrucaoNormativa() {
   w = 600;
   h = screen.height - 150;
   h = screen.height - 150;
   l = (screen.width - w)/2;
   window.open("tiss/instrucao_normativa_25_09_2008.htm", "InstrucaoNormativa", "menubar=0,toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0,width="+w+",height="+h+",top=20,left="+l+"");			
}

function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function conta(campo,limite) {      
   if (campo.value.length>limite) {
      campo.value = campo.value.substring(0,limite);
      document.getElementById('limite').value = limite+" caracteres digitados.";
      return false;
   }
   document.getElementById('limite').value = campo.value.length + " caracteres digitados.";
}

// --------------------------------------------------------- // 
function sendFormFaleConosco() {
   // if (CheckFormFaleConosco(document.getElementById('FormFaleConosco'))==false) return;
	
   var params = Form.serialize('FormFaleConosco');   
   var url = 'controller.php?action=FormFaleConosco';
   
   document.getElementById('FormFaleConosco').style.display = "none"; 
   document.getElementById('msgForm').style.display = "block"; 
   
   var objAjaxLivros = new Ajax.Request( url,{ method: 'post', parameters: params, onComplete: returnForm});
   $('msgForm').innerHTML = "<div id='sending_form'><img src='imgs/ajax-loader.gif'> <br> Enviando Formul&aacute;rio, Aguarde...</div><br /><br /><br /><br />";
}

function returnForm(response) {
   $('msgForm').innerHTML = response.responseText;
}

function historyBackFormFaleConosco(){
   document.getElementById('msgForm').style.display = "none"; 
   document.getElementById('FormFaleConosco').style.display = "block";   
}

function CheckFormFaleConosco(form) {
   if (form.objetivo.value == "---") { 
      alert("Por favor escolha qual o objetivo de seu contato!");
      form.objetivo.focus();
      return false;
   }
   if (form.objetivo.value == "Dúvida:")  { 
      alert("Por favor especifique em qual tipo de plano você tem dúvida!");
      form.objetivo.focus();
      return false;
   }
   if (form.objetivo.value == " ")  { 
      alert("Por favor escolha qual o objetivo de seu contato!");
      form.objetivo.focus();
      return false;
   }
   if (form.nome.value == "")  { 
      alert("Por favor preencha o Campo Nome Corretamente!");
      form.nome.focus();
	  return false;
   }
   if ((form.telefone.value == "") && (form.email.value == ""))  { 
      alert("Por favor preencha pelo meno um dos campos acima, ou Telefone ou E-mail!");
      form.telefone.focus();
	  return false;
   }
   if ((form.email.value == "") && (form.telefone.value == "")) { 
      alert("Por favor preencha pelo meno um dos campos acima, ou Telefone ou E-mail!");
      form.email.focus();
	  return false;
   } 
   else {
      prim = form.email.value.indexOf("@")
      if((prim < 0) && (form.telefone.value == "")) {
         alert("O e-mail digitado parece estar incorreto. Por favor verifique e digite o e-mail correto");
         form.email.focus();
         return false;
      }
      if((form.email.value.indexOf("@",prim + 1) != -1) && (form.telefone.value == "")) {
         alert("O e-mail digitado parece estar incorreto. Por favor verifique e digite o e-mail correto");
         form.email.focus();
         return false;
      }
      if((form.email.value.indexOf(".") < 0) && (form.telefone.value == "")) {
         alert("O e-mail digitado parece estar incorreto. Por favor verifique e digite o e-mail correto");
         form.email.focus();
         return false;
      }
      if((form.email.value.indexOf(" ") != -1) && (form.telefone.value == "")) {
         alert("O e-mail digitado parece estar incorreto. Por favor verifique e digite o e-mail correto");
         form.email.focus();
         return false;
      }
      if((form.email.value.indexOf("www.") != -1) && (form.telefone.value == "")) {
         alert("O e-mail digitado contém o termo WWW que não é usado em e-mails. Por favor digite o e-mail correto.");
         form.email.focus();
         return false;
      }
      if((form.email.value.indexOf("/") > 0) && (form.telefone.value == "")) {
         alert("O e-mail digitado parece estar incorreto. Por favor verifique e digite o e-mail correto");
         form.email.focus();
         return false;
      }
      if((form.email.value.indexOf("[") > 0) && (form.telefone.value == "")) {
         alert("O e-mail digitado parece estar incorreto. Por favor verifique e digite o e-mail correto");
         form.email.focus();
         return false;
      }
      if((form.email.value.indexOf("]") > 0) && (form.telefone.value == "")) {
         alert("O e-mail digitado parece estar incorreto. Por favor verifique e digite o e-mail correto");
         form.email.focus();
         return false;
      }
      if((form.email.value.indexOf("(") > 0) && (form.telefone.value == "")) {
         alert("O e-mail digitado parece estar incorreto. Por favor verifique e digite o e-mail correto");
         form.email.focus();
         return false;
      }
      if((form.email.value.indexOf(")") > 0) && (form.telefone.value == "")) {
         alert("O e-mail digitado parece estar incorreto. Por favor verifique e digite o e-mail correto");
         form.email.focus();
         return false;
      }
      if((form.email.value.indexOf("..") > 0) && (form.telefone.value == "")) {
         alert("O e-mail digitado parece estar incorreto. Por favor verifique e digite o e-mail correto");
         form.email.focus();
         return false;
      }
   }  
}

function sendFormConsultas() {
   var params = Form.serialize('FormConsultas');   
   var url = 'controller.php?action=FormConsultas';
   
   document.getElementById('FormConsultas').style.display = "none"; 
   document.getElementById('msgFormConsultas').style.display = "block"; 
   
   var objAjaxLivros = new Ajax.Request( url,{ method: 'post', parameters: params, onComplete: returnFormConsultas});
   $('msgFormConsultas').innerHTML = "<div id='sending_form'><img src='imgs/ajax-loader.gif'> <br> Enviando Formul&aacute;rio, Aguarde...</div><br /><br /><br /><br />";
}

function returnFormConsultas(response) {
   $('msgFormConsultas').innerHTML = response.responseText;
}

function historyBackFormConsultas(){
   document.getElementById('msgFormConsultas').style.display = "none"; 
   document.getElementById('FormConsultas').style.display = "block";   
}

function sendFormVendas() {
   var params = Form.serialize('FormVendas');   
   var url = 'controller.php?action=FormVendas';
   
   document.getElementById('FormVendas').style.display = "none"; 
   document.getElementById('msgForm').style.display = "block"; 
   
   var objAjaxLivros = new Ajax.Request( url,{ method: 'post', parameters: params, onComplete: returnForm});
   $('msgForm').innerHTML = "<br /><br /><div id='sending_form'><img src='imgs/ajax-loader.gif'> <br /><br /> Enviando Formul&aacute;rio, Aguarde...</div><br /><br /><br /><br />";
}

function returnForm(response) {
   $('msgForm').innerHTML = response.responseText;
}

function historyBackFormVendas(){
   document.getElementById('msgForm').style.display = "none"; 
   document.getElementById('FormVendas').style.display = "block";   
}

function sendFormSolicitacaoTreinamento() {
   var params = Form.serialize('FormSolicitacaoTreinamento');   
   var url = 'controller.php?action=FormSolicitacaoTreinamento';
   
   document.getElementById('FormSolicitacaoTreinamento').style.display = "none"; 
   document.getElementById('msgFormSolicitacaoTreinamento').style.display = "block"; 
   
   var objAjaxLivros = new Ajax.Request( url,{ method: 'post', parameters: params, onComplete: returnFormSolicitacaoTreinamento});
   $('msgFormSolicitacaoTreinamento').innerHTML = "<div id='sending_form'><img src='imgs/ajax-loader.gif'> <br> Enviando Formul&aacute;rio, Aguarde...</div><br /><br /><br /><br />";
}

function returnFormSolicitacaoTreinamento(response) {
   $('msgFormSolicitacaoTreinamento').innerHTML = response.responseText;
}

function historyBackFormSolicitacaoTreinamento(){
   document.getElementById('msgFormSolicitacaoTreinamento').style.display = "none"; 
   document.getElementById('FormSolicitacaoTreinamento').style.display = "block";   
}

function sendFormCorretorFaleConosco() {
   var params = Form.serialize('FormCorretorFaleConosco');   
   var url = 'controller.php?action=FormCorretorFaleConosco';
   
   document.getElementById('FormCorretorFaleConosco').style.display = "none"; 
   document.getElementById('msgFormCorretorFaleConosco').style.display = "block"; 
   
   var objAjaxLivros = new Ajax.Request( url,{ method: 'post', parameters: params, onComplete: returnFormCorretorFaleConosco});
   $('msgFormCorretorFaleConosco').innerHTML = "<div id='sending_form'><img src='imgs/ajax-loader.gif'> <br> Enviando Formul&aacute;rio, Aguarde...</div><br /><br /><br /><br />";
}

function returnFormCorretorFaleConosco(response) {
   $('msgFormCorretorFaleConosco').innerHTML = response.responseText;
}

function historyBackFormCorretorFaleConosco(){
   document.getElementById('msgFormCorretorFaleConosco').style.display = "none"; 
   document.getElementById('FormCorretorFaleConosco').style.display = "block";   
}


function carteiras() {
   window.open("carteiras.php", "Carteiras", "menubar=0,toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0,width=800,height=160,top=180,left=0");			
}

// CHANGE CONTENTs
// A SANTAMALIA
function changeContentASantamalia(button,content,style){
   // BUTTON
   document.getElementById('btnASantamalia_01').style.display = "block";
   document.getElementById('btnASantamalia_02').style.display = "block";
   document.getElementById('btnASantamalia_03').style.display = "block";
   document.getElementById('btnASantamalia_04').style.display = "block";
   if (button == "btnASantamalia_04") {
	   document.getElementById('btnASantamalia_03_b').style.display = "block";
	   document.getElementById('btnASantamalia_03').style.display = "none";
   }
   else {
	   document.getElementById('btnASantamalia_03').style.display = "block";
	   document.getElementById('btnASantamalia_03_b').style.display = "none";
   }
   if (button == "btnASantamalia_03_b") {
	   document.getElementById('btnASantamalia_03').style.display = "none";
	   document.getElementById('btnASantamalia_03_b').style.display = "none";
   }
   document.getElementById(button).style.display = "none";
   // CONTENT
   document.getElementById('contentHistorico').style.display = "none";
   document.getElementById('contentPalavraPresidente').style.display = "none";
   document.getElementById('contentMissao').style.display = "none";
   document.getElementById('contentPrincipios').style.display = "none";
   document.getElementById(content).style.display = "block"; 
   // STYLE 
   document.getElementById('contentBoxASantamalia').className = style;
   
}
// NOSSA REDE
function changeContentNossaRede(button,content,style){
   // BUTTON
   document.getElementById('btnNossaRede_01').style.display = "block";
   document.getElementById('btnNossaRede_02').style.display = "block";
   document.getElementById(button).style.display = "none";
   // CONTENT
   document.getElementById('contentNossaRede').style.display = "none";
   document.getElementById('contentNossaEstrutura').style.display = "none";
   document.getElementById('contentUnidades').style.display = "none";
   document.getElementById(content).style.display = "block"; 
   // STYLE 
   document.getElementById('contentBoxNossaRede').className = style;
   
}

// PRODUTOS
function changeContentProdutos(content,style){
   // BUTTONs
   document.getElementById('btnProdutos_01').style.display = (content=="contentProdutos")?"none":"block";
   document.getElementById('btnProdutos_02').style.display = (content=="contentProdutos")?"block":"none";
   document.getElementById('btnProdutos_03').style.display = (content=="contentProdutos")?"block":"none";
   document.getElementById('btnProdutos_04').style.display = (content=="contentProdutos")?"block":"none";
   document.getElementById('btnProdutos_05').style.display = (content=="contentProdutos")?"block":"none";
   document.getElementById('btnProdutos_06').style.display = (content=="contentProdutos")?"block":"none";
   // CONTENTs
   document.getElementById('contentProdutos').style.display = "none";
   document.getElementById('contentPessoaFisica').style.display = "none";
   document.getElementById('contentPME').style.display = "none";
   document.getElementById('contentEmpresarial').style.display = "none";
   document.getElementById('contentColetivoAdesao').style.display = "none";
   document.getElementById('contentSantamaliaOdonto').style.display = "none";
   document.getElementById(content).style.display = "block"; 
   // RIGHT BOX 
   document.getElementById('rightBoxProdutos').className = (content=="contentProdutos")?"rightBoxProdutos":"rightBoxProdutos_";
   // STYLE 
   document.getElementById('contentBoxProdutos').className = style;	
   
   if (content!="contentPessoaFisica") this.changeContentPF('box_pf_rede_atendimento','btn_pf_rede_atendimento');
   if (content!="contentPME") this.changeContentPME('box_pme_rede_atendimento','btn_pme_rede_atendimento');
   if (content!="contentPJ") this.changeContentPJ('box_pj_rede_atendimento','btn_pj_rede_atendimento'); 
}

// PRODUTOS - ABAS
function changeContentPF(content,button){
   // BUTTONs
   document.getElementById('btn_pf_rede_atendimento').className = "headerTableMenu_off";
   document.getElementById('btn_pf_carencia').className = "headerTableMenu_off";
   document.getElementById('btn_pf_santamalia_odonto').className = "headerTableMenu_off";
   document.getElementById('btn_pf_vantagens').className = "headerTableMenu_off";
   document.getElementById('btn_pf_perguntas_frequentes').className = "headerTableMenu_off";
   document.getElementById(button).className = "headerTableMenu_on";
   // CONTENTs
   document.getElementById('box_pf_rede_atendimento').style.display = "none";
   document.getElementById('box_pf_carencia').style.display = "none";
   document.getElementById('box_pf_santamalia_odonto').style.display = "none";
   document.getElementById('box_pf_vantagens').style.display = "none";
   document.getElementById('box_pf_perguntas_frequentes').style.display = "none";
   document.getElementById(content).style.display = "block";
}
function changeContentPME(content,button){
   // BUTTONs
   document.getElementById('btn_pme_rede_atendimento').className = "headerTableMenu_off";
   document.getElementById('btn_pme_carencia').className = "headerTableMenu_off";
   document.getElementById('btn_pme_santamalia_odonto').className = "headerTableMenu_off";
   document.getElementById('btn_pme_vantagens').className = "headerTableMenu_off";
   document.getElementById('btn_pme_perguntas_frequentes').className = "headerTableMenu_off";
   document.getElementById(button).className = "headerTableMenu_on";
   // CONTENTs
   document.getElementById('box_pme_rede_atendimento').style.display = "none";
   document.getElementById('box_pme_carencia').style.display = "none";
   document.getElementById('box_pme_santamalia_odonto').style.display = "none";
   document.getElementById('box_pme_vantagens').style.display = "none";
   document.getElementById('box_pme_perguntas_frequentes').style.display = "none";
   document.getElementById(content).style.display = "block";
}
function changeContentPJ(content,button){
   // BUTTONs
   document.getElementById('btn_pj_rede_atendimento').className = "headerTableMenu_off";
   document.getElementById('btn_pj_santamalia_odonto').className = "headerTableMenu_off";
   document.getElementById('btn_pj_vantagens').className = "headerTableMenu_off";
   document.getElementById('btn_pj_perguntas_frequentes').className = "headerTableMenu_off";
   document.getElementById(button).className = "headerTableMenu_on";
   // CONTENTs
   document.getElementById('box_pj_rede_atendimento').style.display = "none";
   document.getElementById('box_pj_santamalia_odonto').style.display = "none";
   document.getElementById('box_pj_vantagens').style.display = "none";
   document.getElementById('box_pj_perguntas_frequentes').style.display = "none";
   document.getElementById(content).style.display = "block";
}
// PORTAL
function changeContentPortal(button,content,style){
	// VERIFICA BOX
	if (content=='contentPortalAssociado'){
		document.getElementById('boxContentPortalAssociado').innerHTML = "";
		getContentPagePortalAssociado();
	}
	if (content=='contentPortalCredenciado'){
		document.getElementById('boxContentPortalCredenciado').innerHTML = "";
		getContentPagePortalCredenciado();
	}
	
   // BUTTON
   document.getElementById('btnPortal_01').style.display = "block";
   document.getElementById('btnPortal_02').style.display = "block";
   document.getElementById('btnPortal_03').style.display = "block";
   document.getElementById('btnPortal_04').style.display = "block";
   document.getElementById('btnPortal_05').style.display = "block";
	   document.getElementById('btnPortal_04_b').style.display = "none";
   if (button == "btnPortal_04_b") {
	   document.getElementById('btnPortal_04').style.display = "none";
	   document.getElementById('btnPortal_04_b').style.display = "none";
   }
   if (button == "btnPortal_05") {
	   document.getElementById('btnPortal_04').style.display = "none";
	   document.getElementById('btnPortal_04_b').style.display = "block";
   }
   document.getElementById(button).style.display = "none";
   // CONTENT
   document.getElementById('contentPortal').style.display = "none";
   document.getElementById('contentPortalAssociado').style.display = "none";
   document.getElementById('contentPortalCredenciado').style.display = "none";
   document.getElementById('contentPortalCorretor').style.display = "none";
   document.getElementById('contentPortalTISS').style.display = "none";
   document.getElementById(content).style.display = "block"; 
   // STYLE 
   document.getElementById('contentBoxPortal').className = style;
   
}

// OUTROS
function changeContentOutros(button,content,style){
   // BUTTON
   document.getElementById('btnOutros_01').style.display = "block";
   document.getElementById('btnOutros_02').style.display = "block";
   document.getElementById('btnOutros_03').style.display = "block";
   if (button == "btnOutros_03") {
	   document.getElementById('btnOutros_02_b').style.display = "block";
	   document.getElementById('btnOutros_02').style.display = "none";
   }
   else {
	   document.getElementById('btnOutros_02').style.display = "block";
	   document.getElementById('btnOutros_02_b').style.display = "none";
   }
   document.getElementById(button).style.display = "none";
   // CONTENT
   document.getElementById('contentLaboratorio').style.display = "none";
   document.getElementById('contentExames').style.display = "none";
   document.getElementById('contentFaq').style.display = "none";
   document.getElementById(content).style.display = "block"; 
   // STYLE 
   document.getElementById('contentBoxOutros').className = style;
   
}

// SERVICOS
function changeContentServicos(button,content,style){
   // BUTTON
   document.getElementById('btnServicos_01').style.display = "block";
   document.getElementById('btnServicos_02').style.display = "block";
   document.getElementById('btnServicos_03').style.display = "block";
   document.getElementById('btnServicos_04').style.display = "block";
   if (button == "btnServicos_03_b") {
	   document.getElementById('btnServicos_03').style.display = "none";
	   document.getElementById('btnServicos_03_b').style.display = "block";
   } else {
	   document.getElementById('btnServicos_03').style.display = "block";
	   document.getElementById('btnServicos_03_b').style.display = "none";
   }
   document.getElementById(button).style.display = "none";
   // CONTENT
   document.getElementById('contentServicos').style.display = "none";
   document.getElementById('contentFaleConosco').style.display = "none";
   document.getElementById('contentMedicinaPreventiva').style.display = "none";
   document.getElementById('contentTransporteGratuito').style.display = "none";
   document.getElementById(content).style.display = "block"; 
   // STYLE 
   document.getElementById('contentBoxServicos').className = style;
   
   // CLEAN FORM
   document.getElementById('msgForm').style.display = "none";
   document.getElementById('FormFaleConosco').style.display = "block";
   Form.reset('FormFaleConosco');
   
}

// SERVICOS
function changeContentVantagens(button,content,style){
   // BUTTON
   document.getElementById('btnVantagens_01').style.display = "block";
   document.getElementById(button).style.display = "none";   
   if (button != "btnVantagens_01") {
	   document.getElementById(button).style.display = "block";   
   }
   // CONTENT
   document.getElementById('contentVantagens').style.display = "none";
   document.getElementById('contentMedicinaPreventiva').style.display = "none";
   document.getElementById('contentTransporteGratuito').style.display = "none";
   document.getElementById('contentLaboratorio').style.display = "none";
   document.getElementById(content).style.display = "block"; 
   // STYLE 
   document.getElementById('contentBoxVantagens').className = style;   
}

// NOTICIAS
function changeContentNoticias(button,content,style){
   // BUTTON
   document.getElementById('btnNoticias_01').style.display = "block";
   document.getElementById('btnNoticias_02').style.display = "block";
   document.getElementById(button).style.display = "none";
   // CONTENT
   document.getElementById('contentNoticias').style.display = "none";
   document.getElementById('contentNoticiasDestaque').style.display = "none";
   document.getElementById(content).style.display = "block"; 
   // STYLE 
   document.getElementById('contentBoxNoticias').className = style;   
}

function getContentPagePortalAssociado() {  
   var params = ""; 
   var url = 'controller.php?action=getContentPagePortalAssociado';   
   var objAjax = new Ajax.Request( url,{ method: 'post', parameters: params, onComplete: setContentPagePortalAssociado});
}

function setContentPagePortalAssociado(response) {
   $('boxContentPortalAssociado').innerHTML = response.responseText;
}

function getContentPagePortalCredenciado() {   
   var params = ""; 
   var url = 'controller.php?action=getContentPagePortalCredenciado';   
   var objAjax = new Ajax.Request( url,{ method: 'post', parameters: params, onComplete: setContentPagePortalCredenciado});
}

function setContentPagePortalCredenciado(response) {
   $('boxContentPortalCredenciado').innerHTML = response.responseText;
}

// FAQ 
function ShowHideDivResponse(div){
   var divTarget = document.getElementById(div); 	  
   var divElements = document.getElementsByTagName("div");
   for (i=0;i<divElements.length;i++) {
      if ((divElements[i].className=='faq_response')&&(divTarget.style.display == 'none')){
           divElements[i].style.display = 'none';  
      }
   }	  
	  
   if(divTarget.style.display == 'none'){ divTarget.style.display = 'block'}   
   else                                 { divTarget.style.display = 'none' }
}

function showHideNumeroFuncionarios(state){
   document.getElementById('divNumeroFuncionarios_1').style.display = state;
   document.getElementById('divNumeroFuncionarios_2').style.display = state;
   document.getElementById('numero_funcionarios').value = "";
}

function portalCorretorShowPhoto(id_photo_gallery,foto){
   var url = 'controller.php?action=PortalCorretorPhotoGalleryCallPhoto&id_photo_gallery='+id_photo_gallery+'&foto='+foto;	
   var parametro = 'id_photo_gallery='+id_photo_gallery+'&foto='+foto;	
   var objAjaxLivros = new Ajax.Request( url,{ method: 'post', parameters: parametro, onComplete: portalCorretorShowPhotoReturn });
}

function portalCorretorShowPhotoReturn(resposta){
   var stage = window.parent.document.getElementById('photoStage');
   stage.innerHTML = resposta.responseText;
   showOverlay();
}

function portalCorretorClosePhoto(){
   var bgPhotoStage = window.parent.document.getElementById('bgPhotoStage');
   var photoStage = window.parent.document.getElementById('photoStage');	
   bgPhotoStage.style.display = "none";
   photoStage.innerHTML = "";
   photoStage.style.display = "none";
}

function showOverlay() {
   var sizesPage = getPageSize();	 
   var offsetTop = (window.parent.document.documentElement.scrollTop != 0)?window.parent.document.documentElement.scrollTop:window.parent.document.body.scrollTop;
   var centerPage = ((arrayPageSize[0]-710)/2);
   var bgPhotoStage = window.parent.document.getElementById('bgPhotoStage');
   var photoStage = window.parent.document.getElementById('photoStage');
	  
   bgPhotoStage.style.height = (arrayPageSize[1]+30) + 'px'; // fundo com o tamanho total da página.
   bgPhotoStage.style.display = "block";
   photoStage.style.marginTop = offsetTop + 'px';
   photoStage.style.marginLeft = centerPage + 'px';
   photoStage.style.display = "block";
}

function getPageSize(){
// getPageSize()
// Returns array with page width, height and window width, height
   var xScroll, yScroll;
   var windowWidth, windowHeight;
   
   if (window.parent.innerHeight && window.parent.scrollMaxY) {	
      xScroll = document.body.scrollWidth;
      yScroll = window.parent.innerHeight + window.parent.scrollMaxY;
   } else if (window.parent.document.body.scrollHeight > window.parent.document.body.offsetHeight){ // all but Explorer Mac
      xScroll = window.parent.document.body.scrollWidth;
      yScroll = window.parent.document.body.scrollHeight;
   } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
      xScroll = window.parent.document.body.offsetWidth;
      yScroll = window.parent.document.body.offsetHeight;
   }
   if (self.innerHeight) {	// all except Explorer
      windowWidth = self.innerWidth;
      windowHeight = self.innerHeight;
   } else if (window.parent.document.documentElement && window.parent.document.documentElement.clientHeight) { // Explorer 6 Strict Mode
      windowWidth = window.parent.document.documentElement.clientWidth;
      windowHeight = window.parent.document.documentElement.clientHeight;
   } else if (window.parent.document.body) { // other Explorers
      windowWidth = window.parent.document.body.clientWidth;
      windowHeight = window.parent.document.body.clientHeight;
   }	
   // for small pages with total height less then height of the viewport
   if(yScroll < windowHeight) pageHeight = windowHeight;
   else                       pageHeight = yScroll;

   // for small pages with total width less then width of the viewport
   if(xScroll < windowWidth) pageWidth = windowWidth;
   else                      pageWidth = xScroll;
   
   arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
}

function showHideComoConheceu(value){
	$('comoSoube').style.display = (value == "vendas")?'block':'none';
	$('comoSoube_2').style.display = (value == "vendas")?'block':'none';
}
