/*
  <!----------------------------------------------------------------------|
  |  NetDOM - Informatica e Tecnologia dos Municípios LTDA                |
  |  Copyright (c) 2004 - 2005 NetDOM Ltda. Todos Direitos reservados     |
  |-----------------------------------------------------------------------|
  | Alerta: Esse código é protegido por Direitos Autorais e protegido     |
  | por Leis Internacionais, que proibem quaisquer reproducao, modificacao| 
  | ou redistribuicao.                                                    |
  | Caso esse alerta seja desconsiderado, o responsavel podera ser punido |
  | por quebra de Direitos Autorais e Pirataria sob o Codigo civil n.º155 | 
  | da lei 45654 /94                                                      |
  |----------------------------------------------------------------------->
  Arquivo 			 : servernet.js - Biblioteca Geral do ServerNET 
  Autor 			 : Paulo Matos (paulo.matos@netdom.com.br)
  Feito em			 : 21/02/2006 
*/


function muda_ano()
{
  with( document.form_webnet )
  {
	operacao.value = 3;
    action = 'emails_cliente.cfm';
	method = 'post';
	submit();
  }
}


function fnc_inserir_cliente()
{
  with( document.inserir_cliente )
  {
    action = 'novo_cliente.cfm';
	method = 'post';
	target = 'nova'; 
	if( fnc_verifica_form( document.inserir_cliente ) )
	submit();
 
  }
}


function fnc_ativar_atendente()
{
  with( document.form_webnet )
  {
  	operacao.value = 4;
    action = 'listar_inativos.cfm';
	method = 'post';
	target = '_self'; 
	if (id_helpdesk_usuario.value == ''){
		alert("Favor selecionar um usuario");
		return( false ); 		
	}
	else{
		submit();
	}
  }
}


function fnc_alterar_atendente()
{
  with( document.form_webnet )
  {
  	 if( id_helpdesk_usuario.value ) {		
		 /* subfuncao de verificacao 
			 do total de elementos */
		  fnc_total_elementos = function()
		  { 
			var p_count  = 0;
		
			if( id_helpdesk_usuario != null && id_helpdesk_usuario.options != null )
					 for( var i = 0; i < id_helpdesk_usuario.options.length;i++ )
				   if( id_helpdesk_usuario.options[ i ].selected ) p_count++;
			
				return( p_count );
		  }           
		
		  switch( fnc_total_elementos() )
		  {
			case 0: 
				case 1: 
					action = 'alterar_atendente.cfm?id='+id_helpdesk_usuario.value;
					method = 'post';
					target = '_self'; 
					submit();
				break;
     	      default:
							alert('Selecione apenas um '+ String.fromCharCode( 250 ) +'nico usuario');
				break;
		  }	 
      } 
	  else { alert('Selecione pelo menos um usuario'); }
  }
}


function fnc_exclui_atendente()
{
  with( document.form_webnet )
  {
  	operacao.value = 2;
    action = 'listar_atendentes.cfm';
	method = 'post';
	target = '_self'; 
	if (id_helpdesk_usuario.value == ''){
		alert("Favor selecionar um usuario");
		return( false ); 		
	}
	else{
		submit();
	}
  }
}


function fnc_inserir_usuario()
{
  with( document.inserir_usuario )
  {
  
    action = 'novo_usuario.cfm';
	method = 'post';
	target = 'nova'; 
	if( fnc_verifica_form( document.inserir_usuario ) )
	submit();
  }
}


function fnc_inserir_atendente()
{
	with( document.inserir_atendente )
  	{  
		if (usuario_id.value == ''){
			alert("Favor selecionar o usuario");
			return( false ); 		
		}

		var ok = false;
		var form = departamentos;
		
		for (i = 0; i < form.length; i++)    { 
			if (form[i].checked) { 
				ok = true; 
			}
		}
		if (!ok) {
			alert("Favor selecionar pelo menos um departamento");
			return( false ); 		
		}
		action = 'novo_atendente.cfm';
		method = 'post';
		target = '_self';		
		submit();		
	}	
}


function popup( ) { 
	window.open('email_invalidos.cfm','janela01','status=no,resizable=no,scrollbars=yes,menubar=no,width=300,height=400,left=15,top=20') ;
}


function fnc_muda_sistema()
{
 with( document.forms[ 0 ] )
 {
   action = 'usuariosistemas.cfm';
   method = 'post';
   target = 'sistemas_cliente';
   submit();
  // target = '_self';
  }	 
  return( true );
}


