function scrollOver(strMarquee){
	strMarquee.scrollAmount = "0";
	strMarquee.style.cursor = "default";
}


function scrollOut(strMarquee){
	strMarquee.scrollAmount = "3";
}


function abrePopup(arquivo, largura, altura){
	if (largura == null && altura == null){booResize = "yes";}else{booResize = "no";}

	popup = open(arquivo,"popup1","resizable=" + booResize  +",scrollbars=yes,status=no,width=" + largura + ",height=" + altura + ",top="+(window.screen.height-altura)/2+",left="+(window.screen.width-largura)/2+"");
	popup.focus();	
}


function abreBoleto(arquivo, largura, altura, aux){
	popup = open(arquivo,"boleto", aux + "width=" + largura + ",height=" + altura + ",top="+(window.screen.height-altura)/2+",left="+(window.screen.width-largura)/2+"");
	popup.focus();
}


function mouseOver(elemento, cor){
	elemento.style.backgroundColor = cor;
}


function mouseOut(elemento){
	elemento.style.backgroundColor = "";
}


function ajustaTamanhoJanela(largura, altura){
	window.resizeTo(largura, altura);
	window.moveTo((window.screen.width-largura)/2, (window.screen.height-altura)/2);
}

/*function KeyPress(tecla) {	
	if (document.all){tecla = window.event;  key = tecla.keyCode;}
	if (key == 123){
		abrePopup("login.asp", 150, 150);
		return false;
	}

}
document.onkeydown = KeyPress;*/

function showHide(objeto){
	/*if (eval("document.all." + objeto + ".style").display == "block"){
		eval("document.all." + objeto + ".style").display = "none";
	}else{
		eval("document.all." + objeto + ".style").display = "block";
	}*/
	

	if (document.getElementById(objeto).style.display=='none') {
		document.getElementById(objeto).style.display='block';
	} else {
		document.getElementById(objeto).style.display='none';
	}

}


function ehEmail(Source){

	var Pos=0;		//POSICAO DOS SIMBOLOS
	var Texto="";	//VALOR A SER TESTADO

	Texto=Source;
	if (Texto!=""){//EXISTE VALOR	
		Pos=Texto.indexOf("@",0);
		if ((Pos<=0) || (Pos==Texto.length-1)){//NAO PODE SER EMAIL NAO TEM @ OU COMECA POR @ OU TERMINA POR @
			return(false);
		}//if
		Pos=Texto.indexOf("@",Pos+1);
		if (Pos!=-1){//NAO PODE SER EMAIL TEM 2 @
			return(false);
		}//if
	}//if
	return(true);
}


function ehNome(Source){
	var Texto="";
	
	Texto=Source;
	if (Texto!=""){//EXISTE VALOR
		if (Texto.length<3){// NOME MUITO PEQUENO
			return(false);
		}//if
		if ((Texto.charAt(0)==Texto.charAt(1)) && (Texto.charAt(1)==Texto.charAt(2))){//TRES PRIMEIRAS LETRAS IGUAIS, NAO E' UM NOME
			return(false);
		}//if
	}//if
	return(true);
}

var isNN = (navigator.appName.indexOf("Netscape")!=-1);


function autoTab(input,len, e) {
    var keyCode = (isNN) ? e.which : e.keyCode; 
    var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
    if(input.value.length >= len && !containsElement(filter,keyCode)) {
        input.value = input.value.slice(0, len);
        input.form[(getIndex(input)+1) % input.form.length].focus();
}


function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
        if(arr[index] == ele)
            found = true;
        else
            index++;
        return found;
}


function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
        if (input.form[i] == input)index = i;
        else i++;
        return index;
    }
	return true;
}


function MudarData(dia, obj) {
	if (dia) {
		if (obj) {
			eval(obj).value = dia;
			//eval(obj + "H").value = dia;
		}
	}
}


function caracterInvalido() {
	var strinvalido
	strinvalido = '!"#$%&\()*+,-./:;<=>?@1234567890'
	//strinvalido+= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	//strinvalido+= 'àèìòùâêîôûäëïöüáéíóúãõÀÈÌÒÙÂÊÎÔÛÄËÏÖÜÁÉÍÓÚÃÕ'
	strinvalido += '[\]^_`'
	strinvalido += '{|}~'
	return strinvalido
}


function ehValido(strCaracter, intLista){
	var i = 0;
	var lista = "";

	switch (intLista) {
		case 1 :
			lista = '1234567890';
			break;
		case 2 :
			lista = '!"#$%&\()*+,-./:;<=>?@';
			break;
		case 3 :
			lista = 'àèìòùâêîôûäëïöüáéíóúãõÀÈÌÒÙÂÊÎÔÛÄËÏÖÜÁÉÍÓÚÃÕ';
			break;
	}

	for (i = 0; i < lista.length; i++) {
		if (lista.indexOf(strCaracter.charAt(i),0)==-1){
			return false;
		}
	}

	return true;

}


function ehHora(hora){

 	if(hora.length < 5){
 		//alert("Formato da hora inválido. Por favor, informe a hora no formato correto: hh:mm");
		return false;
	}

	if(hora.substr(0,2) > 23 || isNaN(hora.substr(0,2))){
		//alert("Formato da hora inválido.");
 		return false;
 	}

	if(hora.substr(3,2) > 59 || isNaN(hora.substr(3,2))){
		//alert("Formato do minuto inválido.");
		return false;
	}

	return true;
}


