var ie=(((navigator.userAgent.indexOf("MSIE")>-1)||(navigator.userAgent.indexOf("Mozilla/5.0")>-1))&&navigator.userAgent.indexOf("Opera")==-1?true:false);
var ns=(navigator.userAgent.indexOf("Netscape")>-1&&navigator.userAgent.indexOf("Opera")==-1?true:false);

// Editado por Marcos


		function FormataCpf(onde,qual,que){
			if(onde.value.length == 3){
				onde.value += qual;

			}
			else if(onde.value.length == 7){
				onde.value += qual;
			}
			else if(onde.value.length == 11){
				onde.value += que;
			}
		}

		//Chamar a funcao  onKeyUp="FormataCpf(this,'.','-')"



	function FormataCnpj(onde,qual,que,qui){
			if(onde.value.length == 2){
				onde.value += qual;

			}
			else if(onde.value.length == 6){
				onde.value += qual;
			}
			else if(onde.value.length == 10){
				onde.value += que;
			}
			else if(onde.value.length == 15){
				onde.value += qui;
			}
		}

	//chamar a função onKeyUp="FormataCnpj(this,'.','/','-')"


function CPF(onde){
			var valid = "0123456789";
			var situa = true;
			for(i=0;i<onde.value.length;i++){
				if(valid.indexOf(onde.value.charAt(i))== -1){
				situa = false;
				}
			}
			if (!situa){
			alert("Digite somente números!");
			onde.focus();
			onde.select();
			}
		}

function ValidarNome(onde){
			var valid = "aáâbcçdeéêfghiíjklmnoóôpqrstuúvxywzaÁÂABCÇDEÉÊFGHIÍJKLMNOÓÔPQRSTUÚVXYWZ";
			var situa = true;
			for(i=0;i<onde.value.length;i++){
				if(valid.indexOf(onde.value.charAt(i))== -1){
				situa = false;
				}
			}
			if (!situa){
			alert("Prencha somente o seu nome sem espaços.\nPor favor, preencha seu sobrenome no campo Sobrenome.");
			onde.focus();
			onde.select();
			}
		}


function Cep(onde,qual){
	if(onde.value.length == 5){
		onde.value += qual;
	}
}
		
function ValidaBusca(){
		if(document.busca.strBusca.value==""){
			alert("Digite uma palavra para efetuar a busca!");
			document.busca.strBusca.focus();
		return false
		}
	}

function Numeros(onde){
			var valid = "0123456789-:/.";
			var situa = true;
			for(i=0;i<onde.value.length;i++){
				if(valid.indexOf(onde.value.charAt(i))== -1){
				situa = false;
				}
			}
			if (!situa){
			alert("Digite somente números!");
			onde.focus();
			onde.select();
			}
		}
function Fone(onde,qual){
			if(onde.value.length == 4){
				onde.value += qual;
			}
}

function PopClienteRM(){
	var objpop = window.open('../../downloads/destaques/cliente.asp','PopUP','top=200,left=200,width=368,height=500,scrollbars=yes,menubar=no,status=no,toolbar=no');
	objpop.focus();
}

function PopDarf2008RM(){
	var objpop = window.open('../../downloads/destaques/darf2008.asp','PopUP','top=200,left=200,width=368,height=500,scrollbars=yes,menubar=no,status=no,toolbar=no');
	objpop.focus();
}


function PopFormulario(msg){
	var objpop = window.open('http://www.rm.com.br/include_global/asp/pop_formulario.asp?txtMsg='+msg,'PopUP','top=200,left=200,width=350,height=150,menubar=no,scrollbars=no,status=no,toolbar=no');
	objpop.focus();
}

	function Busca(){
	if(document.frm_busca.strBusca.value==""){
		alert("Digite uma palavra para efetuar a Busca!");
		document.frm_busca.strBusca.focus();
	return false
	}
}


	function ValidaDataEvento(DiaI, MesI, AnoI, DiaF, MesF, AnoF){
	  var DataI = new Date(AnoI,MesI[MesI.selectedIndex].value-1,DiaI);	   
	  var DataF = new Date(AnoF,MesF-1,DiaF);	   
	 
	 if (DataI < DataF){
		alert('Por favor, escolha uma data superior a atual.')	
		return false;
	  }
	  else{
		return true;  
	}
}


