// writeObj : embed,object ±â¼ú
function CompilaFlash(arq,largura,altura) {
    document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+largura+"' height='"+ altura +"' id='flash' align='middle' VIEWASTEXT>"+
	 "<param name='allowScriptAccess' value='always' />"+
	 "<param name='movie' value='"+ arq +"' />"+
	 "<param name='quality' value='high' />"+
	 "<param name='wmode' value='transparent' />"+
	 "<param name='allowFullScreen' value='true' />"+
	 "<embed src='"+ arq +"' quality='high' wmode='transparent' menu='false' width='"+largura+"' height='"+ altura +"' name='flash' align='middle' allowScriptAccess='always' allowFullScreen='true' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
	"</object>");
}

function controleSubmenus(idHabilitar)
{
  	var allParas = document.getElementsByTagName("ul");
	var idHabilitar = document.getElementById(idHabilitar);
	
  	var num = allParas.length;
  
	for (var i=0; i<num; i++){
		var ul = allParas[i];
		var rel = ul.getAttribute('rel');
		
		if (rel && rel == 'submenu'){
			ul.style.display = "none";
			ul.style.visibility = "hidden";
			if(ul.id == idHabilitar.id){
				idHabilitar.style.display = "block";
				idHabilitar.style.visibility = "visible";
			}
		}
	}
	
}

function Oculta(div){
	document.getElementById(div).style.visibility='hidden';
	document.getElementById(div).style.display='none';
}
function Mostra(div){
	document.getElementById(div).style.visibility='visible';
	document.getElementById(div).style.display='block';
}

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

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 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];}}
}

//abre pop up
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//sem letras
function SemLetras(){
	if ((window.event.keyCode < 48) | (window.event.keyCode > 57)){
		window.event.keyCode = 0
	}
}

//pula de campo
function Pula(f){
	if(f.value.length==f.maxLength){
	for(var i=0;i<f.form.length;i++){
		if(f.form[i]==f){f.form[i+1].focus();break}
		}
	}
}
function Seleciona(item){	
	item.setAttribute('class','Selecionado');	
}					
function Desmarca(id){	
	var lis = document.getElementById(id).getElementsByTagName('li');
	for (var i=0; i < lis.length; i++){
		lis[i].setAttribute('class','');
	}
}					

//Função para a formatação dos campos.
function Mascara(tipo, campo, teclaPress) {
if (window.event)
{
var tecla = teclaPress.keyCode;
} else {
tecla = teclaPress.which;
}

var s = new String(campo.value);
//Remove todos os caracteres à seguir: ( ) / - . e espaço, para tratar a string denovo.
s = s.replace(/(\.|\(|\)|\/|\-| )+/g,'');

tam = s.length + 1;

if ( tecla != 9 && tecla != 8 ) {
switch (tipo)
{
case 'CPF' :
if (tam > 3 && tam < 7)
campo.value = s.substr(0,3) + '.' + s.substr(3, tam);
if (tam >= 7 && tam < 10)
campo.value = s.substr(0,3) + '.' + s.substr(3,3) + '.' + s.substr(6,tam-6);
if (tam >= 10 && tam < 12)
campo.value = s.substr(0,3) + '.' + s.substr(3,3) + '.' + s.substr(6,3) + '-' + s.substr(9,tam-9);
break;

case 'CNPJ' :

if (tam > 2 && tam < 6)
campo.value = s.substr(0,2) + '.' + s.substr(2, tam);
if (tam >= 6 && tam < 9)
campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,tam-5);
if (tam >= 9 && tam < 13)
campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '/' + s.substr(8,tam-8);
if (tam >= 13 && tam < 15)
campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '/' + s.substr(8,4)+ '-' + s.substr(12,tam-12);
break;

case 'TEL' :
if (tam > 2 && tam < 4)
campo.value = '(' + s.substr(0,2) + ') ' + s.substr(2,tam);
if (tam >= 7 && tam < 11)
campo.value = '(' + s.substr(0,2) + ') ' + s.substr(2,4) + '-' + s.substr(6,tam-6);
break;

case 'DATA' :
if (tam > 2 && tam < 4)
campo.value = s.substr(0,2) + '/' + s.substr(2, tam);
if (tam > 4 && tam < 11)
campo.value = s.substr(0,2) + '/' + s.substr(2,2) + '/' + s.substr(4,tam-4);
break;

case 'CEP' :
if (tam > 5 && tam < 7)
campo.value = s.substr(0,5) + '-' + s.substr(5, tam);
break;
}
}
}

//Função para verificar se o valor digitado é número.
function digitos(event){
if (window.event) {
//E
key = event.keyCode;
} else if ( event.which ) {
// netscape
key = event.which;
}
if ( key != 8 || key != 13 || key < 48 || key > 57 ){
return ( ( ( key > 47 ) && ( key < 58 ) ) || ( key == 8 ) || ( key == 13 ) );
}
return true;
}

function apenasNum(event, campo){

if(isNaN (campo)) {
alert("Digte apenas números!");
document.getElementById("registro").value = "";
}

  }