function marca_associados(formulario)
{
	string = formulario.sistemas_vinculados;
	
	var i;
	var associados = '';
	var contador = 0;
	var len = string.length;
	
	for(var count = 0; count < len; count++) 
	{
		i = string.options[count].value;
		contador = contador + 1;

		if (contador > 1) {
			associados = associados + ',' + i ;
		} else {
			associados = i;
		}
	}
	
	formulario.associados.value = associados;
	
}


function marca_todos(formulario)
{
	string = formulario.links_vinculados;
	
	var i;
	var associados = '';
	var contador = 0;
	var len = string.length;
	
	for(var count = 0; count < len; count++) 
	{
		i = string.options[count].value;
		contador = contador + 1;

		if (contador > 1) {
			associados = associados + ',' + i ;
		} else {
			associados = i;
		}
	}
	
	formulario.associados.value = associados;
	
}


function resizeIframe_adm(){
	var iframeCentral=document.getElementById("sistemas");
	var alturaPagina=iframeCentral.contentWindow.document.body.scrollHeight;
	iframeCentral.style.height=alturaPagina;
}


function resizeIframe_cliente(){
	var iframeCentral=document.getElementById("janela");
	var alturaPagina=iframeCentral.contentWindow.document.body.scrollHeight;
	iframeCentral.style.height=alturaPagina;
}


function resizeIframe(){
	var iframeInterno=document.getElementById("janela"); 
	var alturaPagina=iframeInterno.contentWindow.document.body.scrollHeight;
	iframeInterno.style.height=alturaPagina;
}


function verificar(){
	 with ( document.formulario ){
		if ( inscricao.value.length == 7){			
		  action = 'verificar2.cfm';
		  method = 'post';
		  target = '_self';
		  submit();
		}else{
		  alert('Você deve preencher o número de inscricao com 7 caracteres');
		  return false;
	   }
	}
 }


function enquete_resultado( id_enquete, id_cliente ) { 
  	pagina='http://www.netdom.com.br/sistemas/diversos_sistemas/webnet/resultado_enquete.cfm?id_enquete='+id_enquete+'&id_cliente='+id_cliente;
	newWindow=window.open(pagina,"enquete_resultado","width=330,height=400,scrollbars=yes")
    if(newWindow)
		return false
    enquete_resultado()
}

function enquete_anteriores( id_cliente ) { 
  	resultado='http://www.netdom.com.br/sistemas/diversos_sistemas/webnet/enquete_anteriores.cfm?id_cliente='+id_cliente;
	novajanela=window.open(resultado,"enquete_resultado","width=400,height=500,scrollbars=yes")
    if(novajanela)
		return false
    enquete_anteriores()
}
	
function checa(nform) {
	//validacao de radio buttons sem saber quantos sao
	marcado = -1
	for (i=0; i<nform.resp.length; i++) {
		if (nform.resp[i].checked) {
			marcado = i
			resposta = nform.resp[i].value
		}
	}
	
	if (marcado == -1) {
		alert("Selecione uma resposta.");
		nform.resp[0].focus();
		return false;
	} else { 
		 with( document.enquete_webnet )
		 {
					 action  = 'http://www.netdom.com.br/sistemas/diversos_sistemas/webnet/envio_enquete.cfm'; 
 				     method  = 'post'; 
				     target  = 'webnet_enquete';
				     submit();
		 }
		return false; 
	} 
		return true;
}


function fnc_alterar_senha()
{
  with( document.alterar_senha )
  {
	 if( senha1.value.length == 0 || senha2.value.length == 0 || senha1.value != senha2.value ) {
	    alert('Os campos nova senha e confirmacao devem ser iguais e nao nulos. Redigite-os');
	 }
	 else {	
			action = 'alterar_senha.cfm';
			method = 'post';
			target = 'nova'; 
			submit();
	      }
  }
}


function deslogar()
{
    self.location = 'adm.cfm?deslog=1';
}


function fnc_muda_texto_empresa()
{
 with( document.forms[ 0 ] )
 {
 
   action = 'busca_sistemas2.cfm';
   method = 'post';
   target = 'sistemas_cliente';
   submit();
  // target = '_self';
  }	 
  return( true );
}