function AbreIstoe(){
	window.open("http://www.rm.com.br/pt_br/popup/istoe_dinheiro/pop.htm","RM","width=399,height=510");
}

function AbreEstaMinas(){
	window.open("http://www.rm.com.br/pt_br/popup/estado_minas/index.htm","RM","width=425,height=500");
}
function AbreInforWeek(){
	window.open('http://www.rm.com.br/pt_br/popup/inforweek/index.html','popMauro','top=20,left=20,width=485,height=500,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no');void(0);
}
function AbreNovoUniforme(){
	window.open('http://www.rm.com.br/pt_br/popup/novo_uniforme/index.html','popUniforme','top=20,left=20,width=608,height=500,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no');void(0);
}
function AbreJanus(){
	window.open("http://www.rm.com.br/pt_br/popup/janus/pop_janus.htm","RM_Janus","width=606,height=500,scrollbars=yes");
}

function AbreSleven(){
	window.open("/pt_br/popup/materia_revista_quimica/index.htm","RM_Química","width=425,height=500");
}
function AbreVarginha(){
	window.open("/pt_br/popup/varginha/pop.html","RM_Varinha","top=10,left=30,width=550,height=500,scrollbars=yes");
}
function Abrecomputerworld(){
	window.open("/pt_br/popup/computerworld/pop.html","RM_Varinha","top=10,left=30,width=648,height=500,scrollbars=yes");
}
function AbreB2BMagazine(){
	window.open("/pt_br/popup/b2b_magazine/index.htm","b2b_magazine","top=10,left=30,width=720,height=500,scrollbars=yes");
}
function AbreExameTotvs(){
	window.open("http://www.rm.com.br/pt_br/popup/exame_totvs/pop1.html","RM","width=490,height=520");
}
function AbreCRN170506(){
	window.open("http://www.rm.com.br/pt_br/popup/crn_170506/index.html","CRN","width=490,height=520");
}
function AbreOTempo030606(){
	window.open("http://www.rm.com.br/pt_br/popup/otempo_030606/index.html","OTempo","width=490,height=520");
}
function AbreRMForte(){
	window.open("http://www.rm.com.br/pt_br/popup/rm_forte/index.html","RMForte","width=490,height=520");
}
function AbreConsumidorModerno(){
	window.open("http://www.rm.com.br/pt_br/popup/consumidor_moderno/index.html","Consumidor","width=490,height=520");
}

function AbreInfoCanal0606(){
	window.open("http://www.rm.com.br/pt_br/popup/info_canal_0606/index.html","InfoCanal","width=490,height=520");
}
function AbreInfoMaio06(){
	window.open("http://www.rm.com.br/pt_br/popup/info_maio_06/index.html","Info","width=720,height=405");
}
function AbreBauru110606(){
	window.open("http://www.rm.com.br/pt_br/popup/bauru_110606/index.html","InfoCanal","width=490,height=520");
}
function AbreTiInside0706(){
	window.open("http://www.rm.com.br/pt_br/popup/tiinside_0706/index.html","TIINSIDE","width=753,height=520");
}

function AbreInfo0706(){
	window.open("http://www.rm.com.br/pt_br/popup/info_0706/1.html","info","width=720,height=510");
}
function AbreClipping0706(){
	window.open("http://www.rm.com.br/pt_br/popup/clipping_0706/1.html","clip","width=720,height=510");
}


