function MM_openBrWindow(theURL,winName,features){
	var myWin =  window.open(theURL,winName,features);
	myWin.focus();
}

function fnMascara(objeto, evt, mask){ 
	var LetrasU = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	var LetrasL = 'abcdefghijklmnopqrstuvwxyz';
	var Letras  = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';	
	var Numeros = '0123456789';
	var Fixos  = '().-:/ ';
	var Charset = " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_/`abcdefghijklmnopqrstuvwxyz{|}~";
	evt = (evt) ? evt : (window.event) ? window.event : "";
	var value = objeto.value;
	if(evt){
	 	var ntecla = (evt.which) ? evt.which : evt.keyCode;
	 	tecla = Charset.substr(ntecla - 32, 1);
	 	if (ntecla < 32) return true;
	 	var tamanho = value.length;
	 	if (tamanho >= mask.length) return false;
	 	var pos = mask.substr(tamanho,1);
	 	while(Fixos.indexOf(pos) != -1){
			value += pos;
			tamanho = value.length;
			if (tamanho >= mask.length) return false;
			pos = mask.substr(tamanho,1);
		}
	 	switch(pos){
			case '#' : if (Numeros.indexOf(tecla) == -1) return false; break;
			case 'A' : if (LetrasU.indexOf(tecla) == -1) return false; break;
			case 'a' : if (LetrasL.indexOf(tecla) == -1) return false; break;
			case 'Z' : if (Letras.indexOf(tecla) == -1) return false; break;
			case '*' : objeto.value = value; return true; break;
			default : return false; break;
		}
	}
	objeto.value = value;
	return true;
}
///////////////////// Contato BR
function validaform_contato(){
	if(document.getElementById('nome_contato').value.length<=1){
		alert("O campo Nome deve estar preenchido corretamente.");
		document.getElementById('nome_contato').focus();
		return false;
	}
	if(document.getElementById('email_contato').value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1){
		alert("O campo E-mail deve estar preenchido corretamente.");
		document.getElementById('email_contato').focus();
		return false;
	}
	if(document.getElementById('telefone').value.length<14){
		alert("O campo Telefone deve estar preenchido corretamente.");
		document.getElementById('telefone').focus();
		return false;
	}
	if(document.getElementById('cidade').value.length<=1){
		alert("O campo Cidade deve estar preenchido corretamente.");
		document.getElementById('cidade').focus();
		return false;
	}
	if(document.getElementById('estado').value.length<=1){
		alert("Por favor, selecione o Estado");
		document.getElementById('estado').focus();
		return false;
	}      
	if(document.getElementById('mensagem').value.length<=1){
		alert("O campo Mensagem deve estar preenchido corretamente.");
		document.getElementById('mensagem').focus();
		return false;
	}      
    document.getElementById( 'contato' ).submit () ;
}
//////////////////////////////////////////// Contato ESP
function validaform_contato2(){
	if(document.getElementById('nome_contato2').value.length<=1){
		alert("El campo Nombre debe ser completado correctamente.");
		document.getElementById('nome_contato').focus();
		return false;
	}
	if(document.getElementById('email_contato2').value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1){
		alert("El campo E-mail debe ser completado correctamente.");
		document.getElementById('email_contato2').focus();
		return false;
	}
	if(document.getElementById('telefone2').value.length<14){
		alert("El Teléfono de campo debe completarse correctamente.");
		document.getElementById('telefone2').focus();
		return false;
	}
	if(document.getElementById('cidade2').value.length<=1){
		alert("La Ciudad campo debe completarse correctamente.");
		document.getElementById('cidade2').focus();
		return false;
	}
	if(document.getElementById('estado2').value.length<=1){
		alert("Por favor seleccione el estado");
		document.getElementById('estado2').focus();
		return false;
	}      
	if(document.getElementById('mensagem2').value.length<=1){
		alert("El campo Mensaje debe ser completado correctamente.");
		document.getElementById('mensagem2').focus();
		return false;
	}      
    document.getElementById( 'contato2' ).submit () ;
}
//////////////////////Contato ENG
function validaform_contato(){
	if(document.getElementById('nome_contato3').value.length<=1){
		alert("The Name field must be completed properly.");
		document.getElementById('nome_contato3').focus();
		return false;
	}
	if(document.getElementById('email_contato3').value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1){
		alert("The field E-mail must be completed properly.");
		document.getElementById('email_contato3').focus();
		return false;
	}
	if(document.getElementById('telefone3').value.length<14){
		alert("The Phone field must be completed properly.");
		document.getElementById('telefone3').focus();
		return false;
	}
	if(document.getElementById('cidade3').value.length<=1){
		alert("The City field must be completed properly.");
		document.getElementById('cidade3').focus();
		return false;
	}
	if(document.getElementById('estado3').value.length<=1){
		alert("Please select the state");
		document.getElementById('estado3').focus();
		return false;
	}      
	if(document.getElementById('mensagem3').value.length<=1){
		alert("The field Message must be completed properly.");
		document.getElementById('mensagem3').focus();
		return false;
	}      
    document.getElementById( 'contato3' ).submit () ;
}
////////////////////////////////////////////////////////////////////

