/*  cancellazione automatica nelle form del testo inserito nelle input  */
function autoClear(obj,def){
	if (obj.value==def) obj.value=""
}
/* inserisce la possibilità di aprire dei popup se il link ha la classe chiamata blank  */
function inizializza() {
var a = document.getElementsByTagName('A');
for(var i=0;a[i];i++) if(a[i].className.indexOf('blank') != -1) {
a[i].title += " [il collegamento apre una nuova finestra]";
a[i].onclick = function () {window.open(this.href, '_blank');return false;};
a[i].onkeypress = function (e) {
k = (e) ? e.keyCode : window.event.keyCode;
if(k==13) {
window.open(this.href, '_blank');
return false;
}
}
}
}
/* abilita nelle tabelle con la class nella table uguale a righealterne, il colore delle righe alternativamente */
function ColoraRighe(){
var tabelle=document.getElementsByTagName("table");
for(i=0;i<tabelle.length;i++){
    if(tabelle[i].className.indexOf("righealterne")>=0){
        trs=tabelle[i].tBodies[0].rows;
        for(j=1;j<trs.length;j+=2)
            trs[j].className="alterna";
        }
    }
}

/* parse the entered query String */
function parseSearchQuery(theForm, message) {
	var queryValue = theForm.elements["query2"].value;
	var testValue = queryValue.replace(/ /g, "");
	if (testValue.length < 3) {
		alert(message);
		return (false);
	}
	theForm.elements["query"].value = queryValue;
	return (true);
}

/* open the print version popup window */
function openPrintVersion() {
	var params = "print=true";
	if (document.location.search != "") {
		params = document.location.search + "&" + params;		
	} else {
		params = "?" + params;
	}
	window.open(document.location.pathname + params, "print", "width=670,height=750,dependent=yes,status=no,toolbar=no,location=no,scrollbars=yes");
}

/* open the imprint popup window */
function openImprint(imprintUri, pageUri, theLocale, site) {
	pageUri = encodeURIComponent(pageUri); 
	pageUri = "?__locale=" + theLocale + "&uri=" + pageUri + "&site=" + site;
	window.open(imprintUri + pageUri, "imprint", "width=670,height=550,dependent=yes,status=no,toolbar=no,location=no,scrollbars=yes,resizable=yes");
}

/* open the recommend page form popup window */
function openRecommendForm(recommendUri, pageUri, theLocale, site) {	
	if (window.location.search != "") {
		pageUri += window.location.search;		
	}
	pageUri = encodeURIComponent(pageUri); 
	pageUri = "?__locale=" + theLocale + "&uri=" + pageUri + "&site=" + site;
	window.open(recommendUri + pageUri, "recommend", "width=670,height=700,dependent=yes,status=no,toolbar=no,location=no,scrollbars=yes,resizable=yes");
}

/* open the recommend page form popup window */
function openLetterForm(letterUri, pageUri, theLocale, site) {	
	if (window.location.search != "") {
		pageUri += window.location.search;		
	}
	pageUri = encodeURIComponent(pageUri); 
	pageUri = "?__locale=" + theLocale + "&uri=" + pageUri + "&site=" + site;
	window.open(letterUri + pageUri, "contact", "width=670,height=700,dependent=yes,status=no,toolbar=no,location=no,scrollbars=yes,resizable=yes");
}
