function txtBoxFormat(objeto, sMask, evtKeyPress) {
    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;


if(document.all) { // Internet Explorer
    nTecla = evtKeyPress.keyCode;
} else if(document.layers) { // Nestcape
    nTecla = evtKeyPress.which;
} else {
    nTecla = evtKeyPress.which;
    if (nTecla == 8 || nTecla == 0) {
        return true;
    }
}

    sValue = objeto.value;

    // Limpa todos os caracteres de formatação que
    // já estiverem no campo.
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( " ", "" );
    sValue = sValue.toString().replace( " ", "" );
    fldLen = sValue.length;
    mskLen = sMask.length;

    i = 0;
    nCount = 0;
    sCod = "";
    mskLen = fldLen;

    while (i <= mskLen) {
      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

      if (bolMask) {
        sCod += sMask.charAt(i);
        mskLen++; }
      else {
        sCod += sValue.charAt(nCount);
        nCount++;
      }

      i++;
    }

    objeto.value = sCod;

    if (nTecla != 8) { // backspace
      if (sMask.charAt(i-1) == "9") { // apenas números...
        return ((nTecla > 47) && (nTecla < 58)); }
      else { // qualquer caracter...
        return true;
      }
    }
    else {
      return true;
    }
  }

function lib_bwcheck(){ 
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie7 || this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var bw=new lib_bwcheck()

var numScrollPages = 1;
var transitionOut = 1;
var transitionIn = 2;
var slideAcceleration = 0.6;
var transitionOnload = 1 

var px = bw.ns4||window.opera?"":"px";

if(document.layers){ 
	scrX= innerWidth; scrY= innerHeight;
	onresize= function(){if(scrX!= innerWidth || scrY!= innerHeight){history.go(0)} }
}

function scrollerobj(obj,nest){
	nest = (!nest)?"":'document.'+nest+'.'
	this.elm = bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):document.getElementById(obj)
	this.css = bw.ns4?this.elm:this.elm.style
	this.doc = bw.ns4?this.elm.document:document
	this.obj = obj+'scrollerobj'; eval(this.obj+'=this')
	this.x = (bw.ns4||bw.opera5)?this.css.left:this.elm.offsetLeft
	this.y = (bw.ns4||bw.opera5)?this.css.top:this.elm.offsetTop
	this.w = (bw.ie4||bw.ie5||bw.ie6||bw.ie7||bw.ns6)?this.elm.offsetWidth:bw.ns4?this.elm.clip.width:bw.opera5?this.css.pixelWidth:0
	this.h = (bw.ie4||bw.ie5||bw.ie6||bw.ie7||bw.ns6)?this.elm.offsetHeight:bw.ns4?this.elm.clip.height:bw.opera5?this.css.pixelHeight:0
}

scrollerobj.prototype.moveTo = function(x,y){
	if(x!=null){this.x=x; this.css.left=x+px}
	if(y!=null){this.y=y; this.css.top=y+px}
}
scrollerobj.prototype.moveBy = function(x,y){this.moveTo(this.x+x,this.y+y)}
scrollerobj.prototype.hideIt = function(){this.css.visibility='hidden'}
scrollerobj.prototype.showIt = function(){this.css.visibility='visible'}

var scrollTimer = null;

function scroll(step){
	clearTimeout(scrollTimer);
	if ( !busy && (step<0&&activePage.y+activePage.h>scroller1.h || step>0&&activePage.y<0) ){
		activePage.moveBy(0,step);
		scrollTimer = setTimeout('scroll('+step+')',40);
	}
}
function stopScroll(){
	clearTimeout(scrollTimer);
}

var activePage = null;
var busy = 0;
function activate(num){
	if (activePage!=pages[num] && !busy){
		busy = 1;
		if (transitionOut==0 || !bw.opacity){ activePage.hideIt(); activateContinue(num); }
		else if (transitionOut==1) activePage.blend('hidden', 'activateContinue('+num+')');
	}
}
function activateContinue(num){
	busy = 1;
	activePage = pages[num];
	activePage.moveTo(0,0);
	if (transitionIn==0 || !bw.opacity){ activePage.showIt(); busy=0; }
	else if (transitionIn==1) activePage.blend('visible', 'busy=0');
	else if (transitionIn==2) activePage.slide(0, slideAcceleration, 40, 'busy=0');
}

