/**
 * /_codice/_standard.js
 *
 * @author 		Fabio Mosti
 *
 * @description 	questo file include tutte le funzioni javascript dello standard
 *
 * @modified		2007-09-04 v5.4 Fabio Mosti
 *			aggiunto commento in testa al file
 *
 */

// funzioni per mostrare/nascondere elementi sulla pagina
    function showhide_textonly(sec) {
	    var sectionid = document.getElementById(sec);	// ricava l'id della sezione

	    if (sectionid.style.display == '')		// se la sezione e' gia' espansa
	        {
		    sectionid.style.display='none';	// nascondi la sezione...
	        }
	    else
	        {
		    sectionid.style.display='';		// mostra la sezione...
	        }
	}

    function showonly(sec) {
	    var sectionid = document.getElementById(sec);
	    sectionid.style.display='';
	}

    function hideonly(sec) {
	    var sectionid = document.getElementById(sec);
	    sectionid.style.display='none';
	}

// funzioni per le password
    function calcolaForzaPw() {
	    var pw = document.getElementById('newPasw0').value;

	    var pwlength = (pw.length);
	    if (pwlength > 5)
	        pwlength = 5;

	    var numnumeric = pw.replace (/[0-9]/g, "");
	    var numeric = (pw.length - numnumeric.length);
	    if (numeric > 3)
	        numeric = 3;

	    var symbols = pw.replace (/\W/g, "");
	    var numsymbols = (pw.length - symbols.length);
	    if (numsymbols > 3)
	        numsymbols = 3;

	    var numupper = pw.replace (/[A-Z]/g, "");
	    var upper = (pw.length - numupper.length);
	    if (upper > 3)
	        upper = 3;

	    var pwstrength = ((pwlength * 10) - 20) + (numeric * 10) + (numsymbols * 15) + (upper * 10);

	    if (pwstrength < 0)
	        pwstrength = 0;

	    if (pwstrength > 100)
	        pwstrength = 100;

	    return pwstrength;
	}

// funzioni per i popup
    function popup(img,lvl,dida) {
	    z=window.open(lvl + "_lib/_popUpImg.php?img="+img+"&dida="+dida,"zoom","scrollbar=no");
	    z.focus();
	}


function addwarning()
    {
	var thealinks = document.getElementsByTagName("span");
	if (!thealinks) { return; }

	for(var x=0;x!=thealinks.length;x++)
	    {
		if(thealinks[x].className == "addToolTip")
		    {
			thealinks[x].setAttribute("tooltiptext",thealinks[x].title);
			thealinks[x].removeAttribute("title");
			thealinks[x].onmouseover = function gomouseover() {ddrivetip(this.getAttribute("tooltiptext"))};
			thealinks[x].onmouseout = function gomouseout() {hideddrivetip();};
		    }
	    }
    }

function ietruebody()
    {
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
    }

function ddrivetip(thetext, thewidth, thecolor)
    {
	if (ns6||ie)
	    {
		if (typeof thewidth!=="undefined") {tipobj.style.width=thewidth+"px";}
		if (typeof thecolor!=="undefined" && thecolor!=="") {tipobj.style.backgroundColor=thecolor;}
		tipobj.innerHTML=thetext;
		enabletip=true;
		return false;
	    }
    }

function positiontip(e)
    {
	if (enabletip)
	    {
		var nondefaultpos=false;
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20;
		var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20;

		var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX;
		var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY;

		var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000;

		if (rightedge<tipobj.offsetWidth)
		    {
			tipobj.style.left=curX-tipobj.offsetWidth+"px";
			nondefaultpos=true;
		    }
		else if (curX<leftedge)
		    {
			tipobj.style.left="5px";
		    }
		else
		    {
			tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px";
			pointerobj.style.left=curX+offsetfromcursorX+"px";
		    }

		if (bottomedge<tipobj.offsetHeight)
		    {
			tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px";
			nondefaultpos=true;
		    }
		else
		    {
			tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px";
			pointerobj.style.top=curY+offsetfromcursorY+"px";
		    }
		tipobj.style.visibility="visible";
		if (!nondefaultpos)
		    {
			pointerobj.style.visibility="visible";
		    }
		else
		    {
			pointerobj.style.visibility="hidden";
		    }
	    }
    }

function hideddrivetip()
    {
	if (ns6||ie)
	    {
		enabletip=false;
		tipobj.style.visibility="hidden";
		pointerobj.style.visibility="hidden";
		tipobj.style.left="-1000px";
		tipobj.style.backgroundColor='';
		tipobj.style.width='';
	    }
    }