function AbreDiarioComercio120606(){
	window.open("http://www.rm.com.br/pt_br/popup/diario_comercio_120606/index.html","DiarioDoComercio","width=490,height=520");
}// EDICAO 05/04/2006


	function Abrecomputerworld02(){
		window.open("/pt_br/popup/computerworld_15.03.06/index.html","computer_world","top=10,left=30,width=780,height=580,scrollbars=yes");
	}
	function AbreTiInside(){
		window.open("/pt_br/popup/ti_inside/index.html","ti_inside","top=10,left=30,width=740,height=580,scrollbars=yes");
	}
	function AbreEstadoMinas2(){
		window.open("/pt_br/popup/estados_minas_02.04.06/index.htm","estado_minas","top=10,left=30,width=720,height=580,scrollbars=yes");
	}
	
	function AbreDemandaExigente(){
		window.open("/pt_br/popup/demanda_exigente/index.html","estado_minas","top=10,left=30,width=580,height=580,scrollbars=yes");
	}
	
// FIM

// Fim Editado por Marcos

function vaipara(){
	endereco = document.getElementById("mapadoportal").value;
	if(endereco!=""){
		document.location = endereco;
	}
}

function imprimir(LinkUrl){
	window.open(LinkUrl,'ImprimirRM','status=yes,scrollbars=yes,width=640,height=430');
}

function indique(pagina){
window.open("http://www.rm.com.br/pt_br/sisteminhas/indique/default.asp?pagina="+pagina,'IndiqueRM','status=yes,scrollbars=no,width=320,height=323');
}

function adiciona_favoritos(pagina){
var bookmarkurl=document.location;
var bookmarktitle="RM Sistemas";

//function addbookmark(){
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
//}

}


function abrirrm(param)
{
if (param == 1)
	{
	//document.all.sim.style.display='';
	//document.all.nao.style.display='none';
		document.getElementById("sim").style.display='';
		document.getElementById("nao").style.display='none';
		//var erro = 1;
		
	}
if (param == 2)
	{
	//document.all.sim.style.display='none';
	//document.all.nao.style.display='';
		document.getElementById("nao").style.display='';
		document.getElementById("sim").style.display='none';
		//var erro = 1;
		

	}
}
function AbrePopUp(URL,NOME,CONFIGS) {
  window.open(URL,NOME,CONFIGS);
}

var win = null;
function abrelinhacompacta(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
w = screen.width;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
h = screen.height;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
}

function abremicrosoft(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
w = screen.width;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
h = screen.height;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
}



<!--

// ------------------------------------------------------------------------------------------ //
// Funções para validação dos campos de um formulário
// ------------------------------------------------------------------------------------------ //

// Função para chamar um calendário
function Calendario(campo)
{
var data = showModalDialog("/portalcorporerm/princcalendario.asp", "", "status=no;dialogWidth=188px;dialogHeight=162px;Help=0");
if (data != null)
campo.value = data;
}
//

//Contador de caracteres para textarea
function VerificaContador(campo,maximo)
	{
	if (campo.value.length >= maximo)
		{
		alert('Este campo deve ter no máximo '+maximo+' caracteres.')
		return false
		}
	else 
		return true
	}
	
function AtualizaContador(campo,maximo)
	{			
	if (campo.value.length <= maximo)		
		document.all.Contador.value = maximo - campo.value.length							
	}	
//

// Formata Data
function FormataData(campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;

	if ( tecla != 9 && tecla != 8 ){
		if ( tam > 2 && tam < 5 )
			document.form[campo].value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam );
		if ( tam >= 5 && tam <= 10 )
			document.form[campo].value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 ); 
	}	
	
}
//

