
//Determina o Focus
function IniciaFocus()
{
	document.all.LoginTextBox.focus();
}


// Inicializa CheckBox Adiantamento
function IncializaControleCheckBox()
{
	var valorFlagAd = parseInt( document.Form1.FlagAdiantamentoInput.value );	
	
	if( valorFlagAd == 0 )
	{
		document.Form1.adiantamentoSimCheckedBox.checked = false;
		document.Form1.adiantamentoNaoCheckedBox.checked = true;	
		document.Form1.adiantamentoInput.value = 0;		
	}
	else
	{
		document.Form1.adiantamentoSimCheckedBox.checked = true;
		document.Form1.adiantamentoNaoCheckedBox.checked = false;	
		document.Form1.adiantamentoInput.value = "40%";		
	}	
}

// Verificando quando for pressionado o CheckedBox: Sim
function AdmissaoAdiantamentoSalarioSim()
{
	
	
	if( document.Form1.adiantamentoSimCheckedBox.checked == true )
	{
		document.Form1.adiantamentoSimCheckedBox.checked = true;
		document.Form1.adiantamentoNaoCheckedBox.checked = false;	
		document.Form1.adiantamentoInput.value = "40%";		
	}
	else
	{
		document.Form1.adiantamentoSimCheckedBox.checked = false;
		document.Form1.adiantamentoNaoCheckedBox.checked = true;	
		document.Form1.adiantamentoInput.value = 0;		
	}	
}

// Verificando quando for pressionado o CheckedBox: Não
function AdmissaoAdiantamentoSalarioNao()
{
	if( document.Form1.adiantamentoNaoCheckedBox.checked == true )
	{
		document.Form1.adiantamentoSimCheckedBox.checked = false;	
		document.Form1.adiantamentoNaoCheckedBox.checked = true;	
		document.Form1.adiantamentoInput.value = 0;
	}
	else
	{
		document.Form1.adiantamentoSimCheckedBox.checked = true;
		document.Form1.adiantamentoNaoCheckedBox.checked = false;	
		document.Form1.adiantamentoInput.value = "40%";
	}	
}


// CENTRALIZA TELA		
function Centralizar()
{
	var w = window.document.body.offsetWidth;
	var h = window.document.body.offsetHeight;
	var wt = Table1.width;
	var ht = Table1.height;
	
	Table1.style.top = ((h-ht)/2);
	Table1.style.left = ((w-wt)/2);				
}

// CENTRALIZA TELA		
function CentralizarProvisorio()
{
	var auxW = 0;
	var auxH = 0;
	var w = screen.availWidth;
	var h = screen.availHeight;
	var wt = Table1.style.width;
	var ht = Table1.style.height;				
	
	auxW = ((w - parseInt(wt))/2);
	auxH = ((h - parseInt(ht))/2);				
	
	Table1.style.top = auxH - 50;
	Table1.style.left = auxW;				
}



// Função do Editor de Texto Java Script

// Troca Imagem Button
function TrocaImagemButton(URLImagem, NomeControle)
{
	document.getElementById(NomeControle).src = URLImagem;
}			

function Iniciar() {
	editor.document.designMode = 'On';				
}	

function recortar() {
	editor.document.execCommand('cut', false, null);
}

function copiar() {
	editor.document.execCommand('copy', false, null);
}

function colar() {
	editor.document.execCommand('paste', false, null);
}

function desfazer() {
	editor.document.execCommand('undo', false, null);
}

function refazer() {
	editor.document.execCommand('redo', false, null);
}

function negrito() {
	editor.document.execCommand('bold', false, null);
}

function italico() {
	editor.document.execCommand('italic', false, null);
}

function sublinhado() {
	editor.document.execCommand('underline', false, null);
}

function alinharEsquerda() {
	editor.document.execCommand('justifyleft', false, null);
}

function centralizado()	{
	editor.document.execCommand('justifycenter', false, null);
}

function alinharDireita() {
	editor.document.execCommand('justifyright', false, null);				
}


function justificado() {
	editor.document.execCommand('justifyfull', false, null);				
}

function numeracao() {
	editor.document.execCommand('insertorderedlist', false, null);
}

function marcadores() {
	editor.document.execCommand('insertunorderedlist', false, null);
}

function FonteText(strFonte) {
	if(strFonte != '')
		editor.document.execCommand('fontname', false, strFonte);
}			

