function doNumber() {
	var whichcode = window.event.keyCode;
	if (whichcode < 48) whichcode = 0;
	if (whichcode > 57) whichcode = 0;
	window.event.keyCode = whichcode;
}

function tbr(txt) {
	if( (txt != "undefined") && (txt != "") ) {
		return false;
	}
	else {
		return true;
	}
}

function obrigatorio(campo, label) {
	if( tbr(campo.value) ) {
		campo.focus();
		alert("Por favor, preencha o campo: " + label);
		return false;
	}
	else {
		return true;
	}
}

function limpaCampos(form) {
	for( x=0; x<form.length; x++ ) {
		if( form[x].type == 'text' ) {
			form[x].value = '';
		}
	}
}

function validata(obj) {
	if(event.keyCode == 0 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 46 || event.keyCode == 16 || event.shiftKey) {return false}
	if (obj.tagName=='INPUT') {
		if (obj.value.length == 2 || obj.value.length == 5) obj.value+="/";
		if (obj.value.length == 8 && obj.maxLength == 10) {
			ano = obj.value.substr(6, 2);
			if (ano<18) {
				ano = '20'+ano;
				obj.value = obj.value.substr(0, 6) + ano;
				tab(obj);
				return;
			}
			else {
				if (ano==20 || ano==19) { return false; }
				ano = '19'+ano;
				obj.value = obj.value.substr(0, 6) + ano;
				tab(obj);
				return;
			}
		}
		if (obj.value.length==obj.maxLength) {tab(obj); return;}
	}
	if (obj.tagName=='SPAN') {
		cData = obj.innerText;
		if (cData.length == 2 || cData.length == 5) cData+="/"; obj.innerText = cData;
		if (cData.length == 8) {
			ano = cData.substr(6, 2);
			if (ano<18) {
				ano = '20'+ano;
				cData = cData.substr(0, 6) + ano;
				obj.innerText = cData;
			}
			else {
				if (ano==20 || ano==19) { return false; }
				ano = '19'+ano;
				cData = cData.substr(0, 6) + ano;
				obj.innerText = cData;
			}
		}
	}
}

function tab(obj) {	
	if (obj.value.length>=obj.maxLength) {
		var a=-1, b=0;
		while (b < obj.form.length && a == -1) {
			if ((b+1) == obj.form.length) { obj.blur(); return false; }
			if (obj.form[b] == obj) { obj.blur(); obj.form[b+1].focus(); }
			b++;
		}
	}
}

function TabFocus(obj){
	camada = obj.parentElement;
	continua = true;
		while (continua){
			while (camada.tagName != "DIV" )
				camada = camada.parentElement;			
			if (camada.style.overflow != "hidden")
				continua = false;			
			else
				camada = camada.parentElement;
		}	
	orelhas = camada.all.item("tabBtPaleta")	
	if (orelhas != null) {
		tabelas = camada.all.item("tabPaleta")
		for (p = 0; p < tabelas.length; p++){
			if ((tabelas[p].style.display == 'none') && (tabelas[p].contains(obj)))
				controleTab(orelhas[p]);
		}
	}
	obj.focus();
}

function forceTab(obj) {		
	try {
		var a=-1, b=0;	
		if (obj.ignoratab == '1') {
			obj.blur();
			hideOp();
			return;	
		}
		while (b < obj.form.length && a == -1) {
			if ((b+1) == obj.form.length) { obj.blur(); return false; }
			if (obj.form[b] == obj){
				while (obj.form[b+1].type == 'button' || obj.form[b+1].type == 'hidden' || obj.form[b+1].readOnly == true) {
					b++;
					aa = 0;
					if ((b+1) == obj.form.length) { obj.blur(); hideOp(); return false; }
				}
				obj.blur();
				campo = obj.form[b+1];
				TabFocus(campo);
			}
			b++;
		}
	}
	catch(err){
		AvisoErro("FORCETAB: ",err);
	}
}

function formatTel (cmp)
{
	if ((cmp.value).length == 2) { cmp.value = '('+ cmp.value +')'; }
	if ((cmp.value).length == 8) { cmp.value += '-' } 
}

function formatCep (cmp)
{
	if ((cmp.value).length == 2) { cmp.value += '.' }
	if ((cmp.value).length == 6) { cmp.value += '-' }	
}

function modCampo (cmp)
{
	objFrm = document.cadastro
	if ((objFrm.cmp_editados.value).indexOf(cmp.name)) { objFrm.cmp_editados.value = cmp.name +','+ objFrm.cmp_editados.value  }		
}

// =======================	VIEW PIC - ZOOM NAS IMAGENS ============================
function viewPic(img)
{ 	
    picfile = new Image(); 
    picfile.src =(img); 
    fileCheck(img); 
}

function fileCheck(img)
{ 	
    if( (picfile.width!=0) && (picfile.height!=0) )
    { 
        makeWindow(img); 
    }
    else 
    {
        funzione="fileCheck('"+img+"')"; 
        intervallo=setTimeout(funzione,10); 
    }
}
function makeWindow(img)
{ 	
    ht = picfile.height;
    wd = picfile.width; 

    var args= "height=" + ht + ",innerHeight=" + ht;
    args += ",width=" + wd + ",innerWidth=" + wd;
    if (window.screen) 
    { 
        var avht = screen.availHeight; 
        var avwd = screen.availWidth;
        var xcen = (avwd - wd) / 2; 
        var ycen = (avht - ht) / 2;
        args += ",left=" + xcen + ",screenX=" + xcen;
        args += ",top=" + ycen + ",screenY=" + ycen + ",resizable=yes"; 	
    }

	popwin=window.open("","_blank",args)
	popwin.document.open()
	popwin.document.write('<html><head><title>'+img+'</title></head><body bgcolor=white scroll=no topmargin=0 leftmargin=0 rightmargin=0 bottomargin=0 marginheight=0 marginwidth=0><div style="position: absolute; top:0px;left:0px"><a href="javascript:window.close()"><img src="'+img+'" width="'+wd+'" height="'+ht+'" border="0"></a></div></body></html>')
	popwin.document.close()
}

// -----------------------------------------------------------------------------------------------------
// NOTICIAS
velocidade=1;
function noticias(){
	try {
		with (document.getElementById('scroller')) {
			if (scrollTop<=(scrollHeight-(clientHeight+5))) { scrollTop+=velocidade; }
			else { scrollTop = 0; }
		}
	}
	catch (erro) {
		return false;
//		alert(erro.description);
	}
}
setInterval("noticias()",25);

// -----------------------------------------------------------------------------------------------------

// =========================================================================
