//****************************************
// Java Scripts de utilização interna
// Escrito por Mauricio Cunha
//****************************************

<!--
newbg="#6a91bf";
bg = "";
lThis = "";
Obg="";
var site = "http://www.sistemaprofile.com";
var description = "VBMania";
var browser = navigator.appName;
var version = navigator.appVersion.substring(0,1);
var ie = ((browser == "Microsoft Internet Explorer") && (version >= 4));
var ns = ((browser=="Netscape") && (version >= 4 && version < 5));

function openWindow(url,iHeight,iWidth)
{
  popupWin = window.open(url,'New_Page','toolbar=no,location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, left=0, top=0, height=' + iHeight + ',width=' + iWidth + '');
}

function openWindowScroll(url,iHeight,iWidth)
{
  popupWin = window.open(url,'New_Page','toolbar=no,location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, left=0, top=0, height=' + iHeight + ',width=' + iWidth + '');
}

function ClipForm() 
   {
      holdtext.innerText = "Profile - www.sistemaprofile.com\n\n" + copyfrm.innerText + '\n\n';
      Copied = holdtext.createTextRange();
      Copied.execCommand("RemoveFormat");      
      Copied.execCommand("Copy");
   }

function ClickHandler() 
{
  var targetId;
  var srcElement
  var targetElement;
  srcElement = window.event.srcElement;
  if (srcElement.className == "Outline") 
  {
     targetId = srcElement.id + "details";
     targetElement = document.all(targetId);
     if (targetElement.style.display == "none") 
     {
        targetElement.style.display = "";
     } 
     else 
     {
        targetElement.style.display = "none";
     }
  }
}
document.onclick = ClickHandler;

function showObject(obj)
{
if(document.layers) 
{
var ns4 = true;
}
if(document.all) 
{
var ie4 = true;
}

if (ns4) obj.visibility = "show";
else if (ie4) obj.visibility = "visible";
}

function hideObject(obj) 
{
if(document.layers) 
{
var ns4 = true;
}
if(document.all) 
{
var ie4 = true;
}

  if (ns4) 
  {
  obj.visibility = "hide";
  }

  if (ie4) 
  {
  obj.visibility = "hidden";
  }
}

function showTable(objName)
{
 if (document.all[objName].style.visibility == "hidden")
 { 
 document.all[objName].style.visibility = "visible"; 
 } 
 else 
 { 
 document.all[objName].style.visibility = "hidden"; 
 }
return false;
}


function setDataType(cValue)
  {
    var isDate = new Date(cValue);
    if (isDate == "NaN")
      {
        if (isNaN(cValue))
          {
            cValue = cValue.toUpperCase();
            return cValue;
          }
        else
          {
            var myNum;
            myNum = String.fromCharCode(48 + cValue.length) + cValue;
            return myNum;
          }
        }
  else
      {
        var myDate = new String();
        myDate = isDate.getFullYear() + " " ;
        myDate = myDate + isDate.getMonth() + " ";
        myDate = myDate + isDate.getDate(); + " ";
        myDate = myDate + isDate.getHours(); + " ";
        myDate = myDate + isDate.getMinutes(); + " ";
        myDate = myDate + isDate.getSeconds();
        return myDate ;
      }
  }