function fnc_muda_texto_baixo()
{
 with( document.forms[ 0 ] )
 {
 
   action = 'branco.html';
   method = 'post';
   target = 'sistemas';
   submit();
  // target = '_self';
  }	 
  return( true );
}

  function mousecima(src,clrOver,strTxt) {
    if (!src.contains(event.fromElement)) {
	  src.style.cursor = 'hand';
	  src.bgColor = clrOver;
	  window.status=strTxt;
	}
  }
  function mousefora(src,clrIn) {
	if (!src.contains(event.toElement)) {
	  src.style.cursor = 'default';
	  src.bgColor = clrIn;
	  window.status='';
	}
  }
  function mClk(src) {
    if(event.srcElement.tagName=='TD'){
	  src.children.tags('A')[0].click();
    }
  }


function fnc_visualizar_sistema()
{ 
with( document.form_webnet ) 
    {
  if( id_cliente.value ) {		
		 /* subfuncao de verificacao 
			 do total de elementos */
		  fnc_total_elementos = function()
		  { 
			var p_count  = 0;
		
			if( id_cliente != null && id_cliente.options != null )
					 for( var i = 0; i < id_cliente.options.length;i++ )
				   if( id_cliente.options[ i ].selected ) p_count++;
			
				return( p_count );
		  }           
		
		  switch( fnc_total_elementos() )
		  {
			case 0: 
				case 1: 
		
				action 		   		= 'visualizar_sistema.cfm';
				method 		   		= 'post'; 
				target 				= 'sistemas';  
				submit();
				break;
     	      default:
							alert('Selecione apenas um '+ String.fromCharCode( 250 ) +'nico cliente');
				break;
		  }	 
      } 
	  else { alert('Selecione pelo menos um cliente'); }
   }
}


function fnc_exclui_sistema()
{ 
with( document.form_webnet )
    {
  if( id_sistema.value ) {		
	 if (confirm ("Tem certeza que deseja excluir o(s) sistema(s)"))
	 { 
				action 		   		= 'excluir_sistema.cfm';
				method 		   		= 'post'; 
				target 				= 'frame';  
				submit();
      } 
  							}
	  else { alert('Selecione pelo menos um sistema para excluir') }
   }
}


function fnc_exclui_foto() 
{ 
with( document.form_webnet ) 
    {
  if( id_foto.value ) {
	  	 if (confirm ("Tem certeza que deseja excluir a foto ?")){
				action 		   		= 'noticias_foto.cfm';
				method 		   		= 'post'; 
				submit();
  			} 
      } 
	  else { alert('Selecione pelo menos uma foto para exclui-la'); }
   }
}


function fnc_alterar_webmail()
{
	 with( document.form_webnet )
	 {
		 action  = 'webmail.cfm'; 
		 method  = 'post'; 
		 target  = '_self';
		 submit();
	}
}


function fnc_exclui_cliente()
{ 
with( document.form_webnet )
    {
  if( id_cliente.value ) {		
	 if (confirm ('     Tem certeza que deseja excluir o(s) cliente(s)   \n Ir' + String.fromCharCode( 225 ) + ' apagar todo conte' + String.fromCharCode( 250 ) + 'do relacionado a essa empresa'))
	 { 
				action 		   		= 'excluir_cliente.cfm';
				method 		   		= 'post'; 
				target 				= 'frame';  
				submit();
      } 
  							}
	  else { alert('Selecione pelo menos uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.'); }
   }
}


function fnc_alterar_cliente()
{ 
with( document.form_webnet ) 
    {
  if( id_cliente.value ) {		
		 /* subfuncao de verificacao 
			 do total de elementos */
		  fnc_total_elementos = function()
		  { 
			var p_count  = 0;
		
			if( id_cliente != null && id_cliente.options != null )
					 for( var i = 0; i < id_cliente.options.length;i++ )
				   if( id_cliente.options[ i ].selected ) p_count++;
			
				return( p_count );
		  }           
		
		  switch( fnc_total_elementos() )
		  {
			case 0: 
				case 1: 
		
				action 		   		= 'alterar_cliente.cfm';
				method 		   		= 'post'; 
				target 				= 'sistemas';  
				submit();
				break;
     	      default:
							alert('Selecione apenas um '+ String.fromCharCode( 250 ) +'nico cliente');
				break;
		  }	 
      } 
	  else { alert('Selecione pelo menos um cliente'); }
   }
}


