// Funcao para Submenu
function submenuOn(id) {
    document.getElementById(id).style.display = '' ;
}

function submenuOff(id) {
    document.getElementById(id).style.display = 'none' ;
}

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

// Validacao de Contato
function verificaContato(form) {
    
	/*if ( form.nome.value.length <= 1 ) {
	  alert("O campo Nome deve estar preenchido corretamente.");
	  form.nome.focus();
	  return false;
	}
	
	if ( form.empresa.value.length <= 1 ) {
	  alert("O campo Instituição de Pesquisa, Associação ou Empresa deve estar preenchido corretamente.");
	  form.empresa.focus();
	  return false;
	}*/
	
	var str_email = form.email.value ;
	if (( str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1 ) || ( str_email == 'Email:' ))
	{
		alert("O campo E-mail deve ser preenchido corretamente");
		form.email.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 preenchido corretamente.");
	  form.estado.focus();
	  return false;
	}
	
	if ( form.cep.value.length <=1 ) {
	  alert("O campo CEP deve estar preenchido corretamente.");
	  form.cep.focus();
	  return false;
	}
	
	if ( form.pais.value.length <=1 ) {
	  alert("O campo País deve estar preenchido corretamente.");
	  form.pais.focus();
	  return false;
	}
	
	
	if ( form.internet.checked == false ){
		alert("O campo Como tomou Conhecimento deve ser preenchido corretamente.");
		return false;
	}	
	
	if ( form.mensagem.value.length <=1 ) {
	  alert("O campo Mensagem deve estar preenchido corretamente.");
	  form.mensagem.focus();
	  return false;
	}*/
	
	if ( form.cod.value.length <=1 ) {
	  alert("Digite o Código de Segurança.");
	  form.cod.focus();
	  return false;
	}
}


// Validacao de Contato em ingles
function verificaContato_ingles(form) {
    
	/*if ( form.nome.value.length <= 1 ) {
	  alert("The field Your Name must be completed correctly.");
	  form.nome.focus();
	  return false;
	}
	
	if ( form.empresa.value.length <= 1 ) {
	  alert("The field Research Institution, or Enterprise Association must be completed correctly.");
	  form.empresa.focus();
	  return false;
	}*/
	
	var str_email = form.email.value ;
	if (( str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1 ) || ( str_email == 'Email:' ))
	{
		alert("The field E-mail must be completed correctly.");
		form.email.focus();
		return false;
	}
	
	
	/*if ( form.endereco.value.length <= 1 ) {
	  alert("The field Address must be completed correctly.");
	  form.endereco.focus();
	  return false;
	}
	
	if ( form.bairro.value.length <=1 ) {
	  alert("The field Neighborhood must be completed correctly.");
	  form.bairro.focus();
	  return false;
	}
	
	if ( form.cidade.value.length <=1 ) {
	  alert("The field City must be completed correctly.");
	  form.cidade.focus();
	  return false;
	}
	
	if ( form.estado.value.length <=1 ) {
	  alert("The field State must be completed correctly.");
	  form.estado.focus();
	  return false;
	}
	
	if ( form.cep.value.length <=1 ) {
	  alert("The field CEP must be completed correctly.");
	  form.cep.focus();
	  return false;
	}
	
	if ( form.pais.value.length <=1 ) {
	  alert("The field Country must be completed correctly.");
	  form.pais.focus();
	  return false;
	}*/
	
	/*if((document.getElementById('internet').checked == false)){
		alert("The field As noted the Farmabrasilis must be completed correctly.");
		return false;
	}	*/
	
	/*if ( form.internet.checked == false ){
		alert("The field As noted the Farmabrasilis must be completed correctly.");
		return false;
	}	
	
	if ( form.mensagem.value.length <=1 ) {
	  alert("The field Leave your message must be completed correctly.");
	  form.mensagem.focus();
	  return false;
	}*/
	
	if ( form.cod.value.length <=1 ) {
	  alert("Digite o Código de Segurança.");
	  form.cod.focus();
	  return false;
	}
}
////////////////////////////////////////////////////////////////////////////////////////

// Funcao de Mascara de Campos
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; }
}