function sortTable(col, tableToSort)
  {
    var iCurCell = col + tableToSort.cols;
    var totalRows = tableToSort.rows.length;
    var bSort = 0;
    var colArray = new Array();
    var oldIndex = new Array();
    var indexArray = new Array();
    var bArray = new Array();
    var newRow;
    var newCell;
    var i;
    var c;
    var j;
    for (i=1; i < tableToSort.rows.length; i++)
      {
        colArray[i - 1] = setDataType(tableToSort.cells(iCurCell).innerText);
        iCurCell = iCurCell + tableToSort.cols;
      }
    for (i=0; i < colArray.length; i++)
      {
        bArray[i] = colArray[i];
      }
    colArray.sort();
    for (i=0; i < colArray.length; i++)
      { 
        indexArray[i] = (i+1);
        for(j=0; j < bArray.length; j++)
          { 
            if (colArray[i] == bArray[j])
              {  
                for (c=0; c<i; c++)
                  {
                    if ( oldIndex[c] == (j+1) )
                    {
                      bSort = 1;
                    }
                      }
                      if (bSort == 0)
                        {
                          oldIndex[i] = (j+1);
                        }
                          bSort = 0;
                        }
          }
    }
  for (i=0; i<oldIndex.length; i++)
    {
      newRow = tableToSort.insertRow();
      for (c=0; c<tableToSort.cols; c++)
        {
          newCell = newRow.insertCell();
          newCell.innerHTML = tableToSort.rows(oldIndex[i]).cells(c).innerHTML;
        }
      }
  for (i=1; i<totalRows; i++)
    {
      tableToSort.moveRow((tableToSort.rows.length -1),1);
    }
  for (i=1; i<totalRows; i++)
    {
      tableToSort.deleteRow();
    }
  }

function mOver(src, clrOver) 
{
	if (!src.contains(event.fromElement)) {
		bg = src.bgColor;
		Obg = src.bgColor;
		src.bgColor = newbg;
	}
}
function mOut(src, clrIn) 
{
   if (!src.contains(event.toElement)) 
   {
		src.bgColor = Obg;
	}
}

    function startpage() {
      if (ie) {
        document.body.style.behavior="url(#default#homepage)";
        document.body.setHomePage(site);
      }
      else 
	    { alert("Houve um erro ao definir VBMania como sua p&aacute;gina inicial !!! "); }
    }

    function favorites() {
      if (ie) 
	    { window.external.AddFavorite(site,description); }
      else {
        if (ns) 
	      { alert("Para adicionar VBMania aos favoritos utilize as teclas CTRL+D"); }
        else 
	      { alert("Adicionado &agrave; favoritos com sucesso !"); }
      }
    }
	
function showtip2(current,e,text){
  if (document.all&&document.readyState=="complete"){
    document.all.tooltip2.innerHTML='<marquee style="border:1px solid black">'+text+'</marquee>'
    document.all.tooltip2.style.pixelLeft=event.clientX+document.body.scrollLeft+10
    document.all.tooltip2.style.pixelTop=event.clientY+document.body.scrollTop+10
    document.all.tooltip2.style.visibility="visible"
}
  else if (document.layers){
    document.tooltip2.document.nstip.document.write('<b>'+text+'</b>')
    document.tooltip2.document.nstip.document.close()
    document.tooltip2.document.nstip.left=0
    currentscroll=setInterval("scrolltip()",100)
    document.tooltip2.left=e.pageX+10
    document.tooltip2.top=e.pageY+10
    document.tooltip2.visibility="show"
}
}
function hidetip2(){
  if (document.all)
    document.all.tooltip2.style.visibility="hidden"
    else if (document.layers){
    clearInterval(currentscroll)
    document.tooltip2.visibility="hidden"
}
}



//-------------------------------------------------------------------------------------------------------------
//Aceita somente numeros em um campo no evento keypress
//-------------------------------------------------------------------------------------------------------------
function isNum( caractere ) 
{ 
var strValidos = "0123456789" 
if ( strValidos.indexOf( caractere ) == -1 ) 
return false; 
return true; 
} 
  
function validaTecla(campo, event) 
{ 
var BACKSPACE= 8; 
var key; 
var tecla; 
CheckTAB=true; 
  
if(navigator.appName.indexOf("Netscape")!= -1) 
 tecla= event.which; 
else 
 tecla= event.keyCode; 

key = String.fromCharCode( tecla); 

if ( tecla == 13 ) 
 return false; 
  
if ( tecla == BACKSPACE ) 
 return true; 
  
return (isNum(key)); 
} 


