
// # # # # # # # # # # # # # # # # # #
// Máscara para CEP , DATA e TELEFONE
// # # # # # # # # # # # # # # # # # #

function Mascara (formato, keypress, objeto){
campo = eval (objeto);
//alert(campo);
// CEP
if (formato=='CEP'){
separador = '-'; 
conjunto1 = 5;
if (campo.value.length == conjunto1){
campo.value = campo.value + separador;
}
}

// DATA
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;
}
}

// TELEFONE
if (formato=='telefone'){
separador = '-'; 
conjunto1 = 4;
if (campo.value.length == conjunto1){
campo.value = campo.value + separador;
}
}

// Hora
if (formato=='hora'){
separador = ':'; 
conjunto1 = 2;
if (campo.value.length == conjunto1){
campo.value = campo.value + separador;
}
}

}


// JavaScript Document
<!-- funçoes do editor HTML
 function set_desc(){
        form1.desc_materia.value = iView.document.body.innerHTML;
		//alert(iView.document.body.innerHTML);
		//alert(form1.desc_materia.value);
  }
  
 
  var viewMode = 1; // WYSIWYG

  function Init()
  {
    iView.document.designMode = 'On';
  }
  
  function selOn(ctrl)
  {
	ctrl.style.borderColor = '#000000';
	ctrl.style.backgroundColor = '#B5BED6';
	ctrl.style.cursor = 'hand';	
  }
  
  function selOff(ctrl)
  {
	ctrl.style.borderColor = '#D6D3CE';  
	ctrl.style.backgroundColor = '#D6D3CE';
  }
  
  function selDown(ctrl)
  {
	ctrl.style.backgroundColor = '#8492B5';
  }
  
  function selUp(ctrl)
  {
    ctrl.style.backgroundColor = '#B5BED6';
  }
    
  function doBold()
  {
	iView.document.execCommand('bold', false, null);
  }

  function doItalic()
  {
	iView.document.execCommand('italic', false, null);
  }

  function doUnderline()
  {
	iView.document.execCommand('underline', false, null);
  }
  
    function doSelecionaTudo()
  {
	iView.document.execCommand('SelectAll', false, null);
  }
  

  
  function doLeft()
  {
    iView.document.execCommand('justifyleft', false, null);
  }

  function doCenter()
  {
    iView.document.execCommand('justifycenter', false, null);
  }

  function doRight()
  {
    iView.document.execCommand('justifyright', false, null);
  }
  
    function doJustifica()
  {
    iView.document.execCommand('justifyFull', false, null);
  }

  function doOrdList()
  {
    iView.document.execCommand('insertorderedlist', false, null);
  }

  function doBulList()
  {
    iView.document.execCommand('insertunorderedlist', false, null);
  }
  
  function doForeCol()
  {
    var fCol = prompt('Enter foreground color', '');
    
    if(fCol != null)
      iView.document.execCommand('forecolor', false, fCol);
  }
  
    function doCorLetra(cor)
  {
    var fCol = cor
    
    if(fCol != null)
      iView.document.execCommand('forecolor', false, fCol);
  }

  function doBackCol()
  {
    var bCol = prompt('Enter background color', '');
    
    if(bCol != null)
      iView.document.execCommand('backcolor', false, bCol);
  }

  function doLink()
  {
    iView.document.execCommand('createlink');
  }
  
    function doRemoverLink()
  {
    iView.document.execCommand('unlink');
  }
  
   
  
  function doImage()
  {
    var imgSrc = prompt('Enter image location', '');
    
    if(imgSrc != null)    
     iView.document.execCommand('insertimage', false, imgSrc);
  }
  
  function doRule()
  {
    iView.document.execCommand('inserthorizontalrule', false, null);
  }
  
  
    function doCopiar()
  {
    iView.document.execCommand('copy', false, null);
  }
  
      function doColar()
  {
    iView.document.execCommand('paste', false, null);
  }
  
        function doDesfazer()
  {
    iView.document.execCommand('undo', false, null);
  }
  
        function doRefazer()
  {
    iView.document.execCommand('redo', false, null);
  }
  
          function doSalvar()
  {
    iView.document.execCommand('SaveAs', false, null);
  }
  
  function doFont(fName)
  {
    if(fName != '')
      iView.document.execCommand('fontname', false, fName);
  }
  
  function doSize(fSize)
  {
    if(fSize != '')
      iView.document.execCommand('fontsize', false, fSize);
  }
  
  function doHead(hType)
  {
    if(hType != '')
    {
      iView.document.execCommand('formatblock', false, hType);  
      doFont(selFont.options[selFont.selectedIndex].value);
    }
  }
  
  function doToggleView()
  {  
    if(viewMode == 1)
    {
      iHTML = iView.document.body.innerHTML;
      iView.document.body.innerText = iHTML;
      
      // Hide all controls
      tblCtrls.style.display = 'none';
      selFont.style.display = 'none';
      selSize.style.display = 'none';
      selHeading.style.display = 'none';
      iView.focus();
      
      viewMode = 2; // Code
    }
    else
    {
      iText = iView.document.body.innerText;
      iView.document.body.innerHTML = iText;
      
      // Show all controls
      tblCtrls.style.display = 'inline';
      selFont.style.display = 'inline';
      selSize.style.display = 'inline';
      selHeading.style.display = 'inline';
      iView.focus();
      
      viewMode = 1; // WYSIWYG
    }
  }
<!-- fim de funçoes do editor HTML



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(theform,thelimit){
var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> caracteres restantes'
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); 
}
}

function AbrePopUp(pagina,altura,largura,barra)
{
 top1=(screen.availHeight - altura)/2;
 left1=(screen.availWidth - largura)/2;
 
 window.open(pagina,"_blank","height="+altura+",width="+largura+","+barra+",left="+left1+",top="+top1); 
}

function tamanho_fonte(tamanho)
{
	if (tamanho == "peq")
		document.getElementById('td_texto').style.fontSize = '9px'
	else
		document.getElementById('td_texto').style.fontSize = '15px'
}

// ####################
//Validao de formulrios


function formCheck(formobj,arrayCamp,arrayDesc){


	// Enter name of mandatory fields
	//var fieldRequired = Array("data","titulo");
	var fieldRequired = arrayCamp;
	// Enter field description to appear in the dialog box
	//var fieldDescription = Array("Data","Titulo");
	var fieldDescription = arrayDesc;
	// dialog message
	var alertMsg = "Por Favor Preencha o(s) campo(s) abaixo:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}

}


// # # # # # # # # # # # # # # # # # # # # # # # #
// Função para permitir somente digitação de números
// # # # # # # # # # # # # # # # # # # # # # # # #

function so_numeros() { 
if (event.keyCode == '13') 
{ 
	} 
		else if (event.keyCode < '48' || event.keyCode > '58') 
		{ 
			event.keyCode = '127'; 
		} 
} 


// # # # # # # # # # # # # # # # # # # # # # # # #
// Função para permitir somente digitação de números Virgula e Ponto
// # # # # # # # # # # # # # # # # # # # # # # # #

function so_numerosvirgula() { 
if (event.keyCode == '13' || event.keyCode == '44' || event.keyCode == '46') 
{ 
	} 
		else if (event.keyCode < '48' || event.keyCode > '58') 
		{ 
			event.keyCode = '127'; 
		} 
} 