function fnc_alterar_cliente_outro()
{
  with( document.alterar_cliente )
  {
    action = 'alterar_cliente.cfm';
	method = 'post';
	if( fnc_verifica_form( document.alterar_cliente ) )
	submit();
 
  }
}


function fnc_incluir_sistema()
{ 
with( document.form_webnet ) 
    {
  if( id_cliente.value ) {		
		 /* subfuncao de verificacao 
			 do total de elementos */
		  fnc_total_elementos = function()
		  { 
			var p_count  = 0;
		
			if( id_cliente != null && id_cliente.options != null )
					 for( var i = 0; i < id_cliente.options.length;i++ )
				   if( id_cliente.options[ i ].selected ) p_count++;
			
				return( p_count );
		  }           
		
		  switch( fnc_total_elementos() )
		  {
			case 0: 
				case 1: 
		
				action 		   		= 'incluir_sistema.cfm';
				method 		   		= 'post'; 
				target 				= 'frame';  
				submit();
				break;
     	      default:
							alert('Selecione apenas um '+ String.fromCharCode( 250 ) +'nico cliente');
				break;
		  }	 
      } 
	  else { alert('Selecione pelo menos um cliente'); }
   }
}


function fnc_login()
{
 with( document.login )
 {
	action 		   		= 'validar.cfm';
	method 		   		= 'post';
	target				= 'resultado';
    submit(); 
  }
}


function fnc_edicao_usuarios()
{ 
with( document.form_webnet ) 
    {
  if( id_cliente.value ) {		
		 /* subfuncao de verificacao 
			 do total de elementos */
		  fnc_total_elementos = function()
		  { 
			var p_count  = 0;
			if( id_cliente != null && id_cliente.options != null )
					 for( var i = 0; i < id_cliente.options.length;i++ )
				   if( id_cliente.options[ i ].selected ) p_count++;
				return( p_count );
		  }           
		  switch( fnc_total_elementos() )
		  {
			case 0: 
				case 1: 
				action 		   		= 'edicao_usuario.cfm';
				method 		   		= 'post'; 
				target 				= 'sistemas';  
				submit();
				break;
     	      default:
							alert('Selecione apenas um '+ String.fromCharCode( 250 ) +'nico cliente');
				break;
		  }	 
      } 
	  else { alert('Selecione pelo menos um cliente'); }
   }
}


function fnc_gerenciar_sistemas()
{ 
with( document.form_webnet ) 
    {
		action 		   		= 'gerenciar_sistemas.cfm';
		method 		   		= 'post'; 
		target 				= 'sistemas';  
		submit();
   }
}


function fnc_editar_usuario()
{ 
with( document.form_webnet ) 
    {
  if( usuario_id.value ) {		
		 /* subfuncao de verificacao 
			 do total de elementos */
		  fnc_total_elementos = function()
		  { 
			var p_count  = 0;
			if( usuario_id != null && usuario_id.options != null )
					 for( var i = 0; i < usuario_id.options.length;i++ )
				   if( usuario_id.options[ i ].selected ) p_count++;
				return( p_count );
		  }           
		  switch( fnc_total_elementos() )
		  {
			case 0: 
				case 1: 
				action 		   		= 'editar_usuario.cfm';
				method 		   		= 'post'; 
				target				= '_self';
				submit();
				break;
     	        default:
							alert('Selecione apenas um usuario');
				break;
		  }	 
      } 
	  else { alert('Selecione pelo menos um usuario'); }
   }
}


function fnc_exclui_usuario()
{ 
with( document.form_webnet ) 
    {
  if( usuario_id.value ) {
	  	 if (confirm ("Tem certeza que deseja excluir o(s) usuario(s)")){
				action 		   		= 'excluir_usuario.cfm';
				method 		   		= 'post'; 
				target				= '_self';
				submit();
  			}
      } 
	  else { alert('Selecione pelo menos um usuario'); }
   }
} 
 
 
/* ----------------------------------------------------------------------------
------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
*/


function fnc_altera_senha()
{
 with( document.inserir_usuario )
 {
  operacao.value = 1;	
  
  //verfica se a confirmacao de senha confere com a senha digitada
  if( senha_sn.value != rpt_senha_sn.value )
   {
	alert('As senhas n' + String.fromCharCode( 227 ) + 'o conferem. Verifique e tente novamente');
	
	senha_sn.value     = ''; 
	rpt_senha_sn.value = '';
	
	senha_sn.focus();
       return( false );  	   
   }
   else { fnc_alterar_usuario(); }
  }	
}


