// ****** HIDE OR SHOW A LAYER

function showhide(id){
if (document.getElementById){
obj = document.getElementById(id);
if (obj.style.display == "none"){
obj.style.display = "";
} else {
obj.style.display = "none";
}
}
}

// ****** SHOW A LAYER

function show(id){
if (document.getElementById){
obj = document.getElementById(id);
obj.style.display = "";
}
}

// ****** HIDE A LAYER

function hide(id){
if (document.getElementById){
obj = document.getElementById(id);
obj.style.display = "none";
}
}


// ****** ENABLE FORM ELEMENT

function enable(id){
if (document.getElementById){
obj = document.getElementById(id);
obj.disabled = false;
}
}

// ****** DISABLE FORM ELEMENT

function disable(id){
if (document.getElementById){
obj = document.getElementById(id);
obj.disabled = true;
}
}

// ****** POPUP FUNCTION
function apri(cosa,dove,larg,alt)
{
window.open(cosa,dove,'toolbar=1,location=1,directories=0,status=1,menubar=0,scrollbars=1,resizable=yes,width='+larg+',height='+alt+',left=10,top=10');
        }

// ****** POPUP FUNCTION
function openpopns(cosa,dove,larg,alt)
{
window.open(cosa,dove,'toolbar=1,location=1,directories=0,status=1,menubar=0,scrollbars=0,resizable=yes,width='+larg+',height='+alt+',left=10,top=10');
        }


// ****** AUTOCLOSE LOGOUT
function closepop(dove)
{
if (!opener) {self.location=dove }
	else {opener.location=dove;
self.close();
}
}
	        
// ****** CONFIRM FUNCTION
function confirm_dialog(message)
{
	return confirm(message)
}     

// ****** PUT OPENER FORM VALUE

function oputvalue(frmname,fielda,valuea){
		formobj=opener.document.forms[frmname];
		destfield=formobj[fielda];
		destfield.value=valuea;
}

// ****** GET OPENER FORM VALUE

function ogetvalue(frmname,fielda){
		formobj=opener.document.forms[frmname];
		destfield=formobj[fielda];
		return destfield.value;
}



// ****** CHANGE OPTIONS OF A PAGE USING PREFIX AND OPTION SELECTED
function prefix_navigation(prefix,selection){
var URL = selection.options[selection.selectedIndex].value;
window.location.href = prefix+URL;
//alert(prefix+URL);
};


// ******** ONLOAD HANDLING

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
};

// ******** ONRESIZE HANDLING

function addResizeEvent(func) {
  var oldonresize = window.onresize;
  if (typeof window.onresize != 'function') {
    window.onresize = func;
  } else {
    window.onresize = function() {
      oldonresize();
      func();
    }
  }
};

//  ***** left
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
};

// ****** right
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
};


function light(number,icon) {
document.images[icon].src=alt_img[number].src
};

function turnoff(number,icon) {
document.images[icon].src=off_img[number].src
};



function getcheckedValue(frmname,fielda) {
		formobj=document.forms[frmname];
		radioObj=formobj[fielda];
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}



function a0401sel(selector) {
	switch (selector.options[selector.selectedIndex].value) {
	case "":
	hide('grupopt');
	warnmsg="Selezionare un\'operazione";
	optgo=false;
	cgroup=false;
	break;
	case "1":
	warnmsg="volete ELIMINARE tutti gli utenti selezionati ??";
	optgo=true;
	cgroup=false;
	hide('grupopt');
	break;
	case "2":
	warnmsg="volete DISABILITARE tutti gli utenti selezionati ??";
	optgo=true;
	cgroup=false;
	hide('grupopt');
	break;
	case "3":
	warnmsg="volete ABILITARE tutti gli utenti selezionati ??";
	optgo=true;
	cgroup=false;
	hide('grupopt');
	break;
	case "4":
	warnmsg="volete ASSEGNARE tutti gli utenti selezionati al gruppo ";
	optgo=true;
	cgroup=true;
	show('grupopt');
	break;
	case "5":
	warnmsg="volete RIMUOVERE tutti gli utenti selezionati dal gruppo ";
	optgo=true;
	cgroup=true;
	show('grupopt');
	break;
		}
	}

function a0401conf() {

if (cgroup) {
	selector=document.a0401.grupopt;
	
	if (selector.options[selector.selectedIndex].value=="") {
		optgo=false;
		alert('Selezionare un gruppo');
		} else {
			optgo=true;
			warnmsg=warnmsg+selector.options[selector.selectedIndex].text;
			}
};


	if (optgo) {
optgo=confirm_dialog(warnmsg);
}
	return optgo;
	}
	
function posnl() {
position('DIV_NEWSBOX_LIST_ICON',-352,-3,'DIV_NEWSBOX_LIST')
	};
	
function hidenl() {
	hide('DIV_NEWSBOX_LIST');
	show('EVENTSBOX_NUMBER');
	show('EVENTSBOX_FAM');
	show('EVENTSBOX_CAT');
};

function shownl() {
	show('DIV_NEWSBOX_LIST');
	hide('EVENTSBOX_NUMBER');
	hide('EVENTSBOX_FAM');
	hide('EVENTSBOX_CAT');
};	

// ******* CONTROLLO DATI PERSONALI

function checkper() {
		formobj=document.forms['REGISTRATION'];
		destfield=formobj['pervalue'];
if (destfield.checked==true) {show('perdata')} else {hide('perdata')};
askper=destfield.checked;
	}