// ===================================================================================
// FUNÇÕES CADASTRADAS
// ===================================================================================
// ABRIR UMA NOVA JANELA
// LIMITA O NÚMERO DE CARACTERES NO TEXT AREA
// DESABILITA SUBMIT DEPOIS DE CLICADO
// BARRA DE STATUS
// TAG EM FLASH
// JANELA MODAL
// ===================================================================================



//
// 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 - INICIO  //////////////////////////////////////////////////////
//
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()",400000)
      times++
    }
 function anim()
    {
     step++
      if (step==3) {step=1}
      if (step==1) {window.status='Contenu : Gestão inteligente de conteúdo on-line'}
      if (step==2) {window.status='Sistema desenvolvido por Wmidia.com'}
      setTimeout("anim()",4500);
    }
welcometext();


/* Tratamento do flash, desabilitada para o funcionamento do video
//
// TRATAR FLASH EM IE - INICIO   /////////////////////////////////////////////////////////////////////
//
// qdo entra na pagina
window.onload = function(){
	if (document.getElementsByTagName) {
		// Pega todas as tags de objetos na pagina
		var objs = document.getElementsByTagName("object");
		for (i=0; i<objs.length; i++) {
			// pega cada conteudo HTML da tag e substitui por ele
			objs[i].outerHTML = objs[i].outerHTML;
		}
	}
}
// qdo sai da pagina
window.onunload = function() {
	 if (document.getElementsByTagName) {
		 // Pega todas as tags de objetos na pagina.
		 var objs = document.getElementsByTagName("object");
		 for (i=0; i<objs.length; i++) {
			 // limpa conteúdo HTML das tags
			 objs[i].outerHTML = "";
		 }
	 }
}

Função do Flash */

//
// JANELA MODAL - INICIO /////////////////////////////////////////////////////////////////////
//

function abrirModalSite(url,nome,titulo,w,h,center,resize,scrolling){
	//sitewindow=dhtmlmodal.open('Conteudo', 'iframe', 'http://www.wmidia.com.br/cliente/expoente3', 'Título da janela modal', 'width=800px,height=500px,center=1,resize=0,scrolling=1')
	settings ='width='+w+'px,height='+h+'px,center='+center+',resize='+resize+',scrolling='+scrolling+''
	sitewindow=dhtmlmodal.open(nome,'iframe',url,titulo,settings)
} 
// COMO USAR:
// <a href="http://www.uol.com.br" 
// onClick="abrirModalSite(this.href,'Nome da Janela','Titulo da pagina','760','550','1','0','1'); return false">Abrir site externo</a>
// w,h,center,resize,scroll > 1 = sim 0 = nao



