function changePicHome(id,txt){
		document.getElementById("homePic").innerHTML='<img src="img.php?ft=img&ext=ext&id='+id+'">';
		document.getElementById("homeTxt").innerHTML=txt;
//		document.getElementById("homeMenu"+id+"Item").style.background=url('interface/imagens/home_submenu_in_01.jpg');
}

function mascaraCPF(campoCPF,campoNext){
	var cpf = document.cadastro[campoCPF].value;
	if (cpf.length == 3){
		cpf = cpf + '.';
		document.cadastro[campoCPF].value = cpf;
		return true;
	}
	if (cpf.length == 7){
		cpf = cpf + '.';
		document.cadastro[campoCPF].value = cpf;
		return true;
	}
	if (cpf.length == 11){
		cpf = cpf + '-';
		document.cadastro[campoCPF].value = cpf;
		return true;
	}
	if (cpf.length == 14 && campoNext == "xx"){
		document.cadastro.submit();
		return true;
	}
	if (cpf.length == 14 && campoNext != "" && campoNext != "xx"){
		document.cadastro[campoNext].focus();
		return true;
	}
}

function mascaraCNPJ(campoCNPJ,campoNext){
	var cnpj = document.cadastro[campoCNPJ].value;
	if (cnpj.length == 2){
		cnpj = cnpj + '.';
		document.cadastro[campoCNPJ].value = cnpj;
		return true;
	}
	if (cnpj.length == 6){
		cnpj = cnpj + '.';
		document.cadastro[campoCNPJ].value = cnpj;
		return true;
	}
	if (cnpj.length == 10){
		cnpj = cnpj + '/';
		document.cadastro[campoCNPJ].value = cnpj;
		return true;
	}
	if (cnpj.length == 15){
		cnpj = cnpj + '-';
		document.cadastro[campoCNPJ].value = cnpj;
		return true;
	}
	if (cnpj.length == 18 && campoNext != ""){
		document.cadastro[campoNext].focus();
		return true;
	}
}

function mascaraCEP(campoCEP,campoNext){
	var cep = document.cadastro[campoCEP].value;
	if (cep.length == 5){
		cep = cep + '-';
		document.cadastro[campoCEP].value = cep;
		return true;
	}
	if (cep.length == 9 && campoNext != ""){
		document.cadastro[campoNext].focus();
		return true;
	}
}

function mascaraData(campoData,campoNext){
	var data = document.cadastro[campoData].value;
	if (data.length == 2){
		data = data + '/';
		document.cadastro[campoData].value = data;
		return true;
	}
	if (data.length == 5){
		data = data + '/';
		document.cadastro[campoData].value = data;
		return true;
	}
	if (data.length == 10 && campoNext != ""){
		document.cadastro[campoNext].focus();
		return true;
	}
}

function mascaraHora(campoHora,campoNext){
	var hora = document.cadastro[campoHora].value;
	if (hora.length == 2){
		hora = hora + ':';
		document.cadastro[campoHora].value = hora;
		return true;
	}
	if (hora.length == 5 && campoNext != ""){
		document.cadastro[campoNext].focus();
		return true;
	}
}

function mascaraFone(campoFone){
	var fone = document.cadastro[campoFone].value;
	if (fone.length == 2){
		fone = fone + ' ';
		document.cadastro[campoFone].value = fone;
		return true;
	}
}

function FormataValor(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
			document.form[campo].value = vr ; }
		if ( (tam > 2) && (tam <= 5) ){
			document.form[campo].value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
		if ( (tam >= 6) && (tam <= 8) ){
			document.form[campo].value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
		if ( (tam >= 9) && (tam <= 11) ){
			document.form[campo].value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
		if ( (tam >= 12) && (tam <= 14) ){
			document.form[campo].value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
		if ( (tam >= 15) && (tam <= 17) ){
			document.form[campo].value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;}
	}
		
	for (var ct = 0; ct < document.form.elements.length; ct++) {
		if (document.form.elements[ct].name == document.form.elements[campo].name) {
			if ( !teclapres.shiftKey && tecla == 9 && document.form.elements[ct+1] && document.form.elements[ct+1].name == "senhaConta" && document.applets['tclJava'] ){
				document.applets['tclJava'].setFocus();
			}	
		}
	}
}

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

			function DisplayInfo(pagina,janela,w,h) {
			 	window.open(pagina,janela,"width="+w+",height="+h+",scrollbars=auto,toolbar=no,location=no,status=yes,menubar=yes,resizable=yes,left=50,top=50")
			}

			function imprimir(id) {
			 DisplayInfo("imprimir.php?id="+id,"imprimir",600,500,"yes","no");
			}

			function artigos (cid) {
				 location.replace('$config[site]artigos.php?in=lista&cid='+cid);
			}
			
			function DisplayInfo(pagina,janela,w,h,scrolling) {
			 if (!scrolling) { scrolling="auto" } resultado = window.open(pagina,janela,"width="+w+",height="+h+",scrollbars="+scrolling+",toolbar=no,location=no,status=yes,menubar=yes,resizable=yes,left=5,top=5")
			}
	
	
			function boldThis(from) { 
				strSelection = document.selection.createRange().text 
				if (strSelection == "") { 
				return false; 
				} 
				else document.selection.createRange().text = "<b>" + strSelection 
				+ "</b>" 
				return;
			}
			
			function italicThis(from) { 
				strSelection = document.selection.createRange().text 
				if (strSelection == "") { 
				return false; 
				} 
				else document.selection.createRange().text = "<i>" + strSelection 
				+ "</i>" 
				return;
			}
			
			function underlineThis(from) { 
				strSelection = document.selection.createRange().text 
				if (strSelection == "") { 
				return false; 
				} 
				else document.selection.createRange().text = "<u>" + strSelection 
				+ "</u>" 
				return;
			}
			
			function changecolor(t) { 
				strSelection = document.selection.createRange().text 
				if (strSelection == "") { 
				return false; 
				} 
				else document.selection.createRange().text = "<font" + " color" +"=" +t+">" + strSelection 
				+ "</font>" 
				return;
			}
			
			function changesize(t) { 
				strSelection = document.selection.createRange().text 
				if (strSelection == "") { 
				return false; 
				} 
				else document.selection.createRange().text = "<font" + " class" +"=" +t+">" + strSelection 
				+ "</font>" 
				return;
			}

			function nbspThis(from) { 
				strSelection = document.selection.createRange().text 
				if (strSelection == "") { 
				alert("Selecione um caracter.."); 
				} 
				else document.selection.createRange().text = "&nbsp; &nbsp; " 
				return;
			}
			
			function produtos (tipo,id,cid){
			  if(tipo == '1') {
				 location.replace('$config[site]admin/?on=produtos&in=novo_prod&cid='+cid);
			  } else {
				 location.replace('$config[site]admin/?on=produtos&in=editar_produto&id='+id+'&cid='+cid);
			  }
			}

		    function clearall (form) {
				form.reset();
		    }

			function changeLine(name,opt){
				var lista = document.getElementsByName(name);
				for (i=0; i<lista.length; i++){
				  lista[i].style.background = opt;
				}
			}
			