function validaform_news(){
    if((document.getElementById('nome').value.length <= 1)||(document.getElementById('nome').value == "Nome:" )){
        alert("Por favor, preencha corretamente o campo Nome..");
        document.getElementById('nome').focus();
        return false;
    }
    if(document.getElementById('email').value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1){
        alert("Por favor, preencha corretamente o campo E-mail");
        document.getElementById('email').focus();
        return false;
    }
    document.getElementById('form_newsletter').submit();
}

////////////////////////////////////////////////ESP

function validaform_news_esp(){
    if((document.getElementById('nome').value.length <= 1)||(document.getElementById('nome').value == "Nome:" )){
        alert("Por favor, rellene correctamente el campo Nombre..");
        document.getElementById('nome').focus();
        return false;
    }
    if(document.getElementById('email').value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1){
        alert("Por favor, rellene el campo correctamente E-mail");
        document.getElementById('email').focus();
        return false;
    }
    document.getElementById('form_newsletter').submit();
}


////////////////////////////////////////////// ENG
function validaform_news3(){
    if((document.getElementById('nome').value.length <= 1)||(document.getElementById('nome').value == "Nome:" )){
        alert("The Name field must be completed properly");
        document.getElementById('nome').focus();
        return false;
    }
    if(document.getElementById('email').value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1){
        alert("The field E-mail must be completed properly.");
        document.getElementById('email').focus();
        return false;
    }
    document.getElementById('form_newsletter').submit();
}
////////////////////////////////////////////////////////////////////////
function FormatMask(objForm, strField, sMask, evtKeyPress) {
	var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
	if(window.event){
		nTecla = evtKeyPress.keyCode;
	}
	else if(evtKeyPress.which){
		nTecla = evtKeyPress.which;
	}
	sValue = objForm[strField].value;
	sValue = sValue.toString().replace( "-", "" );
	sValue = sValue.toString().replace( "-", "" );
	sValue = sValue.toString().replace( ".", "" );
	sValue = sValue.toString().replace( ".", "" );
	sValue = sValue.toString().replace( "/", "" );
	sValue = sValue.toString().replace( "/", "" );
	sValue = sValue.toString().replace( "(", "" );
	sValue = sValue.toString().replace( "(", "" );
	sValue = sValue.toString().replace( ")", "" );
	sValue = sValue.toString().replace( ")", "" );
	sValue = sValue.toString().replace( " ", "" );
	sValue = sValue.toString().replace( " ", "" );
	fldLen = sValue.length;
	mskLen = sMask.length;
	i = 0;
	nCount = 0;
	sCod = "";
	mskLen = fldLen;
	if(nTecla != 8){
		if(sMask.charAt(i-1) == "9"){
			return((nTecla > 47) && (nTecla < 58));
		}
		else{
			while(i <= mskLen){
				bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
				bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))
				if(bolMask){
					sCod += sMask.charAt(i);
					mskLen++;
				}
				else{
					sCod += sValue.charAt(nCount);
					nCount++;
				}
				i++;
			}
			objForm[strField].value = sCod;
			return true;
		}
	}
	else{
		return true;
	}
}