function tamanho(strTamanho) {
	if(strTamanho != '')
		editor.document.execCommand('fontsize', false, strTamanho);					
}

function fonteColor(cor) {
	if(cor != '')
		editor.document.execCommand("ForeColor",false,event.srcElement.value);

}

function corDeFundo(strFundo) {
	if(strFundo != '')
		editor.document.execCommand("BackColor", false, event.srcElement.value);

}

function Arquivo()
{
	document.Form1.conteudo.value = editor.document.body.innerHTML;									
}


// Formatar Data
function FormataData(x, tecla)
{ 
	// Por Tiago Araujo Silva (tiago@tiagoaraujo.com)	        
	separador = "/"; // Você pode definir o separador. Ex: "/" ou "-" ou "."
	
	tecla = tecla.keyCode; // Identifica a tecla, caso seja backspace
	
	valor = x.value.split(''); // Pega o valor do campo e transforma cada caractere em uma string
	formatado = ""; // Variável para carregar formatação temporariamente
	
	i = 0; // variável de controle
	
	while( i < valor.length )
	{
		caractere = valor[i];
		numeros = /^\d+$/; 
		
		// Verifica se é número ou "barra"
		if( numeros.test(caractere) || caractere == separador )
		{ 
			formatado += String(caractere);
		}
		
		// Verifica se precisa de barra, se a tecla for backspace, então a barra não é adicionada
		// Se for para adicionar barra, aumenta ++ variável de controle "i" para pular a barra adicionada
		if(( formatado.length == 2 || formatado.length == 5 ) && tecla != 8 )
		{
			formatado += separador; 
			i++;
		}		    
		i++; // Se houver, passa para o próximo caractere
	}	
	x.value = formatado; // Atribui o valor formatado ao campo
}

function BloquearDigitacaoDeTexto()
{
	if ((window.event.keyCode >= 48) && (window.event.keyCode <= 57) || (window.event.keyCode == 92) )
	{
		// retorna o * para identificar a posição de inserção
		// window.event.keyCode=0;
	} 
	else
	{
		window.event.returnValue = false;
	}   
}

// Imprimir conteudo do IFrame 
function Imprimir()
{
	document.getElementById('editor').contentWindow.focus();
	document.getElementById('editor').contentWindow.print();
}

// Exemplo: Ç, @, #, %, *, &, ETC
function BloquearDigitacaoCaracteresEspecial()
{
	if ((window.event.keyCode >= 65) && (window.event.keyCode <= 90) || (window.event.keyCode >= 97) && (window.event.keyCode <= 122) || (window.event.keyCode == 32) )
	{
		// retorna o * para identificar a posição de inserção
		// window.event.keyCode=0;
	} 
	else
	{
		window.event.returnValue = false;
	}   	
} 

// Formatar Digitação de Hora
function FormataHora(x, tecla)
{ 
	// Por Tiago Araujo Silva (tiago@tiagoaraujo.com)	        
	separador = ":"; // Você pode definir o separador. Ex: "/" ou "-" ou "."
	
	tecla = tecla.keyCode; // Identifica a tecla, caso seja backspace
	
	valor = x.value.split(''); // Pega o valor do campo e transforma cada caractere em uma string
	formatado = ""; // Variável para carregar formatação temporariamente
	
	i = 0; // variável de controle
	
	while( i < valor.length )
	{
		caractere = valor[i];
		numeros = /^\d+$/; 
		
		// Verifica se é número ou "barra"
		if( numeros.test(caractere) || caractere == separador )
		{ 
			formatado += String(caractere);
		}
		
		// Verifica se precisa de barra, se a tecla for backspace, então a barra não é adicionada
		// Se for para adicionar barra, aumenta ++ variável de controle "i" para pular a barra adicionada
		if(( formatado.length == 3 || formatado.length == 7 ) && tecla != 8 )
		{
			formatado += separador; 
			i++;
		}		    
		i++; // Se houver, passa para o próximo caractere
	}	
	x.value = formatado; // Atribui o valor formatado ao campo
}


// Função para Imprimir conteudo de uma DIV
function PrintElementID(id, pg) 
{
	var oPrint, oJan;
	oPrint = window.document.getElementById(id).innerHTML;
	oJan = window.open(pg);
	oJan.document.write(oPrint);
	oJan.history.go();
	oJan.window.print();
}


		