// ===================================================================================
// FUNÇÕES CADASTRADAS
// ===================================================================================
// ABRIR UMA NOVA JANELA
// LIMITA O NÚMERO DE CARACTERES NO TEXT AREA
// DESABILITA SUBMIT DEPOIS DE CLICADO
// BARRA DE STATUS
// ===================================================================================



//
// Abrir em uma nova janela
//
var win = null;
function NovaJanela(mypage,myname,w,h,scroll,resizable,location,menubar,status,toolbar){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resizable+',location='+location+',menubar='+menubar+',status='+status+',toolbar='+toolbar+''
win = window.open(mypage,myname,settings)
}
//Para usar colocar no HREF
//<a href="index.htm" onClick="NovaJanela(this.href,'boleto','700','480','yes','no','no','no','yes','yes');return false">link</a>
// 1º yes ativa o scrollbars >> quantos for adicionando vai ativando as demais settings
// scroll , resizable , location , menubar , status , toolbar
//



//
// LIMITA O NÚMERO DE CARACTERES NO TEXT AREA - INICIO
//


var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}


function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> caracteres restantes para o limite deste campo'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}
//
// LIMITA O NÚMERO DE CARACTERES NO TEXT AREA - FINAL
//




//
// DESABILITA SUBMIT DEPOIS DE CLICADO
//
function submitonce(theform){
	//if IE 4+ or NS 6+
	if (document.all||document.getElementById){
	//screen thru every element in the form, and hunt down "submit" and "reset"
	for (i=0;i<theform.length;i++){
	var tempobj=theform.elements[i]
		if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
		//disable em
		tempobj.disabled=true
		}
	}
}
//
// COMO USAR: <form name="form" method="post" action="" onSubmit="submitonce(this)">
//




//
// BARRA DE STATUS - INICIO
//

var hellotext=""
var thetext=""
var started=false
var step=0
var times=1
 function welcometext()
    {
      times--
      if (times==0)
      {
        if (started==false)
        {
          started = true;
          window.status = hellotext;
          setTimeout("anim()",1);
        }
        thetext = hellotext;
      }
    }
 function showstatustext(txt)
    {
      thetext = txt;
      setTimeout("welcometext()",4000)
      times++
    }
 function anim()
    {
     step++
      if (step==7) {step=1}
      if (step==1) {window.status='==='+thetext+'==='}
      if (step==2) {window.status='=='+thetext+'=='}
      if (step==3) {window.status='='+thetext+'='}
      if (step==4) {window.status='=='+thetext+'=='}
      if (step==5) {window.status='==='+thetext+'==='}
      if (step==6) {window.status='=='+thetext+'=='}
      setTimeout("anim()",200);
    }
welcometext();

//
// BARRA DE STATUS - FINAL
//
