



// restituisce l'oggetto identificato dall'ID in input, null se non esiste
function ElementById( id ) {
 // caso stringa
 if (typeof(id)!="string") return id;
 // dom
 if (document.getElementById) { return document.getElementById(id);
 // IE
 } else if (element.all) { return element.all[id];
 // NN4
 } else if (element.layers) { return FindLayer(id, element); }
 return null;
}

// ricerca del layer (caso NN4)
function FindLayer(id, doc) {
 var i,layer;
 for (i=0; i<doc.layers.length; i++) {
   layer = doc.layers[i];
   if (layer.id==id) return layer;
   if (layer.document.layers.length > 0) {
     if ((layer=FindLayer(name, layer.document)) != null) return layer;
   }
 }
 return null;
}




function SelectAll( form_name, obj_id, val )
{
	f = document.forms[form_name] ;
	
	for (i=0 ; i<f.elements.length ; i++)
	{
		if(f.elements[i].id == obj_id)
			f.elements[i].checked = val ;
	}
}



function MM_popupMsg( msg )
{
    confirm(msg);
}



function LinkConfirm( link, msg )
{
    var confirmation = confirm( msg ) ;
    if (confirmation == true)
        window.location = link ;
}



function Link( link )
{
    window.location = link ;
}




function ChangeAndSubmit( form, field, val )
{
	ElementById( field ).value = val ;
   ElementById( form ).submit() ;
}



function ask_confirm( form, msg )
{
   var confirmation = confirm( msg );
	if (confirmation == true)
		ElementById( form ).submit() ;
}


function ask_change_confirm( form, field, val, msg )
{
    var confirmation = confirm( msg );
    if (confirmation == true)
    {
        ElementById( field ).value = val ;
        ElementById( form ).submit() ;
    }
}




function AskConfirm( msg, url )
{
	var confirmation = confirm( msg );
	if (confirmation == true)
		window.location = url ;
}


function AskFormConfirm( msg, form_name )
{
	var confirmation = confirm( msg );
	if (confirmation == true)
		document.forms[form_name].submit() ;
}