function fnc_alterar_usuario()
{
  with( document.alterar_usuario )
  {
  
    action = 'editar_usuario.cfm';
	method = 'post'; 
	target = 'nova';   
	if( fnc_verifica_form( document.alterar_usuario ) )
	submit();
  } 
} 


function fnc_pega_usuario()
{
with( document.form_webnet )
 {
	action 		   		= 'editar_usuario.cfm';
	method 		   		= 'post';
	target 				= '_self';
 if( fnc_muda_texto_usuario( document.form_webnet ) )
 submit();
  }
}


function fnc_valida_cnpj()
 {
  with( document.form1)
  {
 	retorno = validaCNPJ( cnpj.value );
	
	alert( retorno );
	
	if( retorno  )
	    submit();
  }
 }
 
 
function validaCNPJ(cnpj)
{ 
var i; 
cnpj = cnpj.replace(".", ""); 
cnpj = cnpj.replace(".", ""); 
cnpj = cnpj.replace("/", ""); 
cnpj = cnpj.replace("-", ""); 

var c  = cnpj.substr(0,12); 
var dv = cnpj.substr(12,2); 
	if (cnpj == "00000000000000") { return false; } 
var d1 = 0; 
var ms = "543298765432"; 
	for (i = 0; i < 12; i++)
	{ 
		d1 += c.charAt(i)*ms.charAt(i); } 
		d1  = (d1 % 11); 
			if (d1 == 0 || d1 == 1)
			{ 
				d1 = 0; 
			} else { 
				d1 = 11 - d1; 
			} 
		var d1 = 0; 
		var ms = "543298765432"; 
			for (i = 0; i < 12; i++)
			{ 
				d1 += c.charAt(i)*ms.charAt(i); 
			} 	
				d1 = (d1 % 11); 
				
				if (d1 == 0 || d1 == 1)
				{ 
					d1 = 0; 
				} else { 
					d1 = 11 - d1; 
				} 
				var c = c + d1; 
				var d2 = 0; 
				var ms = "6543298765432"; 
				
				for (i = 0; i < 13; i++)
				{ 
					d2 += c.charAt(i)*ms.charAt(i); 
				} 
					d2 = (d2 % 11); 
					
					if (d2 == 0 || d2 == 1)
					{ 
						d2 = 0; 
					} else { 
						d2 = 11 - d2; 
					} 
					
					if (dv.charAt(0) != d1 || dv.charAt(1) != d2) { return false; } return true; 
					
}


function MascaraCEP (formato, keypress, objeto)
{
campo = eval (objeto);
if (formato=='cep')
{
caracteres = '01234567890';
separacoes = 1;
separacao1 = '-';
conjuntos = 2;
conjunto1 = 5;
conjunto2 = 3;
if ((caracteres.search(String.fromCharCode (keypress))!=-1) && campo.value.length < (conjunto1 + conjunto2 + 1))
{
if (campo.value.length == conjunto1) 
campo.value = campo.value + separacao1;
}
else 
event.returnValue = false;
}
}


function fnc_renomear_usuario() 
{
 with( document.form_webnet )
 {
   action  = 'renomear_usuario.cfm'; 
   method  = 'post'; 
   target  = '_top';
 
  /* subfuncao de verificacao 
     do total de elementos */
  fnc_total_elementos = function()
  { 
    var p_count  = 0;

    if( usuario_sn != null && usuario_sn.options != null )
             for( var i = 0; i < usuario_sn.options.length;i++ )
           if( usuario_sn.options[ i ].selected ) p_count++;
    
        return( p_count );
  }           

  switch( fnc_total_elementos() )
  {
    case 0: 
        case 1: 
            if ( usuario_sn.value ) {
					submit(); }
			else {		
					alert('Selecione pelo menos uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.');
			    }
        break;
          default:
          alert('Selecione somente uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.');
          break;
  }
 }
}


function fnc_pega_sistema() 
{
 with( document.form_webnet )
 {
   action  = 'editar_sistema.cfm'; 
   method  = 'post'; 
   target  = '_top';   
 
  /* subfuncao de verificacao 
     do total de elementos */
  fnc_total_elementos = function()
  { 
    var p_count  = 0;

    if( sistema_id != null && sistema_id.options != null )
             for( var i = 0; i < sistema_id.options.length;i++ )
           if( sistema_id.options[ i ].selected ) p_count++;
    
        return( p_count );
  }           

  switch( fnc_total_elementos() )
  {
    case 0: 
        case 1: 
            if ( sistema_id.value ) {
					submit(); }
			else {		
					alert('Selecione pelo menos uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.');
			    }
        break;
          default:
          alert('Selecione somente uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.');
          break;
  }
 }
}