// Valida campo de Data
function ValidaData(field)
{
  //if (event.keyCode < 45 || event.keyCode > 57) 
	//  event.returnValue = false; 
	  
  var checkstr = "0123456789";
  var DateField = field;
  var Datevalue = "";
  var DateTemp = "";
  var seperator = "/";
  var day;
  var month;
  var year;
  var leap = 0;
  var err = 0;
  var i;
   err = 0;
   DateValue = DateField.value;   
   
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
		 DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;   
	if (DateValue.length <= 1)
		DateValue = "11"
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
	  DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
	  err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
	  err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
	  err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(0,2);
   if (day < 1) {
	 err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
	  leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
	  err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
	  err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
	  err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
	  err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
	  err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
	  DateField.value = day + seperator + month + seperator + year;
  	  return true	 
   }
   /* Error-message if err != 0 */
   else {
	  //alert("Data inválida. Preencha novamente, por favor.");
	  //DateField.select();
	  //DateField.focus();
	  return false
   }  
}
//

// Objeto
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;
}
//

// Valida Form
function ValidaForm() 
{ //v4.0


var i,p,q,nm,test,num,min,max,errors='',args=ValidaForm.arguments;
	for (i=0; i<(args.length-2); i+=3)
	{ 	
	test = args[i+2]; 
	val = MM_findObj(args[i]);	
	  if (val) 
	  { 
		nm = val.name;
		if (nm == 'Body')
			SetVals();
			
		val.value = ignoreSpaces(val.value);
		objeto = val;		
		if ((val = val.value) != "") 
		{
		  
		  if (test.indexOf('Email') != -1){ 
		  	p = val.indexOf('@')
			p = val.indexOf('.');
		  	if (p<1 || p==(val.length-1)){
		  	alert("E-mail inválido. Preencha novamente, por favor.");
			objeto.select();
			objeto.focus();
			return false
			}
		  }
		  
		  //verifica site mais não é obrigatório
		  if (test.indexOf('Site') != -1){
			 p = val.indexOf('.');
			 if (val.length > 0){
				if (p<1){
				alert("Site inválido. Preencha novamente, por favor.");
				objeto.select();
				objeto.focus();
				return false
				}
			 }
		  }
		  if(test.indexOf('Numero') != -1){
		  	if (isNaN(val)){	
			 alert("Esse campo permite apenas valores numéricos. Preencha novamente, por favor.");
			 objeto.select();
			 objeto.focus();
			 return false;
			 }
		}
		if(test.indexOf('CNPJSITE') != -1){
		  	if (isNaN(val)){	
			 alert("O campo CNPJ permite apenas valores numéricos. Preencha novamente, por favor.");
			 objeto.select();
			 objeto.focus();
			 return false;
			 }
		} 
		   if (test.indexOf('Data') != -1) 
			  { 
				  //p=test.indexOf(':');
				  //min=test.substring(8,p); 
				  //max=test.substring(p+1);
				  //if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
				  // Valida campo de Data	
					//teste = ValidaData(document.form1[args[i]]);										 					
					if (! ValidaData(objeto)) 
						{
						alert("Data inválida. Preencha novamente, por favor.");
						objeto.select();
						objeto.focus();
						return false;
						}
			  }
			 //testa cpf OU cnpj
			 if (test.indexOf('CPFCNPJ') != -1) 
			 {
				 if (val.length <= 11)
				 {
					 if (Verify(val, "CPF") == false)
					 {
						 alert("CPF Inválido!");
						objeto.value = "";
						// objeto.select();
						 objeto.focus();
						 return false;
					 }
				 }else{
					 if (Verify(val, "CNPJ") == false)
					 {
						 alert("CNPJ Inválido!");
						// objeto.select();
						objeto.value = "";
						objeto.focus();
						 return false;
					}
				}
			}else{
				//procura so pelo cpf
				 if (test.indexOf('CPF') != -1) 
				 {
					if (Verify(val, "CPF") == false)
					{
						alert("CPF Inválido!");
						objeto.value = "";
						//objeto.select();
						objeto.focus();
						return false;
					}
				}
				//procura so pelo CNPJ
				 if (test.indexOf('CNPJ') != -1) 
				 {
					if (Verify(val, "CNPJ") == false)
					{
						alert("CNPJ Inválido!");
						//objeto.select();
						objeto.value = "";
						objeto.focus();
						return false;
					}
				}
		   }

		} 
		else if (test.charAt(0) == 'R') 
			{
			alert("Por favor, preencha todos os campos obrigatórios.\n * Campos Obrigatórios");			
			if (nm != 'Body')
			  if (objeto.type != 'hidden')
			 	objeto.focus();			 
				
			return false;
			}
	   }
	} 

}
//

