function submit_form(nome_form,name_input)
{

	form_to_send = document.getElementById(nome_form);	

	form_to_send.submit();	
}


function copy_from_to(origine,destinazione)
{
	tmp1 = document.getElementById(origine);
	tmp2 = document.getElementById(destinazione);	
	tmp2.value = tmp1.value;
}

function cambia_abilitazione(nomepar)
{
	
	if(document.getElementById(nomepar).disabled == true) 
	{
		document.getElementById(nomepar).disabled = false;
		document.getElementById(nomepar).checked = true;		
	}
	else
	{
		document.getElementById(nomepar).disabled = true;
		document.getElementById(nomepar).checked = false;
	}

}

function controllo_campi(nome_form, array_label)
{
	var oForm = document.forms[nome_form];
	var trovati=0;
	
	for(var indispensabili=0; indispensabili < array_label.length; indispensabili++)	
		for(var input=0; input < oForm.elements.length; input++){						
			if( oForm.elements[input].name == array_label[ indispensabili ])
				if(oForm.elements[input].value!=""){	
					trovati +=1;
				}else{					
					return oForm.elements[input].name;
				}
			
		}		

	return "OK";
	
	
}


function convalida_input(nome_input)
{
	var str_tmp="";
	for(var i=0;i < document.getElementById(nome_input).textLength; i++)
		if(document.getElementById(nome_input).value.substr(i,1) == ' ')
			str_tmp+='-';
		else str_tmp+=document.getElementById(nome_input).value.substr(i,1);
	document.getElementById(nome_input).value = str_tmp;
}

function CheckSearch() {
    if( document.getElementById('parametro').value == ""){
        alert('Inserire una chiave di ricerca');
		return false;
    }
	else  {
	 document.cerca.submit();
	}
}

/*funzione generica  validazione  errori  front  end */
function clientErrorMsg(errNum){
		document.getElementById('resultForm').value = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><root><status code=\""+errNum+"\">KO</status></root>";			
}

function getFileExt(filename,isLower){

 var MyString = filename;

 
 if(MyString!=''){
   strPos=MyString.lastIndexOf('.')+1;
   if(isLower==1){
    	MyString=MyString.toLowerCase()
   }
   return MyString.substring(strPos)
 }
 else return "KO"
 
}


function apri(url, w, h) {
  	var windowprops = "width=" + w + ",height=" + h;
  popup = window.open(url,'remote',windowprops);
}




