<!--
function openNewWin(theURL,winName,features) {
  // alert("URL = " + theURL);
	theURL = escape(theURL);
	winnews = window.open('popupwin.php?file='+theURL,winName,features);
}

function openPDF(filename) {
	filename = unescape(filename);
	filename = filename.replace(/ /g,"+");
	filename = escape(filename);
	thisURL = document.location.href;
	startindex = thisURL.indexOf(document.domain) + document.domain.length;
	endindex = thisURL.lastIndexOf("/")+1;
	docfolder = thisURL.slice(startindex,endindex) + "documenti/shared/";
	theURL = escape(docfolder + filename + '#page=1&FitH');
	winnews = window.open('popupwin.php?file='+theURL,'primopiano','scrollbars=yes,width=800,height=600,top=10,left=10,resizable=yes');
}

function openPopup(popup) {
	winpopup = window.open(popup,'image','width=500,height=300,scrollbars=no,toolbar=no,location=no,status=no,resizable=yes,left=100,top=100');
}

function displayImg(winName,img,imgt,imgw,imgh) {
	features = 'width=400,height=400,top=0,left=0,resizable=yes,scrollbars=no,status=no,menubar=no';
	winnews = window.open('popupimg.php?img='+img+'&imgt='+imgt+'&imgw='+imgw+'&imgh='+imgh+'&scrw='+screen.width+'&scrh='+screen.height,winName,features);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function formFocus() {
	var bFound = false;
	for (f=0; f < document.forms.length; f++) {										// for each form
		for(i=0; i < document.forms[f].length; i++) {								// for each element in each form
			if (document.forms[f][i].type != "hidden") {							// if it's not a hidden element
				if (document.forms[f][i].disabled != true) {  					// and it's not disabled
					if (document.forms[f].putfocus) {											// and putfocus is not defined
						if (document.forms[f].putfocus.value == "put") {		// and putfocus is defined and = put
							document.forms[f][i].focus();											// set the focus to it
							var bFound = true;
						}
					}
				}
			}
			if (bFound) break;																// if found in this element, stop looking
		}
		if (bFound)  break;																	// if found in this form, stop looking
	}
	 if (!bFound) window.focus();
}

function formMessage() {
	if (document.statusform) {
		if (document.statusform.msg) {
			if (document.statusform.msg.value != "")  alert(document.statusform.msg.value);
		}
	}
}

function htmlEntities(text) { // equivalent to PHP similar function
	transTable = {"¡":"&iexcl;", "¢":"&cent;", "£":"&pound;", "¤":"&curren;",
								"¥":"&yen;", "¦":"&brvbar;", "§":"&sect;", "¨":"&uml;", "©":"&copy;",
								"ª":"&ordf;", "«":"&laquo;", "":"&not;", "­":"&shy;", "®":"&reg;",
								"¯":"&macr;", "°":"&deg;", "±":"&plusmn;", "²":"&sup2;", "³":"&sup3;",
								"´":"&acute;", "µ":"&micro;", "":"&para;", "•":"&middot;", "¸":"&cedil;",
								"¹":"&sup1;", "º":"&ordm;", "»":"&raquo;", "¼":"&frac14;", "½":"&frac12;",
								"¾":"&frac34;", "¿":"&iquest;", "À":"&Agrave;", "Á":"&Aacute;", "Â":"&Acirc;",
								"Ã":"&Atilde;", "Ä":"&Auml;", "Å":"&Aring;", "Æ":"&AElig;", "Ç":"&Ccedil;",
								"È":"&Egrave;", "É":"&Eacute;", "Ê":"&Ecirc;", "Ë":"&Euml;", "Ì":"&Igrave;",
								"Í":"&Iacute;", "Î":"&Icirc;", "Ï":"&Iuml;", "Ð":"&ETH;", "Ñ":"&Ntilde;",
								"Ò":"&Ograve;", "Ó":"&Oacute;", "Ô":"&Ocirc;", "Õ":"&Otilde;", "Ö":"&Ouml;",
								"×":"&times;", "Ø":"&Oslash;", "Ù":"&Ugrave;", "Ú":"&Uacute;", "Û":"&Ucirc;",
								"Ü":"&Uuml;", "Ý":"&Yacute;", "Þ":"&THORN;", "ß":"&szlig;", "à":"&agrave;",
								"á":"&aacute;", "â":"&acirc;", "ã":"&atilde;", "ä":"&auml;", "å":"&aring;",
								"æ":"&aelig;", "ç":"&ccedil;", "è":"&egrave;", "é":"&eacute;", "ê":"&ecirc;",
								"ë":"&euml;", "ì":"&igrave;", "í":"&iacute;", "î":"&icirc;", "ï":"&iuml;",
								"ð":"&eth;", "ñ":"&ntilde;", "ò":"&ograve;", "ó":"&oacute;", "ô":"&ocirc;",
								"õ":"&otilde;", "ö":"&ouml;", "÷":"&divide;", "ø":"&oslash;", "ù":"&ugrave;",
								"ú":"&uacute;", "û":"&ucirc;", "ü":"&uuml;", "ý":"&yacute;", "þ":"&thorn;",
								"ÿ":"&yuml;", "\"":"&quot;", "<":"&lt;", ">":"&gt;", "&":"&amp;"};
	newtext='';
	for(i=0;i<text.length;i++) {
		char = text.charAt(i);
		if (char in transTable) {
			newtext += transTable[char];
		} else {
			newtext += char;
		}
	}
	return newtext;
}

function addslashes(str) {
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');
	return str;
}

function stripslashes(str) {
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\\\/g,'\\');
	str=str.replace(/\\0/g,'\0');
	return str;
}
//-->