<!--

function winopen(url,l,t,w,h) {
	var hWnd = window.open(url,"openWindow"+get_rnd_win(8),"left="+l+", top="+t+" ,width="+w+",height="+h+",resizable=yes,scrollbars=yes,menubar=yes");
	if (!hWnd.opener) hWnd.opener = self;
	if (hWnd.focus != null) hWnd.focus();
}

// winopen per il calendario
function winopenCAL(url,l,t,w,h) {
	var hWnd = window.open(url,"openWindow"+get_rnd_win(8),"left="+l+", top="+t+" ,width="+w+",height="+h+",resizable=yes,scrollbars=yes,menubar=no");
	if (!hWnd.opener) hWnd.opener = self;
	if (hWnd.focus != null) hWnd.focus();
}

	function get_rnd_win(ncar) {
		var alfa = "abcdefghijklmnopqrstuvwxyz0123456789";
		var ret = "";
		var pos;
		for (i = 0; i < ncar; i++) {
			pos = Math.floor( Math.random() * ((alfa.length - 1 ) - ((i==0) ? 9 : 0))); // se e' il primo, esclude le cifre
			ret += alfa.charAt(pos);
		}
		return ret;
	}

// winopen autocentrante sul click del mouse
function winopenAC(url,evn,w,h,opt) {
	if (!opt) {
		opt="toolbar=no,location=no,directories=no,status=no,resizable=yes,scrollbars=yes,menubar=no";
	}
	var dimx = w;
	var dimy = h;
	var x = evn.screenX;
	var y = evn.screenY;
	x = x - parseInt(dimx/2); // correzione per la centratura mouse
	y = y - parseInt(dimy/2); // correzione per la centratura mouse
	var hWnd = window.open(url,"Window_client"+get_rnd_win(8),"left="+x+", top="+y+",width="+dimx+",height="+dimy+","+opt);
	if (!hWnd.opener) hWnd.opener = self;
	if (hWnd.focus != null) hWnd.focus();
}

// winopen alto-sinistra sul click del mouse
function winopenAS(url,evn,w,h) {
	var x = evn.screenX;
	var y = evn.screenY;
	var hWnd = window.open(url,"Window_client"+get_rnd_win(8),"left="+x+",top="+y+",width="+w+",height="+h+",toolbar=no,location=no,directories=no,status=no,resizable=yes,scrollbars=yes,menubar=no");
	if (!hWnd.opener) hWnd.opener = self;
	if (hWnd.focus != null) hWnd.focus();
}

// winopen basso-destra sul click del mouse
function winopenBD(url,evn,w,h) {
	var x = evn.screenX - w;
	var y = evn.screenY - h;
	var hWnd = window.open(url,"Window_client"+get_rnd_win(8),"left="+x+",top="+y+",width="+w+",height="+h+",toolbar=no,location=no,directories=no,status=no,resizable=yes,scrollbars=yes,menubar=no");
	if (!hWnd.opener) hWnd.opener = self;
	if (hWnd.focus != null) hWnd.focus();
}
// winopen basso-sx sul click del mouse
function winopenBS(url,evn,w,h) {
	var x = evn.screenX;
	var y = evn.screenY - h;
	var hWnd = window.open(url,"Window_client"+get_rnd_win(8),"left="+x+",top="+y+",width="+w+",height="+h+",toolbar=no,location=no,directories=no,status=no,resizable=yes,scrollbars=yes,menubar=no");
	if (!hWnd.opener) hWnd.opener = self;
	if (hWnd.focus != null) hWnd.focus();
}
// attiva/disattiva il layer
function swap(lay,evn) {
	var objl;
	var x,y;
	if (document.all) { // MS IE 6
		objl=document.all[lay];
		x = evn.clientX + document.body.scrollLeft;
		y = evn.clientY + document.body.scrollTop;
	} else if (document.getElementById) { // mozilla firefox
		objl=document.getElementById(lay);
		x=evn.pageX;
		y=evn.pageY;
	}
	objl.style.visibility = (objl.style.visibility=="visible") ? "hidden" : "visible";
	objl.style.left = x + 2;
	objl.style.top = y + 2;
}

