function tamanhoFonte(dvId,tm){
	document.getElementById(dvId).style.fontSize = tm+"px";
}
<!-- Função que conta diferença entre duas datas decrescente -->
function getTime() {
now = new Date();
y2k = new Date("Oct 9 2008 14:00:00");
days = (y2k - now) / 1000 / 60 / 60 / 24;
daysRound = Math.floor(days);
hours = (y2k - now) / 1000 / 60 / 60 - (24 * daysRound);
hoursRound = Math.floor(hours);
minutes = (y2k - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
minutesRound = Math.floor(minutes);
seconds = (y2k - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
secondsRound = Math.round(seconds);
sec = (secondsRound == 1) ? "segundo" : " segundos";
min = (minutesRound == 1) ? " minuto" : " minutos";
hr = (hoursRound == 1) ? " hora" : " horas, ";
dy = (daysRound == 1)  ? " dia" : " dias"
document.timeForm.input2.value =  daysRound  + dy ; 
document.timeForm.input3.value = hoursRound + hr;
document.timeForm.input4.value = minutesRound + min;
document.timeForm.input5.value = secondsRound + sec;
newtime = window.setTimeout("getTime();", 1000);
}
//
w = window;
wt = w.top;
wo = wt.opener;
///
/////
function DataParaTexto(dptDt) {
	a1 = new Date ;
	a1 = a1.getFullYear() ;
	a =dptDt.getFullYear() ;
	if (a < ((a1 % 100) + 10)) { a = a + parseInt(a1/100) * 100 ; }
	else if (a < 100) { a = a + (parseInt(a1/100)-1) * 100 ; }
	return (dptDt.getDate()+100+'').slice(1)+"/"+(dptDt.getMonth()+101+'').slice(1)+"/"+a ;
}
function TextoParaData(tpdV) {
	a1 = new Date ;
	tpdDia = parseFloat("0"+tpdV);
	tpdMes = a1.getMonth()+1;
	tpdAno = a1.getFullYear();
	tpdS = "/";
	if (tpdV.indexOf(tpdS)<0) tpdS = "-" ;
	if (tpdV.indexOf(tpdS)<0) tpdS = "." ;
	if (tpdV.indexOf(tpdS)<0) tpdS = " " ;
	tpdP = tpdV.indexOf(tpdS) ;
	if (tpdP>=0) {
		tpdDia = parseFloat("0"+tpdV.substr(0,tpdP));
		tpdV = (tpdV+" ").slice(tpdP+1);
		tpdMes = parseFloat("0"+tpdV);
		tpdP = tpdV.indexOf(tpdS) ;
		if (tpdP!=-1) {
			tpdMes = parseFloat('0'+tpdV.substr(0,tpdP));
			tpdV = (tpdV+" ").slice(tpdP+1);
			tpdAno = parseFloat("0"+tpdV)+"";
			if (tpdAno.length < 4) {
				a1 = a1.getFullYear();
				if (tpdAno > (a1%100)+10 && tpdAno.length < 3) a1 = a1 - 100;
				tpdAno = (a1+"").substr(0, 4 - tpdAno.length) + tpdAno;
			}
			tpdAno = parseFloat("0"+tpdAno);
		}
	}
	tpd31 = "1/3/5/7/8/10/12/" ;
	if (tpdDia > 31 || tpdDia < 1 || tpdMes > 12 || tpdMes < 1) {
	} else if (tpdDia > 30 && tpd31.indexOf(tpdMes+"/")==-1) {
	} else if (tpdDia > 29 && tpdMes==2) {
	} else if (tpdDia > 28 && tpdMes==2 && (tpdAno/4)!=parseInt(tpdAno/4)) {
	} else {
		tpd = new Date(tpdAno,tpdMes-1,tpdDia) ;
		return tpd;
	}
	return false;
}
function ValidaData(w,vd) {
	if (w.ValidaDataStatus) return ;
	if (vd.value=="") {
	} else	if (!TextoParaData(vd.value)) { 
		w.ValidaDataStatus = true;
		vd.select();
		w.alert("Data inválida!");
		vd.focus();
		vd.select();
		w.ValidaDataStatus = false;
	} else {
		vd.value = DataParaTexto(TextoParaData(vd.value));
	}
}
function mudaDia(mdDt, mdDia) {
	return mudaData(mdDt, mdDia, 0, 0);
}
function mudaMes(mdDt, mdMes) {
	return mudaData(mdDt, 0, mdMes, 0);
}
function mudaAno(mdDt, mdAno) {
	return mudaData(mdDt, 0, 0, mdAno);
}
function mudaData(mdDt, mdDia, mdMes, mdAno) {
	mdDt = TextoParaData(mdDt);
	mdDt = new Date (mdDt.getFullYear()+mdAno, mdDt.getMonth()+mdMes, mdDt.getDate()+mdDia );
	return mdDt.getDate() + "/" + (mdDt.getMonth()+1) + "/" + mdDt.getFullYear();
}
function SomaData(w,obj,sdc,sds,sdt) {
	if (! obj) return;
	if (! obj.form) return;
	if (! sdc) return;
	if (sdc=="") return;
	if (! obj.form(sdc)) return;
	sdv = obj.form(sdc).value;
	sdp = sdv.indexOf("/") ;
	if (sdp!=-1) {
		sdDia = parseFloat(sdv.substring(0,sdp));
		sdv = sdv.slice(sdp+1);
		sdp = sdv.indexOf("/") ;
		if (sdp!=-1) {
			sdMes = parseFloat('0'+sdv.substring(0,sdp));
			sdAno = parseFloat(sdv.slice(sdp+1));
			sda1 = new Date ;
			sda1 = sda1.getFullYear() ;
			if (sdAno < ((sda1 % 100) + 10)) { 
				sdAno =parseFloat(sdAno) +  parseInt(sda1/100) * 100 ;
			} else if (sdAno<100) { 
				sdAno =parseFloat(sdAno) +  parseInt(sda1/100) * 100 - 100 ;
			}
			sd31 = "1/3/5/7/8/10/12/" ;
			if (sdDia>31 || sdMes>12) {
			} else if (sdDia>30 && sd31.indexOf(sdMes+"/")==-1) {
			} else if (sdDia>29 && sdMes==2) {
			} else if (sdDia>28 && sdMes==2 && (sdAno/4)!=parseInt(sdAno/4)) {
			} else {
				if (! sds) sds = 1;
				if (! sdt) sdt = 'D';
				sdt = sdt.toUpperCase();
				if (sdt=='D') sdDia += sds;
				else if (sdt=='S') sdDia += sds * 7;
				else if (sdt=='Q') sdDia += sds * 15;
				else if (sdt=='M') sdMes += sds;
				else if (sdt=='B') sdMes += sds*2;
				else if (sdt=='T') sdMes += sds*3;
				else if (sdt=='A') sdAno += sds;
				else if (sdt=='1') sdMes += sds*1;
				else if (sdt=='2') sdMes += sds*2;
				else if (sdt=='3') sdMes += sds*3;
				else if (sdt=='6') sdMes += sds*6;
				else if (sdt=='12') sdAno += sds;
				sd = new Date(sdAno,sdMes-1,sdDia) ;
				obj.form(sdc).value = DataParaTexto(sd) ;
			}
		}
	}
	return false;
}
function DataExtenso(deDt) {
	if (deDt=="") return "";
	deDt = TextoParaData(deDt) ;
	if (deDt.getDay()==0) deE = "Domingo";
	if (deDt.getDay()==1) deE = "Segunda-feira";
	if (deDt.getDay()==2) deE = "Terça-feira";
	if (deDt.getDay()==3) deE = "Quarta-feira";
	if (deDt.getDay()==4) deE = "Quinta-feira";
	if (deDt.getDay()==5) deE = "Sexta-feira";
	if (deDt.getDay()==6) deE = "Sábado";
	deE += ", "+deDt.getDate()+" de ";
	if (deDt.getMonth()==0) deE += "Janeiro";
	if (deDt.getMonth()==1) deE += "Fevereiro";
	if (deDt.getMonth()==2) deE += "Março";
	if (deDt.getMonth()==3) deE += "Abril";
	if (deDt.getMonth()==4) deE += "Maio";
	if (deDt.getMonth()==5) deE += "Junho";
	if (deDt.getMonth()==6) deE += "Julho";
	if (deDt.getMonth()==7) deE += "Agosto";
	if (deDt.getMonth()==8) deE += "Setembro";
	if (deDt.getMonth()==9) deE += "Outubro";
	if (deDt.getMonth()==10) deE += "Novembro";
	if (deDt.getMonth()==11) deE += "Dezembro";
	deE += " de "+deDt.getFullYear();
	return deE;
}
calendario = "<"+"TITLE>Calendário<"+"/TITLE>";
calendario += "<"+"BODY topmargin=0 leftmargin=0 rightmargin=0 bottomargin=0 style='font-family:verdana,arial,times; font-size:10px; background-color:lightblue;'>";
calendario += "<"+"CENTER><"+"TABLE cellspacing=0 cellpading=0><"+"FORM><"+"TR><"+"TD>";
calendario += "<"+"BUTTON onClick='wo.calendarioMove(w,1,-1)'><"+"<"+"/BUTTON>";
calendario += "<"+"INPUT name=dia maxlenght=2 title='Dia' style='width:20' onPropertyChange='wo.calendarioCkDia(w)'>";
calendario += "<"+"BUTTON onClick='wo.calendarioMove(w,1,1)'>><"+"/BUTTON>";
calendario += "<"+"/TD><"+"TD>";
calendario += "<"+"BUTTON onClick='wo.calendarioMove(w,2,-1)'><"+"<"+"/BUTTON>";
calendario += "<"+"SELECT name=mes title='Mês' style='font-size:10' onPropertyChange='wo.calendarioAltera(w)'>";
calendario += "<"+"OPTION value=1>Janeiro<"+"OPTION value=2>Fevereiro<"+"OPTION value=3>Março";
calendario += "<"+"OPTION value=4>Abril<"+"OPTION value=5>Maio<"+"OPTION value=6>Junho";
calendario += "<"+"OPTION value=7>Julho<"+"OPTION value=8>Agosto<"+"OPTION value=9>Setembro";
calendario += "<"+"OPTION value=10>Outubro<"+"OPTION value=11>Novembro<"+"OPTION value=12>Dezembro";
calendario += "<"+"/SELECT>";
calendario += "<"+"BUTTON onClick='wo.calendarioMove(w,2,1)'>><"+"/BUTTON>";
calendario += "<"+"/TD><"+"TD>";
calendario += "<"+"BUTTON onClick='wo.calendarioMove(w,3,-1)'><"+"<"+"/BUTTON>";
calendario += "<"+"INPUT name=ano maxlenght=4 title='Ano' style='width:35' onPropertyChange='wo.calendarioAltera(w)'>";
calendario += "<"+"BUTTON onClick='wo.calendarioMove(w,3,1)'>><"+"/BUTTON>";
calendario += "<"+"/TD><"+"/TR><"+"TR><"+"TD colspan=3 id=Datas><"+"/TD><"+"/TR><"+"/FORM><"+"/TABLE><"+"/CENTER><"+"/BODY>";
calendarioBordaIni = "<"+"TABLE WIDTH=100%"+"><"+"TR"+"><"+"TD style='font-family:verdana,arial,times; font-size:11px'"+">Calendário <"+"/td"+">";
calendarioBordaIni += "<"+"td width='1%' align=right"+"><"+"button onclick='wo.janClose(w.jNo)'"+">X<"+"/button";
calendarioBordaIni += "><"+"/td"+"><"+"/tr"+"><"+"tr"+"><"+"td colspan=2"+">";
calendarioBordaFim = "<"+"/td"+"><"+"/tr"+"></"+"table"+">";
function DataAtual(cW,obj,dac) {
	daf = obj.form;
	da = new Date ;
	daf[dac].value = da.getDate() + "/" + (da.getMonth() + 1) + "/" + da.getFullYear() ;
	daObj = daf[dac];
	selN = janela(cW,daObj,0,260,160);
	selI = 0
	while ((! cW["janela"+selN] || ! cW["janela"+selN].document) && selI<10000) selI++;
	if (selI>=10000) { cW.alert("Não consegui abrir a janela!"); return }
	j = cW["janela"+selN];
	j.document.write("<STYLE>"+document.getElementsByTagName("style")[0].innerHTML+"</STYLE>") ;
	j.wo = window;
	j.w = j.window;
	if (j!=j.top) j.document.write(calendarioBordaIni);
	j.document.write(calendario);
	if (j!=j.top) j.document.write(calendarioBordaFim);
	j.fecha=false;
	f = j.document.forms[0];
	daDt = new Date ;
	j.mover = true;
	f["dia"].value = daDt.getDate();
	f["mes"].value = (daDt.getMonth() + 1 );
	f["ano"].value = daDt.getFullYear();
	j.mover = false;
	j.jNo = selN;
	j.daObj = daObj;
	j.d = f["dia"];
	calendarioAltera(j);
	f["dia"].focus();
}
function calendarioAltera(j) {
	if (j.mover) return;
	f = j.document.forms[0];
	if (f["mes"].value=="") return;
	if (f["ano"].value=="") return;
	if (f["dia"].value=="") f["dia"].value=="1";
	aD = parseInt(f["dia"].value);
	aM = parseInt(f["mes"].value);
	aA = parseInt(f["ano"].value);
	aH = "";
	aH += "<"+"TABLE width='95%' cellspacing=0 cellpading=0 style='font-family:verdana,arial,times; font-size:10px;cursor:hand'>";
	aH += "<"+"TR>";
	aH += "<"+"TD title='Domingo' style='color:red'>Dom<"+"/TD>";
	aH += "<"+"TD title='Segunda-feira'>Seg<"+"/TD>";
	aH += "<"+"TD title='Terça-feira'>Ter<"+"/TD>";
	aH += "<"+"TD title='Quarta-feira'>Qua<"+"/TD>";
	aH += "<"+"TD title='Quinta-feira'>Qui<"+"/TD>";
	aH += "<"+"TD title='Sexta-feira'>Sex<"+"/TD>";
	aH += "<"+"TD title='Sábado'>Sáb<"+"/TD>";
	aH += "<"+"/TR>";
	aH += "<"+"TR>";
	aDia = 1;
	aDt = new Date (aA, aM-1, aDia);
	aDS = aDt.getDay();
	for (a=0; a < aDS; a++) aH += "<"+"TD>&nbsp;<"+"/TD>";
	while ((aM-1)==aDt.getMonth() && aDia<32) {
		if (aDS==6 && aDia>1) aH += "<"+"TR>";
		aDS = aDt.getDay();
		if (aDS==0) aC = " style='color:red'";
		else aC = "";
		aH += "<"+"TD id='dia+"+aDia+"' onClick='fecha=true;d.value="+aDia+";' class='l2' onMouseOver='wo.calendarioLiga(this)' onMouseOut='wo.calendarioDesliga(w,this)' align=center "+aC+">" + aDia + "<"+"/TD>";		
		if (aDS==6) aH += "<"+"/TR>";
		aDia++;
		aDt = new Date(aA, (aM-1), aDia);
	}
	aH += "<"+"/TR>";
	aH += "<"+"/TABLE>";
	j.document.getElementById("Datas").innerHTML = aH ;
	calendarioCkDia(j);
}
function calendarioMove(j,mT,mV) {
	f = j.document.forms[0];
	mD = parseInt(f["dia"].value);
	mM = parseInt(f["mes"].value);
	mA = parseInt(f["ano"].value);
	if (mT==1) mD += mV;
	else if (mT==2) mM += mV ;
	else if (mT==3) mA += mV ;
	mDt = new Date( mA, mM-1, mD );
	f["dia"].value = mDt.getDate() ;
	if (f["mes"].value != mDt.getMonth()+1 || f["ano"].value != mDt.getFullYear()) {
		j.mover = true;
		f["mes"].value = mDt.getMonth()+1 ;
		j.mover = false;
		f["ano"].value = mDt.getFullYear();
	}
}
function calendarioCkDia(j) {
	f = j.document.forms[0];
	cdD = f["dia"].value;
	cdO = j.document.getElementsByTagName("TD");
	if (cdO.length>13) {
		for (cdI=13; cdI < cdO.length; cdI++) {
			if (cdO(cdI).innerHTML==cdD) {
				cdO(cdI).className = 'l1';
			} else {
				cdO(cdI).className = 'l2';
			}
		}
	}
	if (j.daObj) {
		cdDtRet = ((100+parseInt(f["dia"].value))+"").substr(1,2);
		cdDtRet += "/"+((100+parseInt(f["mes"].value))+"").substr(1,2);
		cdDtRet += "/"+f["ano"].value;
		j.daObj.value = cdDtRet;
		if (j.fecha) janClose(j.jNo);
	}
}
function calendarioLiga (ob) {
	ob.className='l0';
}
function calendarioDesliga (j, ob) {
	f = j.document.forms[0];
	dD = f["dia"].value;
	if (ob.innerHTML==dD) ob.className = 'l1';
	else ob.className='l2';
}
///

function janela(jWin,jObj,jPag,jWidth,jHeight,jCenter){
	jW = window;
	if (! jW["janNo"]) jW["janNo"]=0;
	jNo = ++jW["janNo"];
	jW["jW"+jNo] = jWin;
	if (jObj) jW["jO"+jNo] = jObj;
	if (!jPag) jPag = "../_templ/branco.html";
	if (!jWidth) jWidth = 100;
	if (!jHeight) jHeight = 200;
	if (jWin.document.body) {
		jWidthM = cadW(jWin.document.body);
		jHeightM = cadH(jWin.document.body);
		if (jHeight <= jHeightM && jWidth <= jWidthM) {
			if (jCenter || ! jObj) {
				jTop = parseInt((jHeightM-jHeight)/2);
				jLeft = parseInt((jWidthM-jWidth)/2);
			} else {
				jTop = cadH(jObj);
				jLeft = 0;
				jObj1 = jObj;
				while (jObj1.tagName!="BODY" && jObj1) {
					if ("  TD SPAN DIV".indexOf(" "+jObj1.tagName)<0) {
						if (jObj1.offsetTop>=0 && jObj1.offsetLeft>=0) {
							jTop += jObj1.offsetTop;
							jLeft += jObj1.offsetLeft;
						}
					}
					jObj1 = jObj1.parentNode;
				}
				if (jHeight+jTop>jHeightM) jTop = jHeightM-jHeight;
				if (jWidth+jLeft>jWidthM) jLeft = jWidthM-jWidth;
			}
			if (jTop<0) jTop = 0;
			if (jLeft<0) jLeft = 0;
			if (jWidth<50) jWidth = 50;
			if (jHeight<50) jHeight = 50;
			jHTML = "<IFRAME src='"+jPag+"' id='janela"+jNo+"' style='position:absolute;width:"+jWidth+";height:"+jHeight+";top:"+jTop+";left:"+jLeft+";border-style:solid;border-width:1' frameborder=0 scrollbars=no></IFRAME>";
			jWin.document.body.insertAdjacentHTML('beforeEnd', jHTML);
			jW["jT"+jNo] = 1;
			return jNo;
		}
	}
	jWidthM = screen.width;
	jHeightM = screen.height;
	if (jHeight > jHeightM) jHeight = jHeightM;
	if (jWidth > jWidthM) jWidth = jWidthM;
	jTop = parseInt((jHeightM-jHeight)/2);
	jLeft = parseInt((jWidthM-jWidth)/2);
	jTop = "scrollbars=yes,resizable=yes,status=no,top="+jTop+",left="+jLeft+",width="+jWidth+",height="+jHeight;
	jW["jT"+jNo] = 2;
	jWin["janela"+jNo] = jWin.open(jPag, "_blank", jTop) ;
	return jNo;
}
function janClose(jNo) {
	w = window;
	if (w["jT"+jNo]) {
		if (w["jT"+jNo]==1) {
			w["jW"+jNo].document.getElementById("janela"+jNo).removeNode(true);
		} else {
			w["jW"+jNo]["janela"+jNo].close();
			w["jW"+jNo]["janela"+jNo]=undefined;
		}
		w["jT"+jNo]=undefined;
		w["jW"+jNo]=undefined;
		w["jO"+jNo]=undefined;
	}
	if (jNo==w["janNo"]) w["janNo"]--;
	return undefined;
}
//
function cadH(chO,chV) {
	if (! chV) chV = 0;
	if (chO.offsetHeight) return chO.offsetHeight+chV;
	else return (chO.innerHeight+chV)+'px';
}
function cadW(chO,chV) {
	if (! chV) chV = 0;
	if (chO.offsetWidth) return (chO.offsetWidth+chV);
	else return (chO.innerWidth+chV)+'px';
}
function _MaskAPI(){
	this.version = "0.4a";
	this.instances = 0;
	this.objects = {};
}
MaskAPI = new _MaskAPI();

function Mask(m, t){
	this.mask = m;
	this.type = (typeof t == "string") ? t : "string";
	this.error = [];
	this.errorCodes = [];
	this.value = "";
	this.strippedValue = "";
	this.allowPartial = false;
	this.id = MaskAPI.instances++;
	this.ref = "MaskAPI.objects['" + this.id + "']";
	MaskAPI.objects[this.id] = this;
}

// define the attach(oElement) function
Mask.prototype.attach = function (o){
	$addEvent(o, "onkeydown", "return " + this.ref + ".isAllowKeyPress(event, this);", true);
	$addEvent(o, "onkeyup", "return " + this.ref + ".getKeyPress(event, this);", true);
	$addEvent(o, "onblur", "this.value = " + this.ref + ".format(this.value);", true);
}

Mask.prototype.isAllowKeyPress = function (e, o){
	if( this.type != "string" ) return true;
	var xe = new qEvent(e);

	if( ((xe.keyCode > 47) && (o.value.length >= this.mask.length)) && !xe.ctrlKey ) return false;
	return true;
}

Mask.prototype.getKeyPress = function (e, o, _u){
	this.allowPartial = true;
	var xe = new qEvent(e);

//	var k = String.fromCharCode(xe.keyCode);

	if( (xe.keyCode > 47) || (_u == true) || (xe.keyCode == 8 || xe.keyCode == 46) ){
		var v = o.value, d;
		if( xe.keyCode == 8 || xe.keyCode == 46 ) d = true;
		else d = false

		if( this.type == "number" ) this.value = this.setNumber(v, d);
		else if( this.type == "date" ) this.value = this.setDateKeyPress(v, d);
		else this.value = this.setGeneric(v, d);

		o.value = this.value;
	}
	/* */

	this.allowPartial = false;
	return true;
}

Mask.prototype.format = function (s){
	if( this.type == "number" ) this.value = this.setNumber(s);
	else if( this.type == "date" ) this.value = this.setDate(s);
	else this.value = this.setGeneric(s);
	return this.value;
}

Mask.prototype.throwError = function (c, e, v){
	this.error[this.error.length] = e;
	this.errorCodes[this.errorCodes.length] = c;
	if( typeof v == "string" ) return v;
	return true;
}

Mask.prototype.setGeneric = function (_v, _d){
	var v = _v, m = this.mask;
	var r = "x#*", rt = [], nv = "", t, x, a = [], j=0, rx = {"x": "A-Za-z", "#": "0-9", "*": "A-Za-z0-9" };

	// strip out invalid characters
	v = v.replace(new RegExp("[^" + rx["*"] + "]", "gi"), "");
	if( (_d == true) && (v.length == this.strippedValue.length) ) v = v.substring(0, v.length-1);
	this.strippedValue = v;
	var b=[];
	for( var i=0; i < m.length; i++ ){
		// grab the current character
		x = m.charAt(i);
		// check to see if current character is a mask, escape commands are not a mask character
		t = (r.indexOf(x) > -1);
		// if the current character is an escape command, then grab the next character
		if( x == "!" ) x = m.charAt(i++);
		// build a regex to test against
		if( (t && !this.allowPartial) || (t && this.allowPartial && (rt.length < v.length)) ) rt[rt.length] = "[" + rx[x] + "]";
		// build mask definition table
		a[a.length] = { "chr": x, "mask": t };
	}

	var hasOneValidChar = false;
	// if the regex fails, return an error
	if( !this.allowPartial && !(new RegExp(rt.join(""))).test(v) ) return this.throwError(1, "The value \"" + _v + "\" must be in the format " + this.mask + ".", _v);
	// loop through the mask definition, and build the formatted string
	else if( (this.allowPartial && (v.length > 0)) || !this.allowPartial ){
		for( i=0; i < a.length; i++ ){
			if( a[i].mask ){
				while( v.length > 0 && !(new RegExp(rt[j])).test(v.charAt(j)) ) v = (v.length == 1) ? "" : v.substring(1);
				if( v.length > 0 ){
					nv += v.charAt(j);
					hasOneValidChar = true;
				}
				j++;
			} else nv += a[i].chr;
			if( this.allowPartial && (j > v.length) ) break;
		}
	}
	
	if( this.allowPartial && !hasOneValidChar ) nv = "";
	if( this.allowPartial ){
		if( nv.length < a.length ) this.nextValidChar = rx[a[nv.length].chr];
		else this.nextValidChar = null;
	}

	return nv;
}

Mask.prototype.setNumber = function(_v, _d){
	var v = String(_v).replace(/[^\d.-]*/gi, ""), m = this.mask;
	// make sure there's only one decimal point
	v = v.replace(/\./, "d").replace(/\./g, "").replace(/d/, ".");

	// check to see if an invalid mask operation has been entered
	if( !/^[\$]?((\$?[\+-]?([0#]{1,3},)?[0#]*(\.[0#]*)?)|([\+-]?\([\+-]?([0#]{1,3},)?[0#]*(\.[0#]*)?\)))$/.test(m) )
		return this.throwError(1, "An invalid mask was specified for the \nMask constructor.", _v);

	if( (_d == true) && (v.length == this.strippedValue.length) ) v = v.substring(0, v.length-1);

	if( this.allowPartial && (v.replace(/[^0-9]/, "").length == 0) ) return v;
	this.strippedValue = v;

	if( v.length == 0 ) v = NaN;
	var vn = Number(v);
	if( isNaN(vn) ) return this.throwError(2, "The value entered was not a number.", _v);

	// if no mask, stop processing
	if( m.length == 0 ) return v;

	// get the value before the decimal point
	var vi = String(Math.abs((v.indexOf(".") > -1 ) ? v.split(".")[0] : v));
	// get the value after the decimal point
	var vd = (v.indexOf(".") > -1) ? v.split(".")[1] : "";
	var _vd = vd;

	var isNegative = (vn != 0 && Math.abs(vn)*-1 == vn);

	// check for masking operations
	var show = {
		"$" : /^[\$]/.test(m),
		"(": (isNegative && (m.indexOf("(") > -1)),
		"+" : ( (m.indexOf("+") != -1) && !isNegative )
	}
	show["-"] = (isNegative && (!show["("] || (m.indexOf("-") != -1)));


	// replace all non-place holders from the mask
	m = m.replace(/[^#0.,]*/gi, "");

	/*
		make sure there are the correct number of decimal places
	*/
	// get number of digits after decimal point in mask
	var dm = (m.indexOf(".") > -1 ) ? m.split(".")[1] : "";
	if( dm.length == 0 ){
		vi = String(Math.round(Number(vi)));
		vd = "";
	} else {
		// find the last zero, which indicates the minimum number
		// of decimal places to show
		var md = dm.lastIndexOf("0")+1;
		// if the number of decimal places is greater than the mask, then round off
		if( vd.length > dm.length ) vd = String(Math.round(Number(vd.substring(0, dm.length + 1))/10));
		// otherwise, pad the string w/the required zeros
		else while( vd.length < md ) vd += "0";
	}

	/*
		pad the int with any necessary zeros
	*/
	// get number of digits before decimal point in mask
	var im = (m.indexOf(".") > -1 ) ? m.split(".")[0] : m;
	im = im.replace(/[^0#]+/gi, "");
	// find the first zero, which indicates the minimum length
	// that the value must be padded w/zeros
	var mv = im.indexOf("0")+1;
	// if there is a zero found, make sure it's padded
	if( mv > 0 ){
		mv = im.length - mv + 1;
		while( vi.length < mv ) vi = "0" + vi;
	}


	/*
		check to see if we need commas in the thousands place holder
	*/
	if( /[#0]+,[#0]{3}/.test(m) ){
		// add the commas as the place holder
		var x = [], i=0, n=Number(vi);
		while( n > 999 ){
			x[i] = "00" + String(n%1000);
			x[i] = x[i].substring(x[i].length - 3);
			n = Math.floor(n/1000);
			i++;
		}
		x[i] = String(n%1000);
		vi = x.reverse().join(",");
	}


	/*
		combine the new value together
	*/
	if( (vd.length > 0 && !this.allowPartial) || ((dm.length > 0) && this.allowPartial && (v.indexOf(".") > -1) && (_vd.length >= vd.length)) ){
		v = vi + "." + vd;
	} else if( (dm.length > 0) && this.allowPartial && (v.indexOf(".") > -1) && (_vd.length < vd.length) ){
		v = vi + "." + _vd;
	} else {
		v = vi;
	}

	if( show["$"] ) v = this.mask.replace(/(^[\$])(.+)/gi, "$") + v;
	if( show["+"] ) v = "+" + v;
	if( show["-"] ) v = "-" + v;
	if( show["("] ) v = "(" + v + ")";
	return v;
}

Mask.prototype.setDate = function (_v){
	var v = _v, m = this.mask;
	var a, e, mm, dd, yy, x, s;

	// split mask into array, to see position of each day, month & year
	a = m.split(/[^mdy]+/);
	// split mask into array, to get delimiters
	s = m.split(/[mdy]+/);
	// convert the string into an array in which digits are together
	e = v.split(/[^0-9]/);
	
	if( s[0].length == 0 ) s.splice(0, 1);

	for( var i=0; i < a.length; i++ ){
		x = a[i].charAt(0).toLowerCase();
		if( x == "m" ) mm = parseInt(e[i], 10)-1;
		else if( x == "d" ) dd = parseInt(e[i], 10);
		else if( x == "y" ) yy = parseInt(e[i], 10);
	}

	// if year is abbreviated, guess at the year
	if( String(yy).length < 3 ){
		yy = 2000 + yy;
		if( (new Date()).getFullYear()+20 < yy ) yy = yy - 100;
	}

	// create date object
	var d = new Date(yy, mm, dd);

	if( d.getDate() != dd ) return this.throwError(1, "An invalid day was entered.", _v);
	else if( d.getMonth() != mm ) return this.throwError(2, "An invalid month was entered.", _v);

	var nv = "";

	for( i=0; i < a.length; i++ ){
		x = a[i].charAt(0).toLowerCase();
		if( x == "m" ){
			mm++;
			if( a[i].length == 2 ){
				mm = "0" + mm;
				mm = mm.substring(mm.length-2);
			}
			nv += mm;
		} else if( x == "d" ){
			if( a[i].length == 2 ){
				dd = "0" + dd;
				dd = dd.substring(dd.length-2);
			}
			nv += dd;
		} else if( x == "y" ){
			if( a[i].length == 2 ) nv += d.getYear();
			else nv += d.getFullYear();
		}

		if( i < a.length-1 ) nv += s[i];
	}

	return nv;
}

Mask.prototype.setDateKeyPress = function (_v, _d){
	var v = _v, m = this.mask, k = v.charAt(v.length-1);
	var a, e, c, ml, vl, mm = "", dd = "", yy = "", x, p, z;

	if( _d == true ){
		while( (/[^0-9]/gi).test(v.charAt(v.length-1)) ) v = v.substring(0, v.length-1);
		if( (/[^0-9]/gi).test(this.strippedValue.charAt(this.strippedValue.length-1)) ) v = v.substring(0, v.length-1);
		if( v.length == 0 ) return "";
	}

	// split mask into array, to see position of each day, month & year
	a = m.split(/[^mdy]/);
	// split mask into array, to get delimiters
	s = m.split(/[mdy]+/);
	// mozilla wants to add an empty array element which needs removed
	if( s[0].length == 0 ) s.splice(0,1);
	// convert the string into an array in which digits are together
	e = v.split(/[^0-9]/);
	// position in mask
	p = (e.length > 0) ? e.length-1 : 0;
	// determine what mask value the user is currently entering
	c = a[p].charAt(0);
	// determine the length of the current mask value
	ml = a[p].length;

	for( var i=0; i < e.length; i++ ){
		x = a[i].charAt(0).toLowerCase();
		if( x == "m" ) mm = parseInt(e[i], 10)-1;
		else if( x == "d" ) dd = parseInt(e[i], 10);
		else if( x == "y" ) yy = parseInt(e[i], 10);
	}
	
	
	var nv = "";
	var j=0;

	for( i=0; i < e.length; i++ ){
		x = a[i].charAt(0).toLowerCase();
	
		if( x == "m" ){
			z = ((/[^0-9]/).test(k) && c == "m");
			mm++;
			if( (e[i].length == 2 && mm < 10) || (a[i].length == 2 && c != "m") || (mm > 1 && c == "m") || (z && a[i].length == 2) ){
				mm = "0" + mm;
				mm = mm.substring(mm.length-2);
			}
			vl = String(mm).length;
			ml = 2;
			nv += mm;
		} else if( x == "d" ){
			z = ((/[^0-9]/).test(k) && c == "d");
			if( (e[i].length == 2 && dd < 10) || (a[i].length == 2 && c != "d") || (dd > 3 && c == "d") || (z && a[i].length == 2) ){
				dd = "0" + dd;
				dd = dd.substring(dd.length-2);
			}
			vl = String(dd).length;
			ml = 2;
			nv += dd;
		} else if( x == "y" ){
			z = ((/[^0-9]/).test(k) && c == "y");
			if( c == "y" ) yy = String(yy);
			else {
				if( a[i].length == 2 ) yy = d.getYear();
				else yy = d.getFullYear();
			}
			if( (e[i].length == 2 && yy < 10) || (a[i].length == 2 && c != "y") || (z && a[i].length == 2) ){
				yy = "0" + yy;
				yy = yy.substring(yy.length-2);
			}
			ml = a[i].length;
			vl = String(yy).length;
			nv += yy;
		}

		if( ((ml == vl || z) && (x == c) && (i < s.length)) || (i < s.length && x != c ) ) nv += s[i];
	}

	if( nv.length > m.length ) nv = nv.substring(0, m.length);

	this.strippedValue = (nv == "NaN") ? "" : nv;

	return this.strippedValue;
}

function qEvent(e){
	// routine for NS, Opera, etc DOM browsers
	if( window.Event ){
		var isKeyPress = (e.type.substring(0,3) == "key");

		this.keyCode = (isKeyPress) ? parseInt(e.which, 10) : 0;
		this.button = (!isKeyPress) ? parseInt(e.which, 10) : 0;
		this.srcElement = e.target;
		this.type = e.type;
		this.x = e.pageX;
		this.y = e.pageY;
		this.screenX = e.screenX;
		this.screenY = e.screenY;
		if( document.layers ){
			this.altKey = ((e.modifiers & Event.ALT_MASK) > 0);
			this.ctrlKey = ((e.modifiers & Event.CONTROL_MASK) > 0);
			this.shiftKey = ((e.modifiers & Event.SHIFT_MASK) > 0);
			this.keyCode = this.translateKeyCode(this.keyCode);
		} else {
			this.altKey = e.altKey;
			this.ctrlKey = e.ctrlKey;
			this.shiftKey = e.shiftKey;
		}
	// routine for Internet Explorer DOM browsers
	} else {
		e = window.event;
		this.keyCode = parseInt(e.keyCode, 10);
		this.button = e.button;
		this.srcElement = e.srcElement;
		this.type = e.type;
		if( document.all ){
			this.x = e.clientX + document.body.scrollLeft;
			this.y = e.clientY + document.body.scrollTop;
		} else {
			this.x = e.clientX;
			this.y = e.clientY;
		}
		this.screenX = e.screenX;
		this.screenY = e.screenY;
		this.altKey = e.altKey;
		this.ctrlKey = e.ctrlKey;
		this.shiftKey = e.shiftKey;
	}
	if( this.button == 0 ){
		this.setKeyPressed(this.keyCode);
		this.keyChar = String.fromCharCode(this.keyCode);
	}
}

// this method will try to remap the keycodes so the keycode value
// returned will be consistent. this doesn't work for all cases,
// since some browsers don't always return a unique value for a
// key press.
qEvent.prototype.translateKeyCode = function (i){
	var l = {};
	// remap NS4 keycodes to IE/W3C keycodes
	if( !!document.layers ){
		if( this.keyCode > 96 && this.keyCode < 123 ) return this.keyCode - 32;
		l = {
			96:192,126:192,33:49,64:50,35:51,36:52,37:53,94:54,38:55,42:56,40:57,41:48,92:220,124:220,125:221,
			93:221,91:219,123:219,39:222,34:222,47:191,63:191,46:190,62:190,44:188,60:188,45:189,95:189,43:187,
			61:187,59:186,58:186,
			"null": null
		}
	}
	return (!!l[i]) ? l[i] : i;
}

// try to determine the actual value of the key pressed
qEvent.prototype.setKP = function (i, s){
	this.keyPressedCode = i;
	this.keyNonChar = (typeof s == "string");
	this.keyPressed = (this.keyNonChar) ? s : String.fromCharCode(i);
	this.isNumeric = (parseInt(this.keyPressed, 10) == this.keyPressed);
	this.isAlpha = ((this.keyCode > 64 && this.keyCode < 91) && !this.altKey && !this.ctrlKey);
	return true;
}

// try to determine the actual value of the key pressed
qEvent.prototype.setKeyPressed = function (i){
	var b = this.shiftKey;
	if( !b && (i > 64 && i < 91) ) return this.setKP(i + 32);
	if( i > 95 && i < 106 ) return this.setKP(i - 48);
	
	switch( i ){
		case 49: case 51: case 52: case 53: if( b ) i = i - 16; break;
		case 50: if( b ) i = 64; break;
		case 54: if( b ) i = 94; break;
		case 55: if( b ) i = 38; break;
		case 56: if( b ) i = 42; break;
		case 57: if( b ) i = 40; break;
		case 48: if( b ) i = 41; break;
		case 192: if( b ) i = 126; else i = 96; break;
		case 189: if( b ) i = 95; else i = 45; break;
		case 187: if( b ) i = 43; else i = 61; break;
		case 220: if( b ) i = 124; else i = 92; break;
		case 221: if( b ) i = 125; else i = 93; break;
		case 219: if( b ) i = 123; else i = 91; break;
		case 222: if( b ) i = 34; else i = 39; break;
		case 186: if( b ) i = 58; else i = 59; break;
		case 191: if( b ) i = 63; else i = 47; break;
		case 190: if( b ) i = 62; else i = 46; break;
		case 188: if( b ) i = 60; else i = 44; break;

		case 106: case 57379: i = 42; break;
		case 107: case 57380: i = 43; break;
		case 109: case 57381: i = 45; break;
		case 110: i = 46; break;
		case 111: case 57378: i = 47; break;

		case 8: return this.setKP(i, "[backspace]");
		case 9: return this.setKP(i, "[tab]");
		case 13: return this.setKP(i, "[enter]");
		case 16: case 57389: return this.setKP(i, "[shift]");
		case 17: case 57390: return this.setKP(i, "[ctrl]");
		case 18: case 57388: return this.setKP(i, "[alt]");
		case 19: case 57402: return this.setKP(i, "[break]");
		case 20: return this.setKP(i, "[capslock]");
		case 32: return this.setKP(i, "[space]");
		case 91: return this.setKP(i, "[windows]");
		case 93: return this.setKP(i, "[properties]");

		case 33: case 57371: return this.setKP(i*-1, "[pgup]");
		case 34: case 57372: return this.setKP(i*-1, "[pgdown]");
		case 35: case 57370: return this.setKP(i*-1, "[end]");
		case 36: case 57369: return this.setKP(i*-1, "[home]");
		case 37: case 57375: return this.setKP(i*-1, "[left]");
		case 38: case 57373: return this.setKP(i*-1, "[up]");
		case 39: case 57376: return this.setKP(i*-1, "[right]");
		case 40: case 57374: return this.setKP(i*-1, "[down]");
		case 45: case 57382: return this.setKP(i*-1, "[insert]");
		case 46: case 57383: return this.setKP(i*-1, "[delete]");
		case 144: case 57400: return this.setKP(i*-1, "[numlock]");
	}
	
	if( i > 111 && i < 124 ) return this.setKP(i*-1, "[f" + (i-111) + "]");

	return this.setKP(i);
}

// define the addEvent(oElement, sEvent, sCmd, bAppend) function
function $addEvent(o, _e, c, _b){
	var e = _e.toLowerCase(), b = (typeof _b == "boolean") ? _b : true, x = (o[e]) ? o[e].toString() : "";
	// strip out the body of the function
	x = x.substring(x.indexOf("{")+1, x.lastIndexOf("}"));
	x = ((b) ? (x + c) : (c + x)) + "\n";
	return o[e] = (!!window.Event) ? new Function("event", x) : new Function(x);
}
//
function formataCep(valor) {
	cepMascara = new Mask("#####-###");
	cepMascara.attach(valor);
}

function formataMoeda(valor) {
	moedaMascara = new Mask("#,###.00", "number");
	moedaMascara.attach(valor);
}

function formataData(valor) {
	dataMascara = new Mask("dd/mm/yyyy", "date");
	dataMascara.attach(valor);
}

function formataFone(valor) {
	foneMascara = new Mask("(##)####-####");
	foneMascara.attach(valor);
}

function trocaCidade(id_est,objeto,cid_sel)
{
	var obj = document.getElementById(objeto);
	for (i=obj.options.length;i>0;i--){
		if(IsIE())obj.options.remove(i);
		else obj.options[i] = null;
	}
	obj.options[0] = new Option('Aguarde...','0');
	obj.selectedIndex = 0;
	obj.disabled=true;
	if (obj.id == "id_cidade_nasc"){
		parent.topo.location.href = '../publico/troca_cidade.php?id_estado='+id_est+'&obj='+objeto+'&cid_sel='+cid_sel;
	}else{
		parent.rodafun.location.href = '../publico/troca_cidade.php?id_estado='+id_est+'&obj='+objeto+'&cid_sel='+cid_sel;
	}
	
}
function verifFormCurrency(valor,obj)
{
	if(!valor)
	{
		if(obj)
			valor=obj.value;
	}
	
	if(valor == "")
		valor = '0';
	
	if(valor.indexOf(".")>-1)
		return true;
	else if(valor.indexOf(",")>-1)
		while(valor.indexOf(",")>-1)
			valor=valor.replace(",",".");
	else if(valor != "")
		valor= valor + '.00'
	
	if(obj)
		obj.value=valor;
			
	return false;	
}

function abre_div(div,valor)
{
	if(valor==1)
		document.getElementById(div).style.display="block";
	else
		document.getElementById(div).style.display="none";
}

function CursoCompleto(N,V)
{
	mes_t=document.getElementById("mes_conclusao["+N+"]");
	ano_t=document.getElementById("ano_conclusao["+N+"]");
	if(V)
	{
		mes_t.value = '';
		ano_t.value = '';
		mes_t.disabled=true;
		ano_t.disabled=true;
	}
	else
	{
		mes_t.disabled=false;
		ano_t.disabled=false;
		mes_t.focus();
	}
	
}




function textarea(campo,maxi,label,falta)
	{
		campo=document.getElementById(campo);
		if(falta != "")
		document.getElementById(falta).value=maxi-campo.value.length;

		if(campo.value.length >= maxi)
			{
				if (IsIE())
				  window.event.key=0;
				
				
				 
				alert("O campo " + label + "deve ter no maximo " + maxi + " caracteres!");
				
				a=campo.value.substring(0,maxi);
				campo.value=a;
				
				if(falta != "")
				document.getElementById(falta).value=maxi-campo.value.length;

				campo.focus();
				return false;
			}
		
	}

function mostra_data(){
		data = new Date();
		dia = data.getDay();
		
		if(dia==0)
			week = "Domingo";
		if(dia ==1)
			week = "Segunda-Feira";
		if(dia ==2)
			week = "Terça-Feira";
		if(dia ==3)
			week = "Quarta-Feira";
		if(dia ==4)
			week = "Quinta-Feira";
		if(dia ==5)
			week = "Sexta-Feira";
		if(dia ==6)
			week = "Sábado";
		
		dia = data.getDate();
		mes = data.getMonth()+1;
		
	
		if(mes == 1)
			mes = "Janeiro";
		if(mes == 2)
			mes = "Fevereiro";
		if(mes == 3)
			mes = "Março";
		if(mes == 4)
			mes = "Abril";
		if(mes == 5)
			mes = "Maio";
		if(mes == 6)
			mes = "Junho";
		if(mes == 7)
			mes = "Julho";
		if(mes == 8)
			mes = "Agosto";
		if(mes == 9)
			mes = "Setembro";
		if(mes == 10)
			mes = "Outubro";
		if(mes == 11)
			mes = "Novembro";
		if(mes == 12)
			mes = "Dezembro";
		
		ano = data.getFullYear();
		document.write(week + ", " + dia + " de " + mes + " de " + ano);
}
var mvtmp;
function movemrq_down()
{
	if(browser()=="IE")
		tMrq= 50;
	else
		tMrq= 20;

if(document.getElementById('mrq').style.marginTop.indexOf('px')>-1)
	{
		h = document.getElementById('mrq').style.marginTop.substr(0,document.getElementById('mrq').style.marginTop.length -2);
	}
else
	{
		h = document.getElementById('mrq').style.marginTop;
	}
	
	if(h=='')
		h=0;
	
		
		if(document.getElementById('Conteudo_1'))
		{
		HC=document.getElementById('Conteudo_1').clientHeight;
		if((HC==0)||(HC=='undefined'))
			HC =document.getElementById('Conteudo_1').offsetHeight;
		}
		else
		{
		HC=document.getElementById('Conteudo_Login').clientHeight;
		if((HC==0)||(HC=='undefined'))
			HC =document.getElementById('Conteudo_Login').offsetHeight;
		}


		HM=document.getElementById('mrq_t').clientHeight;
		if((HM==0)||(HM=='undefined'))
				HM=document.getElementById('mrq_t').offsetHeight;


	if((-h) + HC < HM )
		{
		document.getElementById('mrq').style.marginTop = h - 2 +'px' ;
		mvtmp = setTimeout('movemrq_down()',tMrq);
		}
	else
		{
			clearTimeout(mvtmp);
		}
}

function movemrq_up()
{
	if(browser()=="IE")
		tMrq= 50;
	else
		tMrq= 20;
if(document.getElementById('mrq').style.marginTop.indexOf('px')>-1)
	{
		h = document.getElementById('mrq').style.marginTop.substr(0,document.getElementById('mrq').style.marginTop.length -2);
	}
else
	{
		h = document.getElementById('mrq').style.marginTop;
	}
	
	if(h < 0)
		{
		y=new Number(h);
		y+=2;
		if(y>0)
			y=0;
		document.getElementById('mrq').style.marginTop = y +'px' ;
		mvtmp = setTimeout('movemrq_up()',tMrq);
		}
	else
		{
			clearTimeout(mvtmp);
		}	
}

function browser()
{
	B = navigator.userAgent;
			if((B.indexOf("Mac")> -1)&&(B.indexOf("MSIE") > -1))
				{
				bw = "MacIE";
				}
			else if(B.indexOf("Netscape") > -1)
				{
				bw = "Netscape";
				}
			
			else if(B.indexOf("Opera") > -1)
				{
				bw = "Opera";
				}
			else if((B.indexOf("MSIE") > -1) && (B.indexOf("Opera") == -1))
				{
				bw = "IE";
				}
			else if((B.indexOf("Mozilla") > -1)&& (B.indexOf("MSIE") == -1)&&(B.indexOf("Opera") == -1))
				{
				bw= "Mozilla";
				}
			return bw;
}

function IsIE()
{
	Brw = navigator.appName;
			if(Brw.indexOf("Microsoft") > -1)
				return true;
			else
				 return false;	
	
}