function fnTarget(str_target){
	var ch_tag_A, vet_A, int_i;
	var str_titulo;
    ch_tag_A = document.getElementsByTagName('a');
    for(int_i=0; int_i<ch_tag_A.length; int_i++){
        vet_A = ch_tag_A[int_i];
        if(vet_A.getAttribute("href") && vet_A.getAttribute('rel')=='externo'){
			vet_A.target = str_target;
			str_titulo = ch_tag_A.title;
			ch_tag_A.title = str_titulo;
		}
    }
}

function onoff(id){ 
	esconder = (document.getElementById(id).style.display == 'block');
	divs = document.getElementsByTagName('div');
	for(d=0; d<divs.length; d++){
		_div = divs[d];
		if (_div.className == 'descricao'){
			id_link = 'titulo_'+(_div.id);
			_link = document.getElementById(id_link);
			if (_div.id != id){
				_div.style.display = 'none';
				if (_link) _link.style.color = 'black';
			}
			else{
				_div.style.display = esconder ? 'none' : 'block';
				if (_link) _link.style.color = esconder ? 'black' : '#124986';
			}
		}
	}
}

////////////////////////////////////////////////////////////////////////////////////

//valida formulário Agende sua Consulta
function validaform_agende_consulta(form)
{
	if(form.nome_paciente.value.length<=1)
	{
		alert("O campo Nome do Paciente deve estar preenchido corretamente.");
		form.nome_paciente.focus();
		return false;
	}
	
	if(form.nome_medico.value.length<=1)
	{
		alert("O campo Nome do Médico deve estar preenchido corretamente.");
		form.nome_medico.focus();
		return false;
	}
	
	if(document.getElementById('email_paciente').value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1){
        alert("Por favor, preencha corretamente o campo E-mail");
        document.getElementById('email_paciente').focus();
        return false;
    }
	
	
	if(form.endereco.value.length<=1)
	{
		alert("O campo Endereço deve estar preenchido corretamente.");
		form.endereco.focus();
		return false;
	}
	
	if(form.bairro.value.length<=1)
	{
		alert("O campo Bairro deve estar preenchido corretamente.");
		form.bairro.focus();
		return false;
	}
	
	if(form.cidade.value.length<=1)
	{
		alert("O campo Cidade deve estar preenchido corretamente.");
		form.cidade.focus();
		return false;
	}
	
	if(form.estado.value.length<=1)
	{
		alert("O campo Estado deve estar selecionado corretamente.");
		form.estado.focus();
		return false;
	}
	
	
	if(form.data_consulta.value.length<=1)
	{
		alert("O campo Data da 1ª Consulta deve estar preenchido corretamente.");
		form.data_consulta.focus();
		return false;
	}
	
	if(form.convenio.value.length<=1)
	{
		alert("O campo Convênio deve estar preenchido corretamente.");
		form.convenio.focus();
		return false;
	}
	
	if(form.matricula.value.length<=1)
	{
		alert("O campo Matrícula deve estar preenchido corretamente.");
		form.matricula.focus();
		return false;
	}
	
	if(form.validade.value.length<=1)
	{
		alert("O campo validade deve estar preenchido corretamente.");
		form.validade.focus();
		return false;
	}
	

}


/////////////////////////////////////////////////////////////////////////////

