// JavaScript Document
function Mascara(campo,restricao,formato){
 // var r = new Restrict(campo,'\\s\\w-','####.###.######-# ##');
  var r = new Restrict(campo,restricao,formato);
    r.onKeyRefuse = function(o, k){
		if (o.corAntiga == null){
			o.corAntiga = o.style.backgroundColor; // seta a cor anterior ao efeito que pisca
		} // fim do if
		o.style.backgroundColor = 'red' ;
		window.setTimeout ("document.getElementById('"+o.id+"').style.backgroundColor = document.getElementById('"+o.id+"').corAntiga;", 50);
    }// fim da função onKeyRefuse
    r.start();
	r = null;
}
function aplicarMascara(origem){
	origem = parseInt(origem,10);
	try{		
		removeEvent(document.getElementById(idNumero),"keyup",document.getElementById(idNumero)._onkeyup[0][0],document.getElementById(idNumero))
		removeEvent(document.getElementById(idNumero),"keydown",document.getElementById(idNumero)._onkeydown[0][0],document.getElementById(idNumero))
		removeEvent(document.getElementById(idNumero),"keypress",document.getElementById(idNumero)._onkeypress[0][0],document.getElementById(idNumero))
	} catch (ex){
		//alert(ex)
		 }
	if (origem == 1){
			Mascara("txtNumero","\\.","####.###.######-# ##");
	}
	else if (origem == 2){
		if (valorSelectMenu('form:selectOneRadio1') == '1')
			Mascara("txtNumero","\\.","####.###.#####");
		else if (valorSelectMenu('form:selectOneRadio1') == '2')
			Mascara("txtNumero","\\.","####.########");
	}		
	else if ((origem == 3) || (origem == 4) || (origem == 7)) {
			Mascara("txtNumero","\\.","####.###.#####");
	}
	else if(origem == 5 ){
			Mascara("txtNumero","\\.","####.#####-#");
	}
	else document.getElementById(idNumero).maxLength = 19;
	
}