scrollerobj.prototype.slide = function(target, acceleration, time, fn){
	this.slideFn= fn?fn:null;
	this.moveTo(0,scroller1.h);
	if (bw.ie4&&!bw.mac) this.css.filter = 'alpha(opacity=100)';
	if (bw.ns6) this.css.MozOpacity = 1;
	this.showIt();
	this.doSlide(target, acceleration, time);
}
scrollerobj.prototype.doSlide = function(target, acceleration, time){
	this.step = Math.round(this.y*acceleration);
	if (this.step<1) this.step = 1;
	if (this.step>this.y) this.step = this.y;
	this.moveBy(0, -this.step);
	if (this.y>0) this.slideTim = setTimeout(this.obj+'.doSlide('+target+','+acceleration+','+time+')', time);
	else {	
		eval(this.slideFn);
		this.slideFn = null;
	}
}

scrollerobj.prototype.blend= function(vis, fn){
	if (bw.ie5||bw.ie6 && !bw.mac) {
		if (vis=='visible') this.css.filter= 'blendTrans(duration=0.9)';
		else this.css.filter= 'blendTrans(duration=0.6)';
		this.elm.onfilterchange = function(){ eval(fn); };
		this.elm.filters.blendTrans.apply();
		this.css.visibility= vis;
		this.elm.filters.blendTrans.play();
	}
	else if (bw.ns6 || bw.ie&&!bw.mac){
		this.css.visibility= 'visible';
		vis=='visible' ? this.fadeTo(100, 7, 40, fn) : this.fadeTo(0, 9, 40, fn);
	}
	else {
		this.css.visibility= vis;
		eval(fn);
	}
}

scrollerobj.prototype.op= 100;
scrollerobj.prototype.opacityTim= null;
scrollerobj.prototype.setOpacity= function(num){
	this.css.filter= 'alpha(opacity='+num+')';
	this.css.MozOpacity= num/100;
	this.op= num;
}

scrollerobj.prototype.fadeTo= function(target, step, time, fn){
	clearTimeout(this.opacityTim);
	this.opacityFn= fn?fn:null;
	this.op = target==100 ? 0 : 100;
	this.fade(target, step, time);
}

scrollerobj.prototype.fade= function(target, step, time){
	if (Math.abs(target-this.op)>step){
		target>this.op? this.setOpacity(this.op+step):this.setOpacity(this.op-step);
		this.opacityTim= setTimeout(this.obj+'.fade('+target+','+step+','+time+')', time);
	}
	else {
		this.setOpacity(target);
		eval(this.opacityFn);
		this.opacityFn= null;
	}
}

var pageslidefadeLoaded = 0;
function initPageSlideFade(){
	scroller1 = new scrollerobj('divScroller1');
	pages = new Array();
	for (var i=0; i<numScrollPages; i++){
		pages[i] = new scrollerobj('dynPage'+i, 'divScroller1');
		pages[i].moveTo(0,0);
	}
//	bw.opacity = ( bw.ie && !bw.ie4 && navigator.userAgent.indexOf('Windows')>-1 ) || bw.ns6
//	if (bw.ie5||bw.ie6 && !bw.mac) pages[0].css.filter= 'blendTrans(duration=0.6)'; // Preloads the windows filters.
	if (transitionOnload) activateContinue(0);
	else{
		activePage = pages[0];
		activePage.showIt();
	}
	if (bw.ie) for(var i=0;i<document.links.length;i++) document.links[i].onfocus=document.links[i].blur;
	pageslidefadeLoaded = 1;
}

function imprime(n2) {
	var x; 	var y;
	w=500; h=400;
	x = (screen.width-w)/2;	y = (screen.height-h)/2;
	arquivo="imprimir.asp?n1=cursos&n2="+n2
	
	window.open(arquivo,'','scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=no,width='+w+',height='+h+',left='+x+',top='+y+',window.focus()');
}