function fnFlash(str_url, int_largura, int_altura)
{
	document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="340" height="300" id="320x240" align="middle">');
	document.writeln('<PARAM NAME=allowFlashAutoInstall VALUE=true>');
	document.writeln('<param name=Flashvars value="url='+str_url+'>');
	document.writeln('<param name="allowScriptAccess" value="sameDomain" >');
	document.writeln('<param name="movie" value="video/player.swf" >');
	document.writeln('<param name="quality" value="high" >');
	document.writeln('<param name="bgcolor" value="#ffffff" >');
	document.writeln('<embed src="video/player.swf" swLiveConnect="true" Flashvars="'+str_url+'" quality="high" bgcolor="#ffffff" width="340" height="300" name="player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" >');
	document.writeln('</object>');
	
}

// Função de imagem no Popup
function fnImagemPopUp(titulo,largura,altura,imagem,alt){
	var janela;
	janela = window.open("","popFoto","width="+largura+",height="+altura+",scrollbars=no,toolbar=no,location=no,status=no,menubar=no,resizable=no,left=300,top=300'");
	janela.document.write('<html><head><title>'+titulo+'</title></head>');
	janela.document.write('<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
	janela.document.write('<a href="javascript:window.close();"><img src="'+imagem+'" alt="'+alt+'" border="0" ></a>');
	janela.document.write('</body></html>');
}
/////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
//funcao para o (mostrar e ocultar)
function oculta(id){
	esconder = (document.getElementById(id).style.display == 'block');
	/*if ( visivel == "" || visivel == "none" ) { document.getElementById(id).style.display = "block" }
	else{ document.getElementById(id).style.display = "none"; }*/
	divs = document.getElementsByTagName('DIV');
	for(d=0; d<divs.length; d++){
		_div = divs[d];
		if (_div.className == 'titulo'){
			id_link = 'titulo_'+(_div.id);
			_link = document.getElementById(id_link);
			if(_div.id != id){ _div.style.display = 'none'; }
			else{ _div.style.display = esconder ? 'none' : 'block'; }
		}
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//valida formulário Agende sua Consulta
function validaformcadastro(form)
{
	if(form.nome.value.length<=1)
	{
		alert("O campo Nome deve estar preenchido corretamente.");
		form.nome.focus();
		return false;
	}
	
	if(form.login.value.length<=1)
	{
		alert("O campo Login deve estar preenchido corretamente.");
		form.login.focus();
		return false;
	}
	
	if(form.senha.value.length<=1)
	{
		alert("O campo Senha deve estar preenchido corretamente.");
		form.senha.focus();
		return false;
	}
	
	if(form.crm.value.length<=1)
	{
		alert("O campo CRM deve estar preenchido corretamente.");
		form.crm.focus();
		return false;
	}
	
	if(form.especialidade.value.length<=1)
	{
		alert("O campo Especialidade deve estar preenchido corretamente.");
		form.especialidade.focus();
		return false;
	}
	
	var str_email = form.email.value ;
    if ( str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1 ) {
    	alert("O campo Seu E-mail deve ser preenchido corretamente.");
    	form.email.focus();
    	return false;
	}
	
	
	if(form.telefone.value.length<=1)
	{
		alert("O campo Telefone deve estar selecionado corretamente.");
		form.telefone.focus();
		return false;
	}
	
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////
//valida formulário Agende sua Consulta
function validaArea(form)
{
	if(form.login_area.value.length<=1)
	{
		alert("O campo Login deve estar preenchido corretamente.");
		form.login_area.focus();
		return false;
	}
	if(form.senha_area.value.length<=1)
	{
		alert("O campo Senha deve estar preenchido corretamente.");
		form.senha_area.focus();
		return false;
	}

}

function fnFlash(str_url, int_largura, int_altura)
{
	document.writeln('<object type="application/x-shockwave-flash" data="' + str_url + '" width="' + int_largura + '" height="' + int_altura + '">');
	document.writeln('<param name="movie" value="' + str_url + '">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<param name="wmode" value="transparent">');
	document.writeln('</object>');
}