function ehNumero(fld, e){
	//  Usar no onKeyPress="return(ehNumero(this,event))" do input(text)
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	key = String.fromCharCode(whichCode);
	if (strCheck.indexOf(key) == -1) return false;
}


function verificaTamanho(obj, maximo){
	var strLen = 0;
	var corte = strLen;

	if (obj.value.length != "" ){
		strLen += obj.value.length;
	}

	if (strLen > maximo){
		obj.value = obj.value.substring(0,maximo-corte);
		strLen -= 1;
	}

   document.all.nCaract.value = maximo - strLen;

}


function Mascara(formato, keypress, objeto){

	campo = eval(objeto);
	
	if (formato == "CEP"){
		separador = "-"; 
		conjunto1 = 5;
		if (campo.value.length == conjunto1){
			campo.value = campo.value + separador;
		} 
	}

	if (formato == "DATA"){
		separador = "/";
		conjunto1 = 2;
		conjunto2 = 5;
		if (campo.value.length == conjunto1){
			campo.value = campo.value + separador;
		}

		if (campo.value.length == conjunto2){
			campo.value = campo.value + separador;
		}
	}

	if (formato == "TELEFONE"){
		separador1 = "(";
		separador2 = ")";
		separador3 = "-";

		conjunto1 = 1;
		conjunto2 = 3;
		conjunto3 = 8;

		if (campo.value.length == conjunto1){
			campo.value = separador1 + campo.value;
		}
		
		if (campo.value.length == conjunto2){
			campo.value = campo.value + separador2;
		}
		
		if (campo.value.length == conjunto3){
			campo.value = campo.value + separador3;
		}
	}

	if (formato == "CPF"){
		separador1 = ".";
		separador2 = "-";

		//000.000.000-00
		conjunto1 = 3;
		conjunto2 = 7;
		conjunto3 = 11;


		if (campo.value.length == conjunto1){
			campo.value = campo.value + separador1;
		}

		if (campo.value.length == conjunto2){
			campo.value = campo.value + separador1;
		}

		if (campo.value.length == conjunto3){
			campo.value = campo.value + separador1;
		}
	}

	if (formato == "CNPJ"){
		separador1 = ".";
		separador2 = "/";
		separador3 = "-";

		//00.000.000/0000-00
		conjunto1 = 2;
		conjunto2 = 6;
		conjunto3 = 10;
		conjunto4 = 15;


		if (campo.value.length == conjunto1){
			campo.value = campo.value + separador1;
		}

		if (campo.value.length == conjunto2){
			campo.value = campo.value + separador1;
		}

		if (campo.value.length == conjunto3){
			campo.value = campo.value + separador2;
		}
		
		if (campo.value.length == conjunto4){
			campo.value = campo.value + separador3;
		}

	}

	return(ehNumero(campo,event));
}


function fechaBanner(){
	document.all.bannerSuspenso.style.display = "none";
}


function createXMLHTTP(){
	var ajax;
	try{
		ajax = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	catch(e){
		try{
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
			alert(ajax);
		}
		catch(ex){
			try{
				ajax = new XMLHttpRequest();
			}
			catch(exc){
				 alert("Esse browser não tem recursos para uso do Ajax");
				 ajax = null;
			}
		}
		return ajax;
	}

   var arrSignatures = ["MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0",
						"MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",
						"Microsoft.XMLHTTP"];

	for (var i=0; i < arrSignatures.length; i++){
		try{
			var oRequest = new ActiveXObject(arrSignatures[i]);
			return oRequest;
		} 
		catch (oError){
		}
   }
   throw new Error("MSXML is not installed on your system.");
}

String.prototype.trim = function(){
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
}


function poppupMDI(strNomePopup){
	popup = new Window(strNomePopup, {className: "spread", top:10, right:20, width:300, height:200, maxWidth:500, maxHeight:500, minWidth:100, minHeight:100, closable: true, resizable: true, title: "Not Closable", //wiredDrag:true,
	url: "http://www.acquamanager.com"})
	popup.show();
	popup.setDestroyOnClose();
	
/*	win3 = new Window('dialog3', {className: "spread", title: "Not Closable", 
	top:10, right:20, width:300, height:200, 
	closable: true, url: "http://www.google.com/", showEffectOptions: {duration:3}})
	win3.show();
	*/
}


function alerta(strMensagem) {
	Dialog.alert(strMensagem + "", {top: 200, width:250, className: "alphacube"})
}


function openAjaxPopupModal(strURL, strTitulo) {
	Dialog.popupModal({url: strURL, options: {method: 'get'}}, {width:500, height:500, title: strTitulo, closable: true, className: "spread"})    
}


function poppup4(){
	win2 = new Window('dialog2', {title: "Ruby on Rails", 
	bottom:70, left:0, width:300, height:200, 
	resizable: true, url: "http://www.rubyonrails.com/", showEffectOptions: {duration:3}})
	win2.show();
	win2.setDestroyOnClose();
}