function retorna_dimensoes(){
	var xScroll, yScroll;
//	xScroll = document.documentElement["scrollWidth"];
//	yScroll = document.documentElement["scrollHeight"];

//	xScroll = document.body.scrollWidth;
//	yScroll = document.body.scrollHeight;

	try{
		xScrollb = document.documentElement["scrollWidth"];
		yScrollb = document.documentElement["scrollHeight"];

		xScroll = document.documentElement["offsetWidth"];
		yScroll = document.documentElement["offsetHeight"];

//	debug("xscroll="+xScroll+" yscroll="+yScroll+" xscrollb="+xScrollb+" yscrollb="+yScrollb)

		if(xScrollb>xScroll) xScroll=xScrollb;
		if(yScrollb>yScroll) yScroll=yScrollb;

//	debug(yScroll);

	} catch (e) { debug(e); }

	
	//alert(xScroll);
	
	return Array(xScroll,yScroll);
}

function aguarde() {
	valores=retorna_dimensoes();	

	/*selects=document.getElementsByTagName("select");
	for(i=0; i<selects.length; i++) selects[i].style.visibility="hidden";*/

	/*travatela1=document.getElementById("trava_tela");
	travatela1.style.width="100%";
	travatela1.style.height=parseInt(valores[1])+"px";
	travatela1.style.display="block";*/
	
	reposiciona("foto_grande");
}

tm="";
function reposiciona(a) {
	quadro=document.getElementById(a);
	quadro.style.display="";

	valores=retorna_dimensoes();
	topo1=document.documentElement["clientHeight"];

	IpopTop=(topo1-quadro.offsetHeight)/2;

	quadro.style.top=(IpopTop+document.documentElement["scrollTop"])+"px";

	tm=setTimeout("reposiciona('"+a+"')",100);
}

// trava tela fim!

function mostra_foto_nome(t) {
	
	var	img	= document.getElementById("recebe_foto");
	img.src="imgs/aguarde.gif";
	aguarde();	
	img.src="imgs/up/"+t;	
}

function mostra_foto(t) {
	var anterior;
	var proximo;
	var foto = vetor_imagem[t];
	var foto_ante = vetor_imagem[t-1];
	var foto_prox = vetor_imagem[t+1];
	var legenda = vetor_legenda[t];
	
	var ante_disabled 	= '';
	var ante_cursor		= 'pointer';
	var ante_evento		= '';
	var prox_disabled 	= '';
	var prox_cursor		= 'pointer';
	var prox_evento		= '';	
	
	img=document.getElementById("recebe_foto");
	img.src="imgs/aguarde.gif";	
	
	aguarde();
	
	if (t > 0){
		anterior = parseInt(t) - 1;
		}else{
			anterior = quant_fotos;
			/*ante_disabled 	= '_disabled';
			ante_cursor		= 'default';
			ante_evento		= '';*/
	}
	
	if (t < quant_fotos){
		proximo =  parseInt(t) + 1;
		}else{
			proximo = 0;
			/*prox_disabled 	= '_disabled';
			prox_cursor		= 'default';
			prox_evento		= '';*/
	}	
	
	var scroll_imagem = document.getElementById('scroll_imagem');
	var scroll_imagem2 = document.getElementById('scroll_imagem2');
	var div_legenda = document.getElementById('div_legenda');

	img.src="imgs/up/"+foto;
	scroll_imagem.innerHTML = "<img class=\"voltar\" src=\"imgs/bt_voltar.gif\" onclick=\"javascript:abre_foto('"+anterior+"')\" alt=\"\" />";
	scroll_imagem2.innerHTML = "<img class=\"avancar\" src=\"imgs/bt_avancar.gif\" onclick=\"javascript:abre_foto('"+proximo+"')\" alt=\"\" />";
	div_legenda.innerHTML = legenda;	
	
}

function abre_foto(t){
	
	var anterior;
	var proximo;
	var foto = vetor_imagem[t];
	var foto_ante = vetor_imagem[t-1];
	var foto_prox = vetor_imagem[t+1];
	var legenda = vetor_legenda[t];
	
	var ante_disabled 	= '';
	var ante_cursor		= 'pointer';
	var ante_evento		= '';
	var prox_disabled 	= '';
	var prox_cursor		= 'pointer';
	var prox_evento		= '';

	img=document.getElementById("recebe_foto");

	img.src="imgs/aguarde.gif";
	
	if (t > 0){
		anterior = parseInt(t) - 1;
		}else{
			anterior = quant_fotos;
			/*ante_disabled 	= '_disabled';
			ante_cursor		= 'default';
			ante_evento		= '';*/
	}
	
	if (t < quant_fotos){
		proximo =  parseInt(t) + 1;
		}else{
			proximo = 0;
			/*prox_disabled 	= '_disabled';
			prox_cursor		= 'default';
			prox_evento		= '';*/
	}	
	
	var scroll_imagem = document.getElementById('scroll_imagem');
	var scroll_imagem2 = document.getElementById('scroll_imagem2');
	var div_legenda = document.getElementById('div_legenda');
	

	img.src="imgs/up/"+foto;
	scroll_imagem.innerHTML = "<img class=\"voltar\" src=\"imgs/bt_voltar.gif\" onclick=\"javascript:abre_foto('"+anterior+"')\" alt=\"\" />";
	scroll_imagem2.innerHTML = "<img class=\"avancar\" src=\"imgs/bt_avancar.gif\" onclick=\"javascript:abre_foto('"+proximo+"')\" alt=\"\" />";
	            
	div_legenda.innerHTML = legenda;
}

	
	

