
/////////////////////////////////////////////////////////

function $(strs){
	     return document.getElementById(strs);
}


/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
function numbersv(campo, eve){
  		 if(navigator.appName == "Netscape"){tecla = eve.which;}else{tecla = eve.keyCode;}
		 var camp = $(campo);
		 if ((tecla != 8) && (tecla != 0) && (tecla != 44)  && (tecla <= 45 || tecla >= 58))
 		 {return false;}
 		 else return true}
//////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////		 
function numbers(eve){
  		 if(navigator.appName == "Netscape"){tecla = eve.which;}else{tecla = eve.keyCode;}
		 if ((tecla != 8) && (tecla != 0) && (tecla <= 46 || tecla >= 58))
 		 {return false;}
 		 else return true}
///////////////////////////////////////////////////////////

function numbersv2(campo, eve){
  		 if(navigator.appName == "Netscape"){tecla = eve.which;}else{tecla = eve.keyCode;}
		 var camp = document.getElementById(campo);
		 if ((tecla != 8) && (tecla != 0) && (tecla != 44) && (tecla <= 45 || tecla >= 58))
 		 {return false;}
 		 else return true}		

///////////////////////////////////////////////////////////

function Formats(campo , string){ 
         //campo = nome do campo
		 //string = * divide as ocorrencias
		 // # divide entre o value.length do cmapo e o caractere que deve ser inserido
		 var camp = campo;
		 strings = string.split("*");
		 for(i = 0; i < strings.length;i++){
		 str = strings[i].split("#");
		 keys = str[0];
		 isn = str[1];
		 if(camp.value.length == keys){camp.value += isn;}
		 }}	

///////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////		 
startList = function() {
if(navigator.appName == "Microsoft Internet Explorer"){
var sfEls = document.getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" over";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" over\\b"), "");
		}
	}
}

}





function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
 var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

 if(navigator.appName == "Netscape"){nTecla = evtKeyPress.which;}else{nTecla = evtKeyPress.keyCode;}

 sValue = objForm[strField].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( " ", "" );
 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) == "/"))
 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++;
 }

 objForm[strField].value = sCod;

 if (nTecla != 8) { // backspace
 if (sMask.charAt(i-1) == "9") { // apenas números...
 return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9
 else { // qualquer caracter...
 return true;
 } }
 else {
 return true;
 }
 }
/////////////////////////////////////////////////////

function contagem(exp1,time){
	     var total = 0;
	     for(i=0;i < time.length;i++){
			 if(time[i].indexOf(exp1) !== -1){total++;}}
			 return total;}
/////////////////////////////////////////////////////

function divs(ndiv,check){
	 if(check == 1){$(ndiv).style.display = "none";}else{
			        $(ndiv).style.display = "block";}
}
	     

/////////////////////////////////////////////////////

function checkfield1(forms,campo,val,str1,msg){
	     data2 = $(campo).value;
		 if(contagem(str1,data2) != val){
	     alert(msg);
		 $(campo).focus();
		 return false;}
		 else{
	     return true;}
		 
}

//////////////////////////////////////////////////////

function proximocampo(car,campo,campo2){
	     if($(campo).value.length == car){$(campo2).focus();}
		 }
//////////////////////////////////////////////////////

function inserirtxt(campo,txt){
	     $(campo).value += txt;
		 }
		 
//////////////////////////////////////////////////////		 

function FormataReais(fld, milSep, decSep, e) {

var sep = 0;

var key = '';

var i = j = 0;

var len = len2 = 0;

var strCheck = '0123456789';

var aux = aux2 = '';

var whichCode = (window.Event) ? e.which : e.keyCode;

if (whichCode == 8 || whichCode == 0) return true;

if (whichCode == 13) return true;

key = String.fromCharCode(whichCode);// Valor para o código da Chave

if (strCheck.indexOf(key) == -1) return false; // Chave inválida

len = fld.value.length;

for(i = 0; i < len; i++)

if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;

aux = '';

for(; i < len; i++)

if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);

aux += key;

len = aux.length;

if (len == 0) fld.value = '';

if (len == 1) fld.value = '0'+ decSep + '0' + aux;