function fnc_pega_host() 
{
 with( document.form_webnet )
 {
   action  = 'editar_host.cfm'; 
   method  = 'post'; 
 
  /* subfuncao de verificacao 
     do total de elementos */
  fnc_total_elementos = function()
  { 
    var p_count  = 0;

    if( host_id != null && host_id.options != null )
             for( var i = 0; i < host_id.options.length;i++ )
           if( host_id.options[ i ].selected ) p_count++;
    
        return( p_count );
  }           

  switch( fnc_total_elementos() )
  {
    case 0: 
        case 1: 
            if ( host_id.value ) {
					submit(); }
			else {		
					alert('Selecione pelo menos uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.');
			    }
        break;
          default:
          alert('Selecione somente uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.');
          break;
  }
 }
}


function fnc_pega_fabricante() 
{
 with( document.form_webnet )
 {
   action  = 'editar_fabricante.cfm'; 
   method  = 'post'; 
   target  = '_top';   
 
  /* subfuncao de verificacao 
     do total de elementos */
  fnc_total_elementos = function()
  { 
    var p_count  = 0;

    if( fabricante_id != null && fabricante_id.options != null )
             for( var i = 0; i < fabricante_id.options.length;i++ )
           if( fabricante_id.options[ i ].selected ) p_count++;
    
        return( p_count );
  }           

  switch( fnc_total_elementos() )
  {
    case 0: 
        case 1: 
            if ( fabricante_id.value ) {
					submit(); }
			else {		
					alert('Selecione pelo menos uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.');
			    }
        break;
          default:
          alert('Selecione somente uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.');
          break;
  }
 }
}


function fnc_exclui_fabricante()
{ 
with( document.form_webnet )
    {
  if( fabricante_id.value ) {		
	 if (confirm ("Tem certeza que deseja excluir o(s) fabricante(s)"))
	 { 
				action 		   		= 'excluir_fabricante.cfm';
				method 		   		= 'post'; 
				target 				= 'frame';  
				submit();
      } 
  							}
	  else { alert('Selecione pelo menos uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.'); }
   }
}


function fnc_exclui_servidor()
{ 
with( document.form_webnet )
    {
  if( servidor_id.value ) {		
	 if (confirm ("Tem certeza que deseja excluir o(s) servidor(es)"))
	 { 
				action 		   		= 'excluir_servidor.cfm';
				method 		   		= 'post'; 
				target 				= 'frame';  
				submit();
      } 
  							}
	  else { alert('Selecione pelo menos uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.'); }
   }
}


function fnc_pega_servidor() 
{
 with( document.form_webnet )
 {
   action  = 'editar_servidor.cfm'; 
   method  = 'post'; 
 
  /* subfuncao de verificacao 
     do total de elementos */
  fnc_total_elementos = function()
  { 
    var p_count  = 0;

    if( servidor_id != null && servidor_id.options != null )
             for( var i = 0; i < servidor_id.options.length;i++ )
           if( servidor_id.options[ i ].selected ) p_count++;
    
        return( p_count );
  }           

  switch( fnc_total_elementos() )
  {
    case 0: 
        case 1: 
            if ( servidor_id.value ) {
					submit(); }
			else {		
					alert('Selecione pelo menos uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.');
			    }
        break;
          default:
          alert('Selecione somente uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.');
          break;
  }
 }
}

function fnc_novo_usuario_propriedades() 
{
 with( document.form_webnet )
 {
   action  = 'novo_usuario_propriedades.cfm'; 
   method  = 'post'; 
   target  = '_top'; 
 
  /* subfuncao de verificacao 
     do total de elementos */
  fnc_total_elementos = function()
  { 
    var p_count  = 0;

    if( usuario_sn != null && usuario_sn.options != null )
             for( var i = 0; i < usuario_sn.options.length;i++ )
           if( usuario_sn.options[ i ].selected ) p_count++;
    
        return( p_count );
  }           

  switch( fnc_total_elementos() )
  {
    case 0: 
        case 1: 

                   if( fnc_muda_texto_usuario( document.form_webnet ) )
					submit();
        break;
          default:
                        alert('Selecione apenas um '+ String.fromCharCode( 250 ) +'nico usu'+ String.fromCharCode( 225 ) +'rio');
        break;
  }
 }
}