// Valida campo de E-mail
function ValidaEmail(field)
{

  var p, fieldvalue
  
  fieldvalue = field.value;
  p = fieldvalue.length;
  if (p != 0)
  {
    p = fieldvalue.indexOf('@');
	p = fieldvalue.indexOf('.');
    if (p<1 || p==(fieldvalue.length-1))
    {
      alert("E-mail inválido. Preencha novamente, por favor.");
      field.select();
      field.focus();
    } 
  }  
}
//

// Retira espaços em branco da esquerda e direita
function ignoreSpaces(string)
{
size = string.length
while (string.slice(0,1) == " ") //Strip leading spaces
  {string = string.substr(1,size-1);size = string.length
  }
 while(string.slice(size-1,size)== " ") //Strip trailing spaces
  {string = string.substr(0,size-1);size = string.length
  }
return string;
// retira todos espaços
//  varItemp = "";
//  string = '' + string;
//  splitstring = string.split(" ");
//  alert(splitstring);
//  for(i = 0; i < splitstring.length; i++)
//Itemp += splitstring[i];

//returnItemp;
}
//

// Valida os campos obrigatórios
function CamposObrigatorios() 
{ 
  var i,args=CamposObrigatorios.arguments;
  for (i=0; i<(args.length); i+=1) 
  {     
    val=MM_findObj(args[i]);
    if (val) 
    { 
      if (ignoreSpaces(val.value) == "") 
      {
        alert('Por favor, preencha todos os campos obrigatórios.');
        val.select();
        val.focus();
        return false;
      }
    } 
  }  
}
//

// Somente Numero
function NumeroPossivel()
{        
  if (event.keyCode == 13)
   	event.returnValue = true	
  else if (event.keyCode < 48 || event.keyCode > 57) 
	event.returnValue = false
}
//

// Somente data
function DataPossivel()
{       
    if (event.keyCode == 13)
	  	event.returnValue = true
	else if (event.keyCode < 47 || event.keyCode > 57) 
		event.returnValue = false
}
//

// Função para calcular diferença entre datas (em dias)
function Dia(Data_DDMMYYYY)
{
string_data = Data_DDMMYYYY.toString();
posicao_barra = string_data.indexOf("/");
if (posicao_barra!= -1)
{
dia = string_data.substring(0,posicao_barra);
return dia;
}
else
{
return false;
}
}

function Mes(Data_DDMMYYYY)
{
string_data = Data_DDMMYYYY.toString();
posicao_barra = string_data.indexOf("/");
if (posicao_barra!= -1)
{
dia = string_data.substring(0,posicao_barra);
string_mes = string_data.substring(posicao_barra+1,string_data.length);
posicao_barra = string_mes.indexOf("/");
if (posicao_barra!= -1)
{
mes = string_mes.substring(0,posicao_barra);
mes = Math.floor(mes);
return mes;
}
else
{
return false;
}

}
else
{
return false;
}
}

function Ano(Data_DDMMYYYY)
{
string_data = Data_DDMMYYYY.toString();
posicao_barra = string_data.indexOf("/");
if (posicao_barra!= -1)
{
dia = string_data.substring(0,posicao_barra);
string_mes = string_data.substring(posicao_barra+1,string_data.length);
posicao_barra = string_mes.indexOf("/");
if (posicao_barra!= -1)
{
mes = string_mes.substring(0,posicao_barra);
mes = Math.floor(mes);
ano = string_mes.substring(posicao_barra+1,string_mes.length);
return ano;
}
else
{
return false;
}

}
else
{
return false;
}
}

