// JavaScript Document

<!--
var mensagem="";

function clickIE() {

	if (document.all) {
	(mensagem);
	return false;

	}
}

function clickNS(e) {

	if (document.layers||(document.getElementById&&!document.all)) {

		if (e.which==2||e.which==3) {
		(mensagem);
		return false;

		}
	}
}

if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS;
} else {
	document.onmouseup=clickNS;
	document.oncontextmenu=clickIE;
}

document.oncontextmenu=new Function("return false");

// -->

<!--
//<form onSubmit="return VerificaSenha(this)">
function VerificaSenha(form) {
	senha1 = form.senha1.value;
	senha2 = form.senha2.value;

	if (senha1 == "") {
		alert ("\O campo senha não pode ser vazio!")
		this.document.form.senha1.focus();
		return false;
	}

	if (senha2 == "") {
		alert ("\O campo de confirmação não pode ser vazio!")
		this.document.form.senha2.focus();
		return false;
	}

	if (senha1 != senha2) {
		alert ("\As senhas informadas são diferentes!")
		return false;
	}
	else
	return true;
}
//-->

<!--
//<input type="password" id="pass" onkeyup="Security(this.value, 8);">
function Security(val, tamanho) {

	document.getElementById('mensagem').innerHTML = "";
	document.getElementById('d_baixa').style.background = 'white';
	document.getElementById('d_media').style.background = 'white';
	document.getElementById('d_alta').style.background = 'white';

	if( val.length >= tamanho && val.search(/[a-z]/) != -1 && val.search(/[A-Z]/) != -1 && val.search(/[0-9]/) != -1
	||val.length >= tamanho && val.search(/[a-z]/) != -1 && val.search(/[A-Z]/) != -1 && val.search(/[@!#$%&*+=?|-]/)
	||val.length >= tamanho && val.search(/[a-z]/) != -1 && val.search(/[@!#$%&*+=?|-]/) != -1 && val.search(/[0-9]/)
	||val.length >= tamanho  && val.search(/[@!#$%&*+=?|-]/) != -1 && val.search(/[A-Z]/) != -1 && val.search(/[0-9]/) )
	{
		document.getElementById('mensagem').innerHTML = "forte";
		document.getElementById('d_baixa').style.background = 'green';
		document.getElementById('d_media').style.background = 'green';
		document.getElementById('d_alta').style.background = 'green';

	}
	else
	{
		if( val.length >= tamanho && val.search(/[a-z]/) != -1 && val.search(/[A-Z]/) != -1
		||val.length >= tamanho && val.search(/[a-z]/) != -1 && val.search(/[0-9]/) != -1
		||val.length >= tamanho && val.search(/[a-z]/) != -1 && val.search(/[@!#$%&*+=?|-]/) != -1
		||val.length >= tamanho && val.search(/[A-Z]/) != -1 && val.search(/[0-9]/) != -1
		||val.length >= tamanho && val.search(/[A-Z]/) != -1 && val.search(/[@!#$%&*+=?|-]/) != -1
		||val.length >= tamanho && val.search(/[0-9]/) != -1 && val.search(/[@!#$%&*+=?|-]/) != -1)
		{

			document.getElementById('mensagem').innerHTML = "média";
			document.getElementById('d_baixa').style.background = 'yellow';
			document.getElementById('d_media').style.background = 'yellow';
			document.getElementById('d_alta').style.background = 'white';

		}
		else 
		{
			if(val.length >= tamanho)
			{
				document.getElementById('mensagem').innerHTML = "fraca";
				document.getElementById('d_baixa').style.background = 'red';
				document.getElementById('d_media').style.background = 'white';
				document.getElementById('d_alta').style.background = 'white';

			}
		}
	}
}
//-->


var mes = new Array("Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro");
var agora = new Date();

function about(){

	alert('SDT ON LINE\nVersão Alfa\n\nCopyright 2007 SDT\nDevelopment by Virtus Sistemas & PBGold Soluções Internet\nPowered by Duo Sistemas de Informação\n\nAll rights reserved');

}

function authError1(){

	alert("ERRO DE AUTENTICAÇÃO\n\nVocê digitou sua identificação ou senha de forma inválida.\n\nPor favor, autentique-se novamente.");

}

function authError2(){

	alert("ERRO DE AUTENTICAÇÃO\n\nVocê passou mais de 20 minutos inativo e sua sessão expirou.\n\nPor favor, autentique-se novamente.");

}

function authError3(){

	alert("ERRO DE AUTENTICAÇÃO\n\nVocê precisa de permissão de administrador para acessar esta página.\n\nPor favor, autentique-se novamente.");

}

function authError4(){

	alert("ERRO DE AUTENTICAÇÃO\n\nVocê não pertence ao grupo de usuários autorizado a acessar a página\n\nPor favor, autentique-se novamente.");

}

function authError5(){

	alert("ERRO DE AUTENTICAÇÃO\n\nVocê está bloqueado no sistema.\n\nPor favor, entre em contato com o administrador.");

}

function authError6(){

	alert("ERRO DE AUTENTICAÇÃO\n\nPassaram-se 15 dias ou mais desde seu cadastro e você ainda não havia\nfeito nenhum acesso ao sistema. Por esta razão você foi bloqueado.\n\nPor favor, entre em contato com o administrador.");

}

function authError7(){

	alert("ERRO DE AUTENTICAÇÃO\n\nPassaram-se 15 dias ou mais desde seu último acesso.\nPor esta razão você foi bloqueado. \n\nPor favor, entre em contato com o administrador.");

}

function authError8(){

	alert("ERRO DE AUTENTICAÇÃO\n\nVocê está tentando acessar o sistema em um horário não permitido. \n\nPor favor, retorne quando as operações forem liberadas.");

}

//formata campos com máscaras:
function formatar(src, mask) {
	var i = src.value.length;
	var saida = mask.substring(i,i+1);
	var ascii = event.keyCode;

	if (saida == "A") {
		if ((ascii >=97) && (ascii <= 122)) { event.keyCode -= 32; }
		else { event.keyCode = 0; }
	} else if (saida == "0") {
		if ((ascii >= 48) && (ascii <= 57)) { return }
		else { event.keyCode = 0 }
	} else if (saida == "#") {
		return;
	} else {
		src.value += saida;
		i += 1;
		saida = mask.substring(i,i+1);
		if (saida == "A") {
			if ((ascii >=97) && (ascii <= 122)) { event.keyCode -= 32; }
			else { event.keyCode = 0; }
		} else if (saida == "0") {
			if ((ascii >= 48) && (ascii <= 57)) { return }
			else { event.keyCode = 0 }
		} else { return; }
	}
}

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

function MM_goToURL() { //v3.0
	var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
	for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}
//-->
<!--
function dasabilitarenter() {
	var tecla = event.keyCode;
	if ((tecla == 13)) {
		return false;
	}
	return tecla;
}
//-->

<!--
function validacpf(){

	var i;

	cpf = document.frm.cpf.value;

	s = cpf.substr(0,3) + cpf.substr(4,3) + cpf.substr(8,3) + cpf.substr(12,2);

	var c = s.substr(0,9);

	var dv = s.substr(9,2);

	var d1 = 0;

	for (i = 0; i < 9; i++)

	{

		d1 += c.charAt(i)*(10-i);

	}

	if (d1 == 0){

		alert("CPF Invalido");

		this.document.frm.cpf.focus();


		return false;

	}

	d1 = 11 - (d1 % 11);

	if (d1 > 9) d1 = 0;

	if (dv.charAt(0) != d1)

	{

		alert("CPF Invalido");

		this.document.frm.cpf.focus();

		return false;

	}


	d1 *= 2;

	for (i = 0; i < 9; i++)

	{

		d1 += c.charAt(i)*(11-i);

	}

	d1 = 11 - (d1 % 11);

	if (d1 > 9) d1 = 0;

	if (dv.charAt(1) != d1)

	{

		alert("CPF Invalido");

		this.document.frm.cpf.focus();

		return false;

	}

	return true;

}
//-->

<!--
function validacnpj(){

	//TODO: implementar
	return true;

}
//-->

// permite a entrada apenas de valores numéricos nos campos
function somente_numero(campo){
	var digits="0123456789-./"
	var campo_temp 
	for (var i=0;i<campo.value.length;i++){
	  campo_temp=campo.value.substring(i,i+1)	
	  if (digits.indexOf(campo_temp)==-1){
		    campo.value = campo.value.substring(0,i);
		    break;
	   }
	}
}

// formata máscara de valores
function formataValor(fld, milSep, decSep, e) {
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode == 13) return true;  // Enter
	key = String.fromCharCode(whichCode);  // Get key value from key code
	if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
	len = fld.value.length;
	for(i = 0; i < len; i++)
		if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
	aux = '';
	for(; i < len; i++)
		if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
	aux += key;
	len = aux.length;
	if (len == 0) fld.value = '';
	if (len == 1) fld.value = '0'+ decSep + '0' + aux;
	if (len == 2) fld.value = '0'+ decSep + aux;
	if (len > 2) {
		aux2 = '';
		for (j = 0, i = len - 3; i >= 0; i--) {
			if (j == 3) {
				aux2 += milSep;
				j = 0;
			}
			aux2 += aux.charAt(i);
			j++;
		}
		fld.value = '';
		len2 = aux2.length;
		for (i = len2 - 1; i >= 0; i--)
			fld.value += aux2.charAt(i);
		fld.value += decSep + aux.substr(len - 2, len);
	}
	return false;
}

<!--
function makepage () {

remote = window.open("","remotewin",' toolbar=1, location=0, status=1, menubar=1, scrollbars=1, resizable=0, width=550, height=500');
remote.document.close()
   if (remote.opener == null) remote.opener = window;
     remote.opener.name = "opener";

history.go(0);
}
//-->

function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function soNumeros(v){
    return v.replace(/\D/g,"")
}

function telefone(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    //v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}

function vcpf(v){
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
                                             //de novo (para o segundo bloco de números)
    v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
    return v
}

function prot(v){
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{4})(\d)/,"$1-$2")       //Coloca um traço entre o quarto e o quinto dígitos
	v=v.replace(/(\d{2})(\d{3})/,"$1-$2")       //Coloca um traço entre o quarto e o quinto dígitos
	v=v.replace(/(\d{3})(\d{1,1})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
    return v
}

function data(v){
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{2})(\d)/,"$1/$2")       //Coloca uma barra entre o segundo e o terceiro dígitos
    v=v.replace(/(\d{2})(\d)/,"$1/$2")       //Coloca uma barra entre o quarto e o quinto dígitos
                                             //de novo (para o segundo bloco de números)
    return v
}


function cpostal(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/(\d{5})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}

function cnpj(v){
    v=v.replace(/\D/g,"")                           //Remove tudo o que não é dígito
    v=v.replace(/^(\d{2})(\d)/,"$1.$2")             //Coloca ponto entre o segundo e o terceiro dígitos
    v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") //Coloca ponto entre o quinto e o sexto dígitos
    v=v.replace(/\.(\d{3})(\d)/,".$1/$2")           //Coloca uma barra entre o oitavo e o nono dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")              //Coloca um hífen depois do bloco de quatro dígitos
    return v
}



function romanos(v){
    v=v.toUpperCase()             //Maiúsculas
    v=v.replace(/[^IVXLCDM]/g,"") //Remove tudo o que não for I, V, X, L, C, D ou M
    while(v.replace(/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/,"")!="")
        v=v.replace(/.$/,"")
    return v
}

function site(v){
    v=v.replace(/^http:\/\/?/,"")
    dominio=v
    caminho=""
    if(v.indexOf("/")>-1)
        dominio=v.split("/")[0]
        caminho=v.replace(/[^\/]*/,"")
    dominio=dominio.replace(/[^\w\.\+-:@]/g,"")
    caminho=caminho.replace(/[^\w\d\+-@:\?&=%\(\)\.]/g,"")
    caminho=caminho.replace(/([\?&])=/,"$1")
    if(caminho!="")dominio=dominio.replace(/\.+$/,"")
    v="http://"+dominio+caminho
    return v
}