function fnc_pegar_senha()
{
 with( document.inserir_usuario )
 {
  operacao.value = 1;	
  
  //verfica se a confirmacao de senha confere com a senha digitada
  if( senha_sn.value != rpt_senha_sn.value )
   {
	alert('As senhas n' + String.fromCharCode( 227 ) + 'o conferem. Verifique e tente novamente');
	
	senha_sn.value     = ''; 
	rpt_senha_sn.value = '';
	
	senha_sn.focus();
       return( false );  	   
   }
  }	
}


function fnc_editar_empresa()
{
		with( document.form_webnet )
 			{
			action 		   		= 'editar_empresa.cfm';
			method 		   		= 'post';
		    target 				= '_top';  
   		    submit();
       		}
}




function fnc_exclui_host()
{ 
with( document.form_webnet )
    {
  if( host_id.value ) {		
	 if (confirm ("Tem certeza que deseja excluir o(s) host(s)"))
	 { 
				action 		   		= 'excluir_host.cfm';
				method 		   		= 'post'; 
				target 				= 'frame';  
				submit();
      } 
  							}
	  else { alert('Selecione pelo menos uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.'); }
   }
}

function fnc_associar_usuario()
{
 with( document.form_webnet )
 {
   action  = 'associar_usuario.cfm'; 
   method  = 'post'; 
   target  = '_top';
 
  /* subfuncao de verificacao 
     do total de elementos */
  fnc_total_elementos = function()
  { 
    var p_count  = 0;

    if( usuario_sn != null && usuario_sn.options != null )
             for( var i = 0; i < usuario_sn.options.length;i++ )
           if( usuario_sn.options[ i ].selected ) p_count++;
    
        return( p_count );
  }           

  switch( fnc_total_elementos() )
  {
    case 0: 
        case 1: 

                   if( fnc_muda_texto_usuario( document.form_webnet ) )
					submit();
        break;
          default:
                        alert('Selecione apenas um '+ String.fromCharCode( 250 ) +'nico usu'+ String.fromCharCode( 225 ) +'rio');
        break;
  }
 }
}

function fnc_noticia() 
{
 with( document.form_webnet )
 {
   action  = '../comum/noticia.cfm'; 
   method  = 'get'; 
   target = 'noticia';
	  /* subfuncao de verificacao 
     do total de elementos */
  fnc_total_elementos = function()
  { 
    var p_count  = 0;

    if( mural_aviso_id != null && mural_aviso_id.options != null )
             for( var i = 0; i < mural_aviso_id.options.length;i++ )
           if( mural_aviso_id.options[ i ].selected ) p_count++;
    
        return( p_count );
  }           

  switch( fnc_total_elementos() )
  {
    case 0: 
        case 1: 
            if ( mural_aviso_id.value ) {
					submit(); }
			else {		
					alert('Selecione pelo menos uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.');
			    }
        break;
          default:
          break;
  }
 }
}


function fnc_editar_noticia() 
{
 with( document.form_webnet )
 {
   action  = 'editar_noticia.cfm'; 
   method  = 'post';
   target  = '_top';
 
  /* subfuncao de verificacao 
     do total de elementos */
  fnc_total_elementos = function()
  { 
    var p_count  = 0;

    if( mural_aviso_id != null && mural_aviso_id.options != null )
             for( var i = 0; i < mural_aviso_id.options.length;i++ )
           if( mural_aviso_id.options[ i ].selected ) p_count++;
    
        return( p_count );
  }           

  switch( fnc_total_elementos() )
  {
    case 0: 
        case 1: 
            if ( mural_aviso_id.value ) {
					submit(); }
			else {		
					alert('Selecione pelo menos uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.');
			    }
        break;
          default:
          alert('Selecione somente uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.');
          break;
  }
 }
}


function fnc_exclui_aviso()
{ 
with( document.form_webnet )
    {
  if( mural_aviso_id.value ) {		
	 if (confirm ("Tem certeza que deseja excluir o(s) aviso(s)"))
	 { 
				action 		   		= 'excluir_aviso.cfm';
				method 		   		= 'post'; 
				target 				= 'frame';  
				submit();
      } 
  							}
	  else { alert('Selecione pelo menos uma op' + String.fromCharCode( 231 ) + '' + String.fromCharCode( 227 ) + 'o.'); }
   }
}