if (len == 2) fld.value = '0'+ decSep + aux;

if (len > 2) {

aux2 = '';

for (j = 0, i = len - 3; i >= 0; i--) {

if (j == 3) {

aux2 += milSep;

j = 0;

}

aux2 += aux.charAt(i);

j++;

}

fld.value = '';

len2 = aux2.length;

for (i = len2 - 1; i >= 0; i--)

fld.value += aux2.charAt(i);

fld.value += decSep + aux.substr(len - 2, len);

}

return false;

}

function formatmoney(fld, milSep, decSep){

var fld = $(fld);

var sep = 0;

var key = '';

var i = j = 0;

var len = len2 = 0;

var strCheck = '0123456789';

var aux = aux2 = '';

len = fld.value.length;

for(i = 0; i < len; i++)

if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;

aux = '';

for(; i < len; i++)

if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);

len = aux.length;

if (len == 0) fld.value = '';

if (len == 1) fld.value = '0'+ decSep + '0' + aux;

if (len == 2) fld.value = '0'+ decSep + aux;

if (len > 2) {

aux2 = '';

for (j = 0, i = len - 3; i >= 0; i--) {

if (j == 3) {

aux2 += milSep;

j = 0;

}



aux2 += aux.charAt(i);

j++;

}

fld.value = '';

len2 = aux2.length;

for (i = len2 - 1; i >= 0; i--)

fld.value += aux2.charAt(i);

fld.value += decSep + aux.substr(len - 2, len);

}

return false;

}

function substr_reset(vars){
         var temp = new Array();
         var temp2 = new Array();		 
		 var nvar = "";
		 var nvar2 = "";
		 temp = vars.split(',');
		 for(i = 0;i < temp.length;i++){
		 nvar += temp[i];}
 		 temp2 = nvar.split('.');
		 for(i = 0;i < temp2.length;i++){
		 nvar2 += temp2[i];}
		 return nvar2;
		 }
		 
		 
function shows(ids){
		 num = divs.length;
         for(i = 0;i <= num;i++){
		 divn = divs[i];
		 
		 if(isNaN(divn) == false){		 
		 document.getElementById(divn).style.display = "none";}}
         var now = document.getElementById(ids).style.display;
		 if(document.getElementById("le").value == ids){document.getElementById(ids).style.display = "none";document.getElementById("le").value = "";}else{
		 if(now == "none"){document.getElementById(ids).style.display = "block";
		                   document.getElementById("le").value = ids;}else{document.getElementById(ids).style.display = "none";
						   												 document.getElementById("le").value = "";}}}
																		 
function tabs(tab,color,ac,or){
         col = tab.style.backgroundColor;

		 if (col.indexOf("rgb") >= 0)
         {
         var rgbStr = col.slice(col.indexOf('(') + 1,col.indexOf(')'));
         var rgbValues = rgbStr.split(",");
         col = "#";
         var hexChars = "0123456789abcdef";
         for (var i = 0; i < 3; i++)
         {
            var v = rgbValues[i].valueOf();
            col += hexChars.charAt(v/16) + hexChars.charAt(v%16);
         }
         }	 

		 if(ac == "over" && col != "#ffffcc"){
		 tab.style.background = color;}
		 if(ac == "out" && col != "#ffffcc"){
		 tab.style.background = color;}
		 
		 if(ac == "down"){
		 if(col == "#ffffcc"){
		 tab.style.background = or;}else{
		 tab.style.background = color;}}
}

function confirmar(msg,links){
	     if(confirm(msg)){
			 location.href = links;
		 }
}
////////////////////////////////////////////////////
////////////////////////////////////////////////////
function Formats2(campo,sMask,evento){
	 var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

     if(evento){
	 if(!numbers(evento)){return false;}		 
	 }

 sValue = campo.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( " ", "" );
 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) == "/"))
 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++;
 }

 campo.value = sCod;

 }
 
 function pfls(swf,width,height){

document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width+'" height="'+height+'"><param name="movie" value="'+swf+'"/><param name="quality" value="high"/><param name="wmode" value="transparent"/><embed src="'+swf+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" width="'+width+'" height="'+height+'"></embed></object>');

}