//FUNZIONI COMUNI ALLA PROCEDURA AMTER (DIVERSE DA QUELLE PER LA GESTIONE OPERATORI

function doaction(p_parm)//stringa dei parametri
{	
	f_menu=false;
	if (p_parm!='')
		{
		a_temp=new Array();
		a_temp=p_parm.split('|');
		for(i=0;i<a_temp.length;i++)
			{
				a_parm=new Array();
				a_parm=a_temp[i].split('=');
				var elem_name=a_parm[0];
				if(this.document.getElementsByName(elem_name)[0])
					{
					var elem=this.document.getElementsByName(elem_name)[0];
					var new_value=a_parm[1];
					//var elem=this.document.getElementById(par[0]).value=par[1];
					//SE L'ORDINAMENTO E' GIA IMPOSTATO SUL VALORE CORRENTE
					//INVERTE L'ORDINAMENTO (DESC)
					if(elem_name=="sort" && elem.value==new_value)
						new_value+=" DESC";
					elem.value=new_value;
					}
			}
		}
	this.document.mainform.submit();
}

function is_return(e)
{	
	var keynum;
	if(window.event) // IE
		 keynum = e.keyCode;
	else if(e.which) // Netscape/Firefox/Opera
		 keynum = e.which;
	if (keynum==13) return true;//13 è il valore del RETURN
	else return false;
}



function is_tab_press(e)
{
	var keynum = e.keyCode;
	if (keynum==9)
		return true;//9 è il valore del TAB
	else 
		return false;
}

function ask_conf(p_conf,p_parm){
	if(confirm(p_conf))
		doaction(p_parm);
}

function initparm()
{	
	var a_parm=new Array("link", "args", "oper", "sort", "qstr", "move", "npag");
	var i=0;
	for (i=0;i<a_parm.length;i++){
		if (this.document.getElementById(a_parm[i])){
			this.document.getElementById(a_parm[i]).value="";
				//alert(param[i]+" = "+this.document.getElementById(param[i]).value);
		}
	}
	//INIZIALIZZA IL NUMERO DI PAGINA CORRENTE E IL NUMERO 
	//DI RECORD PER PAGINA AI VALORI DI DEFAULT
	if(this.document.getElementById("npag"))
		{
			this.document.getElementById("npag").value=1;
		}
		
	if(this.document.getElementById("rpag"))
		{
			this.document.getElementById("rpag").value="10";
			//alert("RECPAG = "+this.document.getElementById("recpag").value);
		}
	if(this.document.getElementById("init"))
		{
			this.document.getElementById("init").value="1";
		}
	
}

function is_modified(id,is_upper_case)
{	//alert("IS_MODIFIED");
	if (is_upper_case==1) upper_case(id);
	this.document.getElementById("fmod").value='true';
	//this.document.getElementById("BlockClick").value='true';
}

function set_codice(id,codi_)
	{	
	if(this.document.getElementById(id).value=='') return;
	this.document.getElementById(codi_).setAttribute("value",this.document.getElementById(id).options[this.document.getElementById(id).selectedIndex].getAttribute("codice"));
	}
//funzione che sostituisce la replace global di javascript che non funziona per farci dispetto	
function replace_all(p_vals, p_oldc, p_newc)
{
	while(p_vals.indexOf(p_oldc)>=0)
	{
		p_vals=p_vals.replace(p_oldc, p_newc);
	}
	return p_vals;
}

function butt_log(butt_id)
	{	
	if(this.document.getElementById('Accesso'))
		this.document.getElementById('Accesso').value = butt_id;
	if(this.document.getElementById('cont'))
		this.document.getElementById('cont').value = "home";
	this.document.mainform.submit();
}