///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Favoritos
function fnFavoritos() {
	title = document.title;
	url = "http://www.farmabrasilis.org.br";
	if(window.sidebar){ window.sidebar.addPanel(title,url,""); }
    else if(window.external){ window.external.AddFavorite(url,title); }
	else if(window.opera && window.print){ return true; }
}

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('<embed wmode="transparent" src="' + str_url + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + int_largura + '" height="' + int_altura + '"></embed></object>');
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Função abre janela Indique o site
function fnIndique(theURL,winName,features) // onclick="fnIndique('indique_amigo.php','indiqueAmigo','width=440,height=380,scrollbars=no');"
{
	var myWin =  window.open(theURL,winName,features);
	myWin.focus();
}


// Função valida form do Indique o site
function verificaIndiqueSite(form) {	
	if (form.nome.value=="") {
		alert("O campo Seu nome deve ser preenchido corretamente.");
		form.nome.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;
	}
	
	//var str_email = form.emailamigo.value ;
    //if ( str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1 ) {
    if (form.emailamigo.value=="") {
		alert("O campo E-mail do Destinatário deve ser preenchido corretamente.");
    	form.emailamigo.focus();
    	return false;
	} 
}


// Função valida form do Indique o site em ingles
function verificaIndiqueSite_ingles(form) {	
	if (form.nome.value=="") {
		alert("The field Your Name must be completed correctly.");
		form.nome.focus();
		return false;
	}
	
	var str_email = form.email.value ;
    if ( str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1 ) {
    	alert("The field E-mail must be completed correctly.");
    	form.email.focus();
    	return false;
	}
	
	//var str_email = form.emailamigo.value ;
    //if ( str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1 ) {
	if (form.emailamigo.value=="") {
    	alert("The field E-mail(s) of the recipient(s) must be completed correctly.");
    	form.emailamigo.focus();
    	return false;
	}
}

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

// Validacao de Contato
function verificaContate_nos(form) {
  if ( form.nome.value.length <= 1 ) {
	  alert("O campo Nome deve estar preenchido corretamente.");
	  form.nome.focus();
	  return false;
  }

	var str_email = form.email.value ;
    if (( str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1 ) || ( str_email == 'Email:' ))
	{
    	alert("O campo E-mail deve ser preenchido corretamente");
    	form.email.focus();
    	return false;
	}

  if ( form.telefone.value.length <= 13 ) {
	  alert("O campo Telefone deve estar preenchido corretamente.");
	  form.telefone.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 preenchido corretamente.");
	  form.estado.focus();
	  return false;
  }
	
  if ( form.internet.value.length <=1 ) {
	  alert("O campo PEqs deve estar preenchido corretamente.");
	  form.mensagem.focus();
	  return false;
  }
  if ( form.mensagem.value.length <=1 ) {
	  alert("O campo Mensagem deve estar preenchido corretamente.");
	  form.mensagem.focus();
	  return false;
  }
  
  
  if ( form.cod.value.length <=1 ) {
	  alert("Digite o Código de Segurança.");
	  form.cod.focus();
	  return false;
  }
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Função valida form do Indique o Amigo
function verificaIndiqueAmigo(form) {	
	if (form.nome.value=="") {
		alert("O campo Seu nome deve ser preenchido corretamente.");
		form.nome.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;
	}
	
	var str_email = form.emailamigo.value ;
    if ( str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1 ) {
    	alert("O campo E-mail do Destinatário deve ser preenchido corretamente.");
    	form.emailamigo.focus();
    	return false;
	}
}


// Função valida form do Indique o Amigo em ingles
function verificaIndiqueAmigo_ingles(form) {	
	if (form.nome.value=="") {
		alert("The field Your Name must be completed correctly.");
		form.nome.focus();
		return false;
	}
	
	var str_email = form.email.value ;
    if ( str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1 ) {
    	alert("The field E-mail must be completed correctly.");
    	form.email.focus();
    	return false;
	}
	
	var str_email = form.emailamigo.value ;
    if ( str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1 ) {
    	alert("The field E-mail(s) of the recipient(s) must be completed correctly.");
    	form.emailamigo.focus();
    	return false;
	}
}


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