function fecha_aguarde() {
	
	selects=document.getElementsByTagName("select");
	for(i=0; i<selects.length; i++) selects[i].style.visibility="";
	
	document.getElementById("trava_tela").style.display="none";
	document.getElementById("foto_grande").style.display="none";
	clearTimeout(tm);
}

function mostra_div(show){
	var el1 = document.getElementById(show);
	if (el1.style.display == 'none'){
		el1.style.display = 'block';
		}else{
			el1.style.display = 'none';
	}
}

// inicio trava tela
function txtBoxFormat(objeto, sMask, evtKeyPress) {
    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;


if(document.all) { // Internet Explorer
    nTecla = evtKeyPress.keyCode;
} else if(document.layers) { // Nestcape
    nTecla = evtKeyPress.which;
} else {
    nTecla = evtKeyPress.which;
    if (nTecla == 8) {
        return true;
    }
}

    sValue = objeto.value;

    // Limpa todos os caracteres de formatação que
    // já estiverem no campo.
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( " ", "" );
    sValue = sValue.toString().replace( " ", "" );
    fldLen = sValue.length;
    mskLen = sMask.length;

    i = 0;
    nCount = 0;
    sCod = "";
    mskLen = fldLen;

    while (i <= mskLen) {
      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

      if (bolMask) {
        sCod += sMask.charAt(i);
        mskLen++; }
      else {
        sCod += sValue.charAt(nCount);
        nCount++;
      }

      i++;
    }

    objeto.value = sCod;

    if (nTecla != 8) { // backspace
      if (sMask.charAt(i-1) == "9") { // apenas números...
        return ((nTecla > 47) && (nTecla < 58)); }
      else { // qualquer caracter...
        return true;
      }
    }
    else {
      return true;
    }
  }

function retorna_dimensoes(){
	var xScroll, yScroll;
//	xScroll = document.documentElement["scrollWidth"];
//	yScroll = document.documentElement["scrollHeight"];

//	xScroll = document.body.scrollWidth;
//	yScroll = document.body.scrollHeight;

	try{
		xScrollb = document.documentElement["scrollWidth"];
		yScrollb = document.documentElement["scrollHeight"];

		xScroll = document.documentElement["offsetWidth"];
		yScroll = document.documentElement["offsetHeight"];

//	debug("xscroll="+xScroll+" yscroll="+yScroll+" xscrollb="+xScrollb+" yscrollb="+yScrollb)

		if(xScrollb>xScroll) xScroll=xScrollb;
		if(yScrollb>yScroll) yScroll=yScrollb;

//	debug(yScroll);

	} catch (e) { debug(e); }

	return Array(xScroll,yScroll);
}

function aguarde() {
	valores=retorna_dimensoes();	

	/*selects=document.getElementsByTagName("select");
	for(i=0; i<selects.length; i++) selects[i].style.visibility="hidden";*/

	travatela1=document.getElementById("trava_tela");
	travatela1.style.width="100%";
	travatela1.style.height=parseInt(valores[1])+"px";
	travatela1.style.display="";
	
	reposiciona("foto_grande");
}

tm="";
function reposiciona(a) {
	quadro=document.getElementById(a);
	quadro.style.display="";

	valores=retorna_dimensoes();
	topo1=document.documentElement["clientHeight"];

	IpopTop=(topo1-quadro.offsetHeight)/2;

	quadro.style.top=(IpopTop+document.documentElement["scrollTop"])+"px";

	tm=setTimeout("reposiciona('"+a+"')",100);
}

// trava tela fim!