﻿//  CSS - CETAC

//  Descrição: Javascript
//  Versão: 1.0
//  Autor: Devigate - Agência Web
//  Autor URL: http://www.devigate.com/

//  Criação: 06 Janeiro 2011


//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div' );

//Specify spectrum of different font sizes:
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 2;

function ts( trgt,inc ) {
    if (!document.getElementById) return
    var d = document,cEl = null,sz = startSz,i,j,cTags;
    sz += inc;
    if ( sz < 0 ) sz = 0;
    if ( sz > 6 ) sz = 6;
    startSz = sz;
    if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

    cEl.style.fontSize = szs[ sz ];

    for ( i = 0; i < tgs.length; i++ ) {
        cTags = cEl.getElementsByTagName( tgs[ i ] );
        for ( j = 0; j < cTags.length; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
    }
}

function NotSpecials()
{
    if (window.event.keyCode >= 48 && window.event.keyCode <= 57)
        return true
    else if (window.event.keyCode >= 65 && window.event.keyCode <= 90)
        return true
    else if (window.event.keyCode >= 97 && window.event.keyCode <= 122)
        return true
	else if (window.event.keyCode == 32)
        return true
  else
    window.event.keyCode = 0;
}

function OnlyNumbers()
{
    if (window.event.keyCode >= 48 && window.event.keyCode <= 57)
        return true
    else
        window.event.keyCode = 0;
        alert('Digitar somente números, não informar ponto, traço ou letra!')
}

function OnlyDecimals()
{
    if ((window.event.keyCode >= 48 && window.event.keyCode <= 57) || (window.event.keyCode == 44))
        return true
    else
        window.event.keyCode = 0;
}

function ValidPercent(campo)
{
    var campo1 = document.getElementById(campo).value;
    var maior = parseFloat(campo1);
   if ((maior > 100) || (maior < 0))
   {
        alert('Valor percentual invalido!');
        document.getElementById(campo).value = '';
   }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function formata(campo, mask, evt) { 
  
 if(document.all) { // Internet Explorer 
    key = evt.keyCode; } 
    else{ // Nestcape 
       key = evt.which; 
     } 

 string = campo.value;  
 i = string.length;

 if (i < mask.length) {
  if (mask.charAt(i) == '§') {
       return (key > 47 && key < 58);
      } else {
       if (mask.charAt(i) == '!') {  return true;  }
   for (c = i; c < mask.length; c++) {
         if (mask.charAt(c) != '§' && mask.charAt(c) != '!')
         campo.value = campo.value + mask.charAt(c);
      else if (mask.charAt(c) == '!'){
                return true;
       } else {
         return (key > 47 && key < 58);
          }
       }
    }
  } else return false;
}

function validaemail(campo)
{
  var obj = eval(campo.value);
  var txt = obj.value;
  if ((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 7)))
  {
    alert('Email incorreto');
	obj.focus();
  }
}