//-------------------------------------------------------------------------------------------------------------
//Retira acentos e caracteres estranhos do campo
//-------------------------------------------------------------------------------------------------------------
function troca(campo)
{ 
var estranha = "ÁÉÍÓÚÀÈÌÒÙÂÊÎÔÛÃÕ@#$%^&*()_+=-~`'Ç"; 
var correta  = "AEIOUAEIOUAEIOUAO________________C"; 
var retorno = ""; 
  
campo.value = campo.value.toUpperCase(); 
  
for(i=0;i<estranha.length;i++) 
 { 
  for(j=0;j<campo.value.length;j++) 
  { 
   retorno = campo.value.replace(estranha.substr(i,1),correta.substr(i,1)); 
   retorno = retorno.replace("_",""); 
   campo.value = retorno; 
  } 
 } 
} 

//-------------------------------------------------------------------------------------------------------------
//Limpa um campo caso nume tenha o valor igual ao valor default
//-------------------------------------------------------------------------------------------------------------
function clearFromDefault(finumd) 
{
   if(finumd.defaultValue == finumd.value)
     finumd.value = ""
}


//-------------------------------------------------------------------------------------------------------------
//Força o preenchimento de zero caso o campo seja nulo
//-------------------------------------------------------------------------------------------------------------
function forceZero(finumd)
{
  if(finumd.value == '')
     finumd.value = '0'
}


//-------------------------------------------------------------------------------------------------------------
//Formata um campo para numerico a partir de um valor currency
//-------------------------------------------------------------------------------------------------------------
function formatToNumber(num)
{
 var rep1 = /[.]/gi
 num = num.toString().replace(rep1, "");
 var rep2 = /[$,.]/gi
 num = num.toString().replace(rep2, "")/100;
 return num
}


//-------------------------------------------------------------------------------------------------------------
//Formata um campo para moeda
//-------------------------------------------------------------------------------------------------------------
function formatCurrency(num) 
{
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
 num = "0";
 sign = (num == (num = Math.abs(num)));
 num = Math.floor(num*100+0.50000000001);
 cents = num%100;
 num = Math.floor(num/100).toString();

if(cents < 10)
 cents = "0" + cents;
  for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
   num = num.substring(0,num.length-(4*i+3))+'.'+
   num.substring(num.length-(4*i+3));
   return (((sign)?'':'-') + num + ',' + cents);
}


function formatDia(vData)
{
	if(vData=="")return "";
	if(vData.indexOf('/')<0)
	 {
	  var vDia=vData.substring(0,2);
	  var vMes=vData.substring(2,4);
	  var vAno=vData.substring(4,8);
	 }
	else
	{
	  var vDia=vData.substring(0,2);
	  var vMes=vData.substring(3,5);
	  var vAno=vData.substring(6,10);
	}
	return vDia+'/'+vMes+'/'+vAno;
}


function isDate(dateStr) 
{
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
var matchArray = dateStr.match(datePat); 

if (matchArray == null) 
{
 return false;
}

day = matchArray[1];
month = matchArray[3]; 
year = matchArray[5];

if (month < 1 || month > 12) 
{
 return false;
}

if (day < 1 || day > 31) 
{
 return false;
}

if ((month==4 || month==6 || month==9 || month==11) && day==31) 
{
 return false;
}

if (month == 2) 
{
 var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
 if (day > 29 || (day==29 && !isleap)) 
 {
  return false;
 }
}
return true
}

//-------------------------------------------------------------------------------------------------------------
//Remove todas as tags de uma string (tags de data,cnpj e moeda)
//-------------------------------------------------------------------------------------------------------------
function clearAllTags(fromobj)
{
var tmpreturn = "";
for (var i = 0; i < fromobj.length; i++) 
 {
  switch (fromobj.charAt(i))
  {
   case "/": 
    tmpreturn += "";
    break;
   case "-": 
    tmpreturn += "";
    break;
   case ".": 
    tmpreturn += "";
    break;
   case ",": 
    tmpreturn += "";
    break;
   default:  
    tmpreturn += fromobj.charAt(i); 
  }  
 }
return tmpreturn;



function emailValid(emailStr) 
 {
 var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
 var regex = new RegExp(emailReg);
 return regex.test(emailStr);
 }
}

function textCounter(field, countfield, maxlimit) 
{
if (field.value.length > maxlimit) 
 field.value = field.value.substring(0, maxlimit);
else 
 countfield.value = maxlimit - field.value.length;
}

-->

