function attScroll(gpx){
	scrollBy(0,gpx);
	document.getElementById("nome").focus();
}
function clearScroll(){
	clearInterval(inizia);
	clearInterval(p_fine);
}
function scrolla_f(pxa){
	scrollBy(0,pxa);
	document.getElementById("nome").focus();
}
function imposta(tipo,ext){
	document.getElementById("alfabeto").value=tipo;
	//alert(ext);
	alerta(ext);
}
function azzera_campi(){
	document.getElementById("codice").innerHTML="";
	document.getElementById("cod_html").innerHTML="";
	document.getElementById("cod_bb").innerHTML="";
}
function scrivi(alfa,campo,lunghezza,ext){
	
	var c_html = '';
	var c_bb   = '';
	var char_finale = '';
	var estensione = '';
	var mc = document.getElementById("macro_categoria").value;

	for(x=0;x<lunghezza;x++){

		campo.charAt(x)!=' ' ? let_f = alfa+'/images/'+campo.charAt(x).toUpperCase()+'.'+ext : let_f = '../_images/spazio.gif' ;

		img     = '<img src="'+let_f+'" border="0" alt="'+campo.charAt(x)+'">';
		document.getElementById("codice").innerHTML+=img;
		imgbb   = '[img]http://www.megghy.com/gif_animate/'+mc+'/'+alfa+'/images/'+campo.charAt(x).toUpperCase()+'.'+ext+'[/img]';
		imghtml = '&lt;img src="http://www.megghy.com/gif_animate/'+mc+'/'+alfa+'/images/'+campo.charAt(x).toUpperCase()+'.'+ext+'" border="0"/&gt;';

		c_html += imghtml;
		c_bb   += imgbb;
	    char_finale += campo.charAt(x);

	}

		if(campo==''){
			azzera_campi();
		}else{
			document.getElementById("cod_html").innerHTML = c_html;
			document.getElementById("cod_bb").innerHTML   = '[url=http://www.megghy.com/gif_animate/crea_nomi_alfabeti.htm]'+c_bb+'[/url]';
		}

	document.getElementById("nome").value = char_finale;

}

function alerta(ext){

	var myRegex = /\D/i;
	var alfa   = document.getElementById("alfabeto").value;
	var campo  = document.getElementById("nome").value;
	var char_finale = '';
	var lung_campo = campo.length;
	
	azzera_campi();

	if(myRegex.test(campo.charAt(lung_campo-1))){

		scrivi(alfa,campo,(campo.length),ext);
	
	//Se e numero segnalo con alert carattere non valido
	}else{
		
		scrivi(alfa,campo,(campo.length-1),ext);
		if(campo!=''){
			alert('Hai inserito un carattere non valido');
		}
		
	}

}