function Calcula_Dias(data1_DDMMYYYY,data2_DDMMYYYY){

Var_Dia1=Dia(data1_DDMMYYYY);
Var_Mes1=Mes(data1_DDMMYYYY);
Var_Mes1=Math.floor(Var_Mes1)-1;
Var_Ano1=Ano(data1_DDMMYYYY);
var data1 = new Date(Var_Ano1,Var_Mes1,Var_Dia1);

Var_Dia2=Dia(data2_DDMMYYYY);
Var_Mes2=Mes(data2_DDMMYYYY);
Var_Mes2=Math.floor(Var_Mes2)-1;
Var_Ano2=Ano(data2_DDMMYYYY);
var data2 = new Date(Var_Ano2,Var_Mes2,Var_Dia2);

var diferenca = data1.getTime() - data2.getTime();
var diferenca = Math.floor(diferenca / (1000 * 60 * 60 * 24));
return diferenca
}
//

//-->
function validaconquista(){
if(document.frm_busca.strBusca.value==""){
alert("Preencha o campo para efetuar a busca!")
return false;
}
}

function ValidaAgendamento(){

escolhido = document.getElementById("formescolhido").value;



if(escolhido=="1"){
erro=0;

	if(document.getElementById("nomecontato").value==""){
		erro=1;
	}
	
	if(document.getElementById("telefone").value==""){
		erro=1;
	}
	
	if(document.getElementById("cidade").value==""){
		erro=1;
	}
	if(document.getElementById("estado").value==""){
		erro=1;
	}
	if(document.getElementById("numleito").value==""){
		erro=1;
	}
	if(document.getElementById("numconvenio").value==""){
		erro=1;
	}
	if(document.getElementById("numfunc").value==""){
		erro=1;
	}
	if(document.getElementById("prflhospital").value==""){
		erro=1;
	}
	if(document.getElementById("srvdisponivel").value==""){
		erro=1;
	}
	if(document.getElementById("numfunc").value==""){
		erro=1;
	}
	if(document.getElementById("vincinstensino").value==""){
		erro=1;
	}
	if(document.getElementById("atendea").value==""){
		erro=1;
	}
	if(document.getElementById("sistgsthospital").value==""){
		erro=1;
	}
	if(document.getElementById("operacionalsistgsthospital").value==""){
		erro=1;
	}
	if(document.getElementById("bancosistgsthospital").value==""){
		erro=1;
	}
	if(document.getElementById("sistadmfinop").value==""){
		erro=1;
	}
	if(document.getElementById("numusratual").value==""){
		erro=1;
	}
		if(document.getElementById("numusrexp").value==""){
		erro=1;
	}
		if(document.getElementById("demode").value==""){
		erro=1;
	}
	if(document.getElementById("comositerm").value==""){
		erro=1;
	}
	if(document.getElementById("ecliente").value==""){
		erro=1;
	}
	
	
	if(erro==1){
		alert("Preencha o campo para efetuar a busca!");
		return false
	}
	
	
}
	if(escolhido=="2"){
	erro=0;


	if(document.getElementById("nomecontato").value==""){
		erro=1;
	}
	
	if(document.getElementById("telefone").value==""){
		erro=1;
	}
	
	if(document.getElementById("cidade").value==""){
		erro=1;
	}
	if(document.getElementById("estado").value==""){
		erro=1;
	}
	if(document.getElementById("numusrassoc").value==""){
		erro=1;
	}
	if(document.getElementById("numusrplidvfml").value==""){
		erro=1;
	}
	if(document.getElementById("numusrplempsr").value==""){
		erro=1;
	}
	if(document.getElementById("numempsrcontr").value==""){
		erro=1;
	}
	if(document.getElementById("totcredenciad").value==""){
		erro=1;
	}
	if(document.getElementById("tipooperadora").value==""){
		erro=1;
	}
	if(document.getElementById("sistgestop").value==""){
		erro=1;
	}
	if(document.getElementById("sistadmfin").value==""){
		erro=1;
	}
	if(document.getElementById("sistadmfinop").value==""){
		erro=1;
	}
	if(document.getElementById("numusratual").value==""){
		erro=1;
	}
	if(document.getElementById("numusrexp").value==""){
		erro=1;
	}
	if(document.getElementById("demode").value==""){
		erro=1;
	}
	if(document.getElementById("comositerm").value==""){
		erro=1;
	}
		if(document.getElementById("ecliente").value==""){
		erro=1;
	}
	
	
	if(erro==1){
		alert("Preencha o campo para efetuar a busca!");
		return false
	}
}

if(escolhido=="3"){
	erro=0;


	if(document.getElementById("nomecontato").value==""){
		erro=1;
	}
	if(document.getElementById("telefone").value==""){
		erro=1;
	}
	
	if(document.getElementById("cidade").value==""){
		erro=1;
	}
	if(document.getElementById("estado").value==""){
		erro=1;
	}
	
	if(document.getElementById("demode").value==""){
		erro=1;
	}
	
	if(document.getElementById("comositerm").value==""){
		erro=1;
	}
		if(document.getElementById("ecliente").value==""){
		erro=1;
	}
	
	
	if(erro==1){
		alert("Preencha o campo para efetuar a busca!");
		return false
	}
}

}

// o retorno é true ou false.. a function é TESTA('298098098390','CPF') <- troca o cpf por CNPJ
function TESTA(CNUMB,CTYPE)
{
  if(Verify(CNUMB, CTYPE))
  {
  	//alert("verdadeiro");
   // return(true)
  }
  else
  {
  	if(CTYPE=='CPF'){
	alert("Cpf Inválido!");
	}
	if(CTYPE=='CNPJ'){
	alert("CNPJ Inválido!");
	}
   return false;
  }
}

function ClearStr(str,charo)
{
  while((cx=str.indexOf(charo))!=-1)
  {		
    str = str.substring(0,cx)+str.substring(cx+1);
  }
  return(str);
}

function ParseNumb(c)
{
  c=ClearStr(c,'-');
  c=ClearStr(c,'/');
  c=ClearStr(c,',');
  c=ClearStr(c,'.');
  c=ClearStr(c,'(');
  c=ClearStr(c,')');
  c=ClearStr(c,' ');
  if((parseFloat(c) / c != 1))
  {
    if(parseFloat(c) * c == 0)
    {
      return(c);
    }
    else
    {
      return(0);
    }
  }
  else
  {
    return(c);
  }
}

function Verify(CNUMB,CTYPE)
{
  CNUMB=ParseNumb(CNUMB)
  if(CNUMB == 0)
  {
    return(false);
  }
  else
  {
    g=CNUMB.length-2;
    if(TestDigit(CNUMB,CTYPE,g))
    {
      g=CNUMB.length-1;
      if(TestDigit(CNUMB,CTYPE,g))
      {	
        return(true);
      }
      else
      {
        return(false);
      }
    }
    else
    {
      return(false);
    }
  }
}

function TestDigit(CNUMB,CTYPE,g)
{
  var dig=0;
  var ind=2;
  for(f=g;f>0;f--)
  {
    dig+=parseInt(CNUMB.charAt(f-1))*ind;
    if (CTYPE=='CNPJ')
    { if(ind>8) {ind=2} else {ind++} }
    else
    { ind++ }
  }
  dig%=11;
  if(dig<2)
  {
    dig=0;
  }
  else
  {
    dig=11-dig;
  }
  if(dig!=parseInt(CNUMB.charAt(g)))
  {
    return false;
  }
  else
  {
    return(true);
  }
}


//FUNÇÂO ABRIR POPUP SOLUÇÔES ALIANÇA//
function JustSoPicWindow(imageName,imageWidth,imageHeight,alt,bgcolor,hugger,hugMargin) {

	if (bgcolor=="") {
		bgcolor="#FFFFFF";
	}
	var adj=10
	var w = screen.width;
	var h = screen.height;
	var byFactor=1;

	if(w<740){
	  var lift=0.90;
	}
	if(w>=740 & w<835){
	  var lift=0.91;
	}
	if(w>=835){
	  var lift=0.93;
	}
	if (imageWidth>w){	
	  byFactor = w / imageWidth;			
	  imageWidth = w;
	  imageHeight = imageHeight * byFactor;
	}
	if (imageHeight>h-adj){
	  byFactor = h / imageHeight;
	  imageWidth = (imageWidth * byFactor);
	  imageHeight = h; 
	}
	   
	var scrWidth = w-adj;
	var scrHeight = (h*lift)-adj;

	if (imageHeight>scrHeight){
  	  imageHeight=imageHeight*lift;
	  imageWidth=imageWidth*lift;
	}

	var posLeft=0;
	var posTop=0;

	if (hugger == "hug image"){
	  if (hugMargin == ""){
	    hugMargin = 0;
	  }
	  var scrHeightTemp = imageHeight - 0 + 2*hugMargin;
	  if (scrHeightTemp < scrHeight) {
		scrHeight = scrHeightTemp;
	  } 
	  var scrWidthTemp = imageWidth - 0 + 2*hugMargin;
	  if (scrWidthTemp < scrWidth) {
		scrWidth = scrWidthTemp;
	  }
	  
	  if (scrHeight<100){scrHeight=100;}
	  if (scrWidth<100){scrWidth=100;}

	  posTop =  ((h-(scrHeight/lift)-adj)/2);
	  posLeft = ((w-(scrWidth)-adj)/2);
 	}

	if (imageHeight > (h*lift)-adj || imageWidth > w-adj){
		imageHeight=imageHeight-adj;
		imageWidth=imageWidth-adj;
	}
	posTop = parseInt(posTop);
	posLeft = parseInt(posLeft);		
	scrWidth = parseInt(scrWidth); 
	scrHeight = parseInt(scrHeight);
	
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1){
	  var args= new Array();
	  args[0]='parent';
	  args[1]=imageName;
	  var i ; document.MM_returnValue = false;
	  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	} else {
	newWindow = window.open("","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+' onBlur="self.close()" onClick="self.close()">');  
	newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
	newWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+' alt="CLIQUE SOBRE A IMAGEM PARA FECHAR" >'); 
	newWindow.document.write('</td></tr></table></body></html>');
	newWindow.document.close();
	newWindow.focus();
	}
}

function widthBoxInicial(){
	if(screen.width>=1000){
		document.getElementById("box1").className += " box1024";
		document.getElementById("box2").className += " box1024";
		document.getElementById("box3").className += " box1024 last1024";
		
		document.getElementById("topo_limite").className += " limite1024";
		document.getElementById("main_limite").className += " limite1024";
		document.getElementById("rodape_limite").className += " limite1024";		
		
		document.getElementById("cellDestaque").className += " cell1024";
	
	}else{
		document.getElementById("box1").className += " box800";
		document.getElementById("box2").className += " box800";
		document.getElementById("box3").className += " box800 last800";
		
		document.getElementById("topo_limite").className += " limite800";
		document.getElementById("main_limite").className += " limite800";
		document.getElementById("rodape_limite").className += " limite800";				
		
		document.getElementById("cellDestaque").className += " cell800";
		document.getElementById("dstq_1").className += " destaque800";
		document.getElementById("dstq_2").className += " destaque800";		

	}
}
function limiteLayoutG2(){
	if(screen.width>=1000){
		document.getElementById("topo_limite").className += " limite1024";
		document.getElementById("main_limite").className += " limite1024";
		document.getElementById("rodape_limite").className += " limite1024";		
	}else{
		document.getElementById("topo_limite").className += " limite800";
		document.getElementById("main_limite").className += " limite800";
		document.getElementById("rodape_limite").className += " limite800";				
	}
}

//-->