function fechar(){
	document.getElementById('ddestaqueinicial').style.display='none';
	document.getElementById('fade').style.display='none'
	document.getElementById('ddestaqueinicial').innerHTML="";
}
function ajaxInit(){
var xmlhttp ;

	try {
 		xmlhttp = new XMLHttpRequest ( ) ;
 	}catch (ee){
		try { 
		xmlhttp = new ActiveXObject ("Msxml2.XMLHTTP") ;
 		}catch( e ) {
 			try {
 				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP" ) ;
 			}catch(E) {
 				xmlhttp= false ;
 			}
 		}
 	}

 return xmlhttp ;
 }

function saibaMais(id,cro){
	ajax=ajaxInit();
	
	document.getElementById("div_saiba_mais").innerHTML="<img src=\"http://www.stdweb.com.br/stdweb/imagensAcheSeuDentista/carregando.gif\" \>";
	if(ajax){
		ajax.open('GET','http://www.acheseudentista.com.br/dentista/?ac=carregar_saiba_mais&id='+id+'&cro='+cro+'&aba=1',true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("div_saiba_mais").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}

function saibaMais2(id,cro){
	ajax=ajaxInit();
	document.getElementById("div_saiba_mais").innerHTML="<img src=\"http://www.stdweb.com.br/stdweb/imagensAcheSeuDentista/carregando.gif\" \>";
	if(ajax){
		ajax.open('GET','http://www.acheseudentista.com.br/dentista/?ac=carregar_saiba_mais&id='+id+'&cro='+cro+'&aba=1',true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("div_saiba_mais").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}

function convenios(id,cro){
	ajax=ajaxInit();
	//document.getElementById("div_saiba_mais").innerHTML="<img src=\"../stdweb/imagensStdWeb/carregando.gif\" \>";
	if(ajax){
		ajax.open('GET','http://www.acheseudentista.com.br/dentista/?ac=carregar_convenios&id='+id+'&cro='+cro+'&aba=2',true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("div_saiba_mais").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}

function formacao(id,cro){
	ajax=ajaxInit();
	//document.getElementById("div_saiba_mais").innerHTML="<img src=\"../stdweb/imagensStdWeb/carregando.gif\" \>";
	if(ajax){
		ajax.open('GET','http://www.acheseudentista.com.br/dentista/?ac=carregar_formacao&id='+id+'&cro='+cro+'&aba=3',true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("div_saiba_mais").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}

function outrosDados(id,cro){
	ajax=ajaxInit();
	//document.getElementById("div_saiba_mais").innerHTML="<img src=\"../stdweb/imagensStdWeb/carregando.gif\" \>";
	if(ajax){
		ajax.open('GET','http://www.acheseudentista.com.br/dentista/?ac=carregar_outros_dados&id='+id+'&cro='+cro+'&aba=4',true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("div_saiba_mais").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}


function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = 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) 
}

var timer;

function bodyOverlay(id,cro,idAba) {

	  if(idAba==null||idAba==1||idAba==''){
		saibaMais(id,cro);
	  }
	  else if(idAba!=null&&idAba==2){
		convenios(id,cro);
	  }
	  else if(idAba!=null&&idAba==3){
		formacao(id,cro);
	  }
	  else if(idAba!=null&&idAba==4){
		outrosDados(id,cro);
	  }
	  else if(idAba!=null&&idAba==5){
		saibaMais2(id,cro);
	  }
	  
	  var objBody = document.getElementsByTagName('body').item(0);
	  var sizesPage = getPageSize();
	  var bodyOverlay = document.createElement("div");
	  bodyOverlay.setAttribute('id','bodyOverlay');
	  bodyOverlay.style.height = arrayPageSize[1] + 'px'; // fundo com o tamanho total da página.
	  if (!document.getElementById('bodyOverlay')) {
		    objBody.insertBefore(bodyOverlay, objBody.firstChild);
	  }
	  window.parent.document.getElementById('div_saiba_mais').style.visibility="visible";
	 
	  
	  /**
	   * Acrescentei isto aqui apenas para chamar a função removerOverlay
	   */
	//timer = window.setInterval('removerOverlay()',1000);
}


function removerOverlay() {
	/**
	 * Acrescentei este alerta apenas para avisar que esta função foi chamada
	 */
	 //alert('Estou chamando a função removerOverlay() para removermos este overlay sobre o body.');
	 //clearInterval(timer);
	 
	  var bodyOverlay = document.getElementById('bodyOverlay');
	  if (bodyOverlay) {
		    bodyOverlay.parentNode.removeChild(bodyOverlay);
	  }
  window.parent.document.getElementById('div_saiba_mais').style.visibility="hidden";
}

function xGetElementById(e) {
  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else e=null;
  return e;
}

function xDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

function xShow(objeto) {
  if(!(objeto=xGetElementById(objeto))) return;
  if(objeto.style && xDef(objeto.style.visibility)){ 
  var x;
  var y;
	if (navigator.appName == 'Netscape'){
		objeto.style.top='px';
		objeto.style.left='380px';
	}
	else{
		x = event.clientX+document.body.scrollLeft; 
		y = event.clientY+document.body.scrollTop;
 		objeto.style.top= y + -120 +"px";
 		objeto.style.left= x + 5 +"px";
	}
  objeto.style.visibility='visible';
  }
}
function xHide(e) {
  if(!(e=xGetElementById(e))) return;
  	e.style.top='10px';
	e.style.left='10px';
  if(e.style && xDef(e.style.visibility)) e.style.visibility='hidden';
}
function contaVoto(id){
	document.form.action='crodf?ac=contaVoto&idopcao='+id;
	document.form.submit();
}
function CaixaBaixa(fsValor, foForm, foNome) { 
	if (window.event.keyCode >= 65 && window.event.keyCode <= 90){
		x = new String(document.forms[foForm].elements[foNome].value);
		document.forms[foForm].elements[foNome].value = x.toLowerCase();
	}
} 

function xGetElementById(e) {
  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else e=null;
  return e;
}

function xDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

function xShow(objeto) {
  if(!(objeto=xGetElementById(objeto))) return;
  if(objeto.style && xDef(objeto.style.visibility)){ 
  var x;
  var y;
	if (navigator.appName == 'Netscape'){
		//objeto.style.top='px';
		//objeto.style.left='380px';
	}
	else{
		x = event.clientX+document.body.scrollLeft; 
		y = event.clientY+document.body.scrollTop;
 		objeto.style.top= y + -120 +"px";
 		objeto.style.left= x + 5 +"px";
 		objeto.style.visibility='visible';
	}
  
  }
}

function xHide(e) {
  if(!(e=xGetElementById(e))) return;
  	e.style.top='10px';
	e.style.left='10px';
  if(e.style && xDef(e.style.visibility)) e.style.visibility='hidden';
}


function validaEmail(Email){
	var filter = /^(([a-zA-Z0-9_-])+(([\.\])+([a-zA-Z0-9_-]{0,1})))+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 
	var arrayEmail = Email.split(";"); //Separa os email 
	for (var i=0;i < arrayEmail.length; i++){ //varre a lista de emails 
		if ( !filter.test(arrayEmail[i]) ){ 
			return false; //se tiver erro sai com false 
		}
		else{ 
			return true; // se nao achou erro retorrna verdadeiro 
		}
	}
}
function enviarEmail(){
	if(document.formContato.txtNome.value==''){
		alert('Informe um nome!');
		document.formContato.txtNome.focus();
	}
	else if(document.formContato.txtEmail.value==''){
		alert('Informe um e-mail!');
		document.formContato.txtEmail.focus();
	}
	else if(validaEmail(document.formContato.txtEmail.value)==false){
		alert('E-mail inválido');
		document.formContato.txtEmail.value = '';
	}
	else if(document.formContato.txtAssunto.value==''){
		alert('Informe um assunto!');
		document.formContato.txtAssunto.focus();
	}
	else if(document.formContato.txtMsg.value==''){
		alert('Digite uma mensagem!');
		document.formContato.txtMsg.focus();
	}
	else{
		document.formContato.action='?ac=contato';
		document.formContato.submit();
	}
} 
function busca(){
	if(document.formFiliados.txtNome.value==''
	   && document.formFiliados.txtCodigo.value==''
	   && document.formFiliados.cboCategorias.value==0
	   && document.formFiliados.cboEspecialidades.value==0
	    && document.formFiliados.cboLocalidade.value==0
	   && document.formFiliados.cboBairro.value==0)
	   {
		alert('Informe pelo menos 1 critério de busca!');
	}
	else{
		if(document.formFiliados.cboLocalidade.value!=0 && document.formFiliados.cboBairro.value==0){
				alert('Informe o bairro desejado!');
				document.formFiliados.cboBairro.focus();
		}
		else{
			document.formFiliados.action='?ac=busca';
			document.formFiliados.submit();
		}
	}
} 

function atualizarEspecialidade(valor){
	var frame=document.getElementById("iFrameFiliado");
	frame.src='?ac=carregar_especialidade&idcategoria='+valor;
}

function atualizarLocalidade(valor){
	var frame=document.getElementById("iFrameFiliado");
	frame.src='?ac=carregar_localidade&idlocalidade='+valor;
}

function atualizarSubLink(valor){
	var frame=document.getElementById("iFrameSubLink");
	frame.src='?ac=carregar_sub_link&idlink='+valor;
}

function atualizarPesquisaLink(valor){
	var frame=document.getElementById("iFrameSubLink");
	frame.src='?ac=carregar_busca_link&idlink='+valor;
}

function atualizarbairro(valor){
	var frame=document.getElementById("iFrameFiliado");
	frame.src='?ac=carregar_bairro&idlocalidade='+valor;
}
function enviarNews(){
	if(document.form.txtEmail.value==''){
		alert('Informe um e-mail!');
		document.form.txtEmail.focus();
	}
	else if(validaEmail(document.form.txtEmail.value)==false){
		alert('E-mail inválido');
		document.form.txtEmail.value = '';
	}
	else{
		document.form.action='?ac=news';
		document.form.submit();
	}
} 
function eveAno(mes){
	location.href='?ac=eventoPortal&mes='+mes+'&ano='+document.formEve.ano.value;
}
function demoAno(mes){
	location.href='?ac=demoFinanceiro&mes='+mes+'&ano='+document.formEve.ano.value;
}
function enviarInscricao(){
	if(document.formInscricao.txtNome.value==''){
		alert('Informe seu nome!');
		document.formInscricao.txtNome.focus();
	}
	else if(document.formInscricao.txtEmail.value==''){
		alert('Informe seu e-mail!');
		document.formInscricao.txtEmail.focus();
	}
	else if(validaEmail(document.formInscricao.txtEmail.value)==false){
		alert('E-mail inválido');
		document.formInscricao.txtEmail.value = '';
	}
	else if(document.formInscricao.txtEndereco.value==''){
		alert('Informe seu endereço!');
		document.formInscricao.txtEndereco.focus();
	}
	else if(document.formInscricao.txtTelefone.value==''){
		alert('Digite seu telefone!');
		document.formInscricao.txtTelefone.focus();
	}
	else if(document.formInscricao.txtProfissao.value==''){
		alert('Digite sua profissão!');
		document.formInscricao.txtProfissao.focus();
	}
	else{
		document.formInscricao.action='?ac=inscricao';
		document.formInscricao.submit();
	}
}
function enviarInscricao2(){
	if(document.formInscricao.txtNome.value==''){
		alert('Informe seu nome!');
		document.formInscricao.txtNome.focus();
	}
	else if(document.formInscricao.txtCRO.value==''){
		alert('Informe seu CRO!');
		document.formInscricao.txtCRO.focus();
	}
	else if(document.formInscricao.txtEndereco.value==''){
		alert('Informe seu endereço!');
		document.formInscricao.txtEndereco.focus();
	}
	else if(document.formInscricao.txtEspecialidade.value==''){
		alert('Digite sua especialidade!');
		document.formInscricao.txtEspecialidade.focus();
	}
	else if(document.formInscricao.txtTelefone.value==''){
		alert('Digite seu telefone!');
		document.formInscricao.txtTelefone.focus();
	}
	else{
		document.formInscricao.action='?ac=inscricao2';
		document.formInscricao.submit();
	}
}
function aSub(id){
	document.getElementById("Sub"+id).style.display="block";
}
function fSub(id){
	document.getElementById("Sub"+id).style.display="none";
}