// attiva/disattiva il layer con puntatore verso sx
function swapSX(lay,evn,width) {
	var objl;
	var x,y;
	if (document.all) { // MS IE 6
		objl=document.all[lay];
		x = evn.clientX + document.body.scrollLeft;
		y = evn.clientY + document.body.scrollTop;
	} else if (document.getElementById) { // mozilla firefox
		objl=document.getElementById(lay);
		x=evn.pageX;
		y=evn.pageY;
	}
	objl.style.visibility = (objl.style.visibility=="visible") ? "hidden" : "visible";
	objl.style.left = x - width;
	objl.style.top = y + 2;
}

// recupera l'oggetto del form contenuto dentro il layer
function rif_lay(lay,formname,campo) {
	var obj;
	if (document.all) { // MS IE 6
		obj=document.all[lay];
	} else if (document.getElementById) { // mozilla firefox
		obj=document.getElementById(lay);
	}
	alert(document.forms[formname].elements[campo].value);
}

// richiama lo swap per il nodo d'albero
function tnswap(lay,cookie_name,set_val) {
	sswap(lay);
	var cv=GetCookieData(cookie_name); // recupera il valore attuale del cookie
	var ln=cv.split(","); // split degli id nodi
	var nc=''; // nuovo valore cookie
	var flag=false;
	for (var j = 0; j < ln.length; j++) {
		if (ln[j]==set_val) {
			flag=true;
		}
		nc += (ln[j]==set_val) ? "" : (ln[j] + ",");
	}
	if (!flag) {
		nc+=set_val;
	}
	SetCookie (cookie_name,nc,null,"/");
}

// attiva/disattiva il layer (modalita' semplice, senza riferimenti mouse)
function sswap(lay) {
	var objl;
	if (document.all) { // MS IE 6
		objl=document.all[lay];
	} else if (document.getElementById) { // mozilla firefox
		objl=document.getElementById(lay);
	}
	objl.style.visibility = (objl.style.visibility=="visible") ? "hidden" : "visible";
	objl.style.display = (objl.style.display=="block") ? "none" : "block";
}

// swap color sul layer (NON VA: controllare
function swapCol(lay,col1,col2) {
	var objl;
	if (document.all) { // MS IE 6
		objl=document.all[lay];
	} else if (document.getElementById) { // mozilla firefox
		objl=document.getElementById(lay);
	}
	objl.style.backgroundColor = (objl.style.backgroundColor==col1) ? col2 : col1;
}

// stato dell'albero
function treestate(lay) {
	var tobj;
	if (document.all) { // MS IE 6
		tobj=document.all[lay];
	} else if (document.getElementById) { // mozilla firefox
		tobj=document.getElementById(lay);
	}
	alert(tobj.length);
}
	
// copiate da js bible
function GetCookieData(labelName) {
	var labelLen = labelName.length;
	// read cookie property only once for speed
	var cookieData = document.cookie;
	var cLen = cookieData.length;
	var i = 0;
	var cEnd;
	while (i < cLen) {
		var j = i + labelLen;
		if (cookieData.substring(i,j) == labelName) {
			cEnd = cookieData.indexOf(";",j);
			if (cEnd == -1) {
				cEnd = cookieData.length;
			}
			return unescape(cookieData.substring(j+1, cEnd));
		}
		i++;
	}
	return "";
}

function SetCookie (name,value,expires,path,domain,secure) {
	document.cookie = name + "=" + escape (value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
}

function writelay(lay, testo) {
	if (document.all) { // MS IE 6
		tobj=document.all[lay];
	} else if (document.getElementById) { // mozilla firefox
		tobj=document.getElementById(lay);
	}
	tobj.innerHTML = testo;
}

//-->