/**
 * @descritivo: Envia atualizacões para o servidor
 * @parametro: sem parâmetros
 * @retorno: void
 * @autor       : Jefferson Petilo( jefferson@netdom.com.br ) 
 * @versao: 1, 15 de Maio de  2005
 */
function fnc_upload_atualizacoes()
{
 with( document.form_servernet )
 {
action    = 'principal.cfm';
method    = 'post';
target 	  = '_self';
enctype	  = 'multipart/form-data';
operacao.value = 2;

if( fnc_verifica_form( document.form_servernet ) )
{
submit();
    }
  }
}

/**
 * @descritivo: Deleta arquivos do servidor
 * @parametro: sem parâmetros
 * @retorno: void
 * @autor       : Jefferson Petilo( jefferson@netdom.com.br ) 
 * @versao: 1, 15 de Maio de  2005
 */
function fnc_deletar_arquivo( p_arquivo )
{
 with( document.form_servernet )
 {
action    = 'principal.cfm';
method    = 'post';
target = '_self';
enctype= 'multipart/form-data';
operacao.value = 4;
arquivo.value       = p_arquivo;

   if( confirm('Deseja realmente excluir o arquivo?') )  
      submit();
  }
}

/**
 * @descritivo: Download dos arquivos do servidor
 * @parametro: sem parâmetros
 * @retorno: void
 * @autor       : Jefferson Petilo( jefferson@netdom.com.br ) 
 * @versao: 1, 15 de Maio de  2005
 */
function fnc_download_arquivo( p_arquivo )
{
 with( document.form_servernet )
 {
action    = 'download_arquivo.cfm';
method    = 'post';
target = 'resultado';
operacao.value = 3;
arquivo.value       = p_arquivo;

    submit();
  }
}

/**
 * @descritivo: Enviar fomulario de Contato
 * @parametro: sem parâmetros
 * @retorno: void
 * @autor       : Jefferson Petilo( jefferson@netdom.com.br ) 
 * @versao: 1, 01 de Abril de  2005
 */
function fnc_envia_contato()
{
 with( document.form_webnet )
 {
  operacao.value = 1;
  action         = '/_actions/act_form_contato.cfm';
  method         = 'post';

  if( fnc_verifica_form( document.form_webnet ) )
      submit();
 }
}
/**
 * @descritivo: Enviar fomulario de Fale Consco
 * @parametro: sem parâmetros
 * @retorno: void
 * @autor       : Jefferson Petilo( jefferson@netdom.com.br ) 
 * @versao: 1, 06 de Outubro de  2005
 */
function fnc_fale_conosco()
{
 with( document.form_webnet )
 {
  operacao.value = 1;
  action         = '/_actions/act_fale_conosco.cfm';
  method         = 'post';
  target  = 'resultado';

  if( fnc_verifica_form( document.form_webnet ) )
      submit();
 }
}


function expand(trid) {
  elementid='trc'+trid;
  otherelement='trx'+trid;
  subelements='trs'+trid;
  document.getElementById(elementid).style.display='none';
  document.getElementById(otherelement).style.display='';
  document.getElementById(subelements).style.display='';
}


function collapse(trid) {
  elementid='trc'+trid;
  otherelement='trx'+trid;
  subelements='trs'+trid;
  document.getElementById(elementid).style.display='';
  document.getElementById(otherelement).style.display='none';
  document.getElementById(subelements).style.display='none';
}


var copytoclip=1

function HighlightAll(theField) {
	var tempval=eval("document."+theField)
	tempval.focus()
	tempval.select()
	if (document.all&&copytoclip==1){
		therange=tempval.createTextRange()
		therange.execCommand("Copy")
		window.status="Código copiado com sucesso !"
		setTimeout("window.status=''",1800)
	}
}


function checkEmail(){ 
  with( document.login )
  {
	if (email.value == ''){
		alert("Favor preencher o campo com um e-mail valido.");
	}
	else{
		action = 'index.cfm';
		method = 'post';
		submit();
	}
  }
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}


function MM_reloadPage_outro(init) {  //reloads the window if Nav4 resized
  	if (init==true) with (navigator) {
  		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; 
			onresize=MM_reloadPage; 
		}
	}
  	else{
		if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) {
			location.reload();
		}
	}
}

