

function form1_validator(formid){

myform = document.getElementById(formid);
//controllo email
	if(myform.mittente.value == "" || myform.mittente.value.indexOf('@') < 0 || myform.mittente.value.indexOf('.') < 0 || myform.mittente.value.length < 6){
	    alert("Inserire un indirizzo e-mail valido");
	    myform.mittente.focus();
		return false;
  	}
	
	//controllo oggetto
	if (myform.oggetto.value == ""){
		alert("Inserire l'oggetto del messaggio");
		myform.oggetto.focus();
		return false;
	}
	
	//controllo testo
	if (myform.corpo.value == ""){
	    alert("Inserire il testo del messaggio");
	    myform.corpo.focus();
		return false;
	}
	
	myform.submit();
}
	
	//Diario gestione commenti archivio
	 var myDivs;
	 var divIndex = 0;
	 var divNum; 
	 var albumWin;
	 
	var heightRealPlayer;
	var heightMediaPlayer;
	var widthRealPlayer;
	var widthMediaPlayer;
	 
	 
	 window.onload=init;
	 
	 window.onresize = function(){
	 	resizeColDx();
	 	resizeCatalogo();
		centerPlayer();
	 }
	 
	 
	 window.onunload = function(){
	 	if (albumWin && !document.all) albumWin.close();
	 }
	 
	 
	 function init(){
		if (document.getElementById('slidecont')){
			var divFlag = false;
		
	 		myDivs = document.getElementById("slidecont").getElementsByTagName("DIV");
	 		divNum = myDivs.length;
			
			for(var i=0; i<myDivs.length;i++ ) if (myDivs[i].style.display=='block') {
				divIndex = i;
				divFlag = true;
			}
			
	  		if (!divFlag) {
				myDivs[divNum - 1].style.display='block';
				divIndex = divNum -1;
	  		}
			//window.setInterval("next();", 5000);
	  	}
		
		resizeColDx();
		if (document.getElementById('Album')){
			centerPlayer();		
		}
		
		
			if (document.all){
				hScreen = document.body.offsetHeight;
				wScreen = document.body.offsetWidth;
			}else{
				hScreen = window.innerHeight - 20;
				wScreen = window.innerWidth - 20;
			}	
			
			widthMediaPlayer = (wScreen-420)/1.8; 
			heightMediaPlayer = (widthMediaPlayer*0.97) ;
			
			
			heightRealPlayer=heightMediaPlayer;
			widthRealPlayer=widthMediaPlayer;
			heightRealPlayerToolbar="36";
			heightDiv = heightMediaPlayer + "px";
			widthDiv = widthMediaPlayer + 3 + "px";
		
		
		resizeCatalogo();
		
	 }
	 
	 function next(){
	  	nextDivIndex = (divIndex<divNum-1)?divIndex+1:0;
		for(var i=0; i<myDivs.length;i++ ) myDivs[i].style.display='none';
	 	myDivs[nextDivIndex].style.display='block';
	 	divIndex = nextDivIndex;
	 }
	 
	 function prev(){
	  	prevDivIndex = (divIndex>0)?divIndex-1:divNum-1;
	  	for(var i=0; i<myDivs.length;i++ ) myDivs[i].style.display='none';
	 	myDivs[prevDivIndex].style.display='block';
	 	divIndex = prevDivIndex;
	 }
	 
	 function resizeColDx(){
	 //alert("1");
		 if (document.all){
			hScreen = screen.height-150;
		}else{
			hScreen = window.innerHeight - 20;
		}
	 
		var hContent = document.getElementById('content').offsetHeight;
		var navBeta = document.getElementById('navBeta');
		var hNavBeta = document.getElementById('navBeta').offsetHeight;
		navBeta.style.height = (hContent>hScreen)?hContent+20+'px':hScreen +'px';
	 }
 
 	function resizeCatalogo(){
		var wContent = document.getElementById('content').offsetWidth;
		if(wContent>340){
			if (document.getElementById('categorySearch')) document.getElementById('categorySearch').style.width = wContent - 205+'px'
			if (document.getElementById('contButtonSearch')) document.getElementById('contButtonSearch').style.width = wContent - 205+'px'
			if (document.getElementById('titoloCategorieDx')) document.getElementById('titoloCategorieDx').style.width = wContent - 270+'px'
			if (document.getElementById('testoPrivacy')) document.getElementById('testoPrivacy').style.width = wContent - 80+'px'
		}	
	}

	
	/*funzioni di stampa dei player*/

	
	function PrintMediaPlayerVideo(file)
	{
		sOutput="";
		if (document.all){
			sOutput +='<OBJECT ID="WMPlay" CLASSID=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6   '
			sOutput +='	standby="Loading Microsoft Windows Media Player components..."      	'
			sOutput +='	TYPE="application/x-oleobject" width="+widthMediaPlayer+" height="'+heightMediaPlayer+'" VIEWASTEXT> 	'
			sOutput +='	<PARAM NAME="url" VALUE="' + file + '">                             	'
			sOutput +='	<PARAM NAME="AutoStart" VALUE="true">                               	'
			sOutput +='	<PARAM NAME="uiMode" VALUE="full">                                  	'
			sOutput +='	<PARAM NAME="stretchtofit" VALUE="true">                            	'
			sOutput +='	<embed name="WMPlay" id="WMPlay"             	'
			sOutput +='		type="application/x-mplayer2"                               		'
			sOutput +='		pluginspage="http://www.microsoft.com/windows/windowsmedia/"		'
			sOutput +='		SRC ="'+ file +'"                                           		'
			sOutput +='		displaysize="0"                                             		'
			sOutput +='		displaymode="0"                                             		'
			sOutput +='		showcontrols="1"                                            		'
			sOutput +='		showcontrols="1"                                           			'
			sOutput +='		showaudiocontrols="1"                                       		'
			sOutput +='		showpositioncontrols="1"                                    		'
			sOutput +='		showtracker="1"                                             		'
			sOutput +='		showstatusbar="1"                                           		'
			sOutput +='		animationatstart="0"                                        		'
			sOutput +='		autostart="1"                                               		'
			sOutput +='		transparentatstart="0"                                      		'
			sOutput +='		width="'+widthMediaPlayer+'"                                        '
			sOutput +='		height="'+heightMediaPlayer+'"                                      '
			sOutput +='	</embed>                                                            	'
			sOutput +='</OBJECT>		                                                    	'		

			document.getElementById('divPlayer').innerHTML = sOutput;
			document.getElementById('divPlayer').style.width = widthDiv;
			document.getElementById('divPlayer').style.height = heightDiv;
		}else{
			//albumWin = openWin( file , 'multimediaMozzilla', 'width=10,height=10,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0' );
			//setTimeout ("albumWin.close()", 6000 );
			window.open(file);
		}
	}
	
	function PrintMediaPlayerAudio(file)
	{
		sOutput="";
		if (document.all){
			sOutput +='<OBJECT ID="WMPlay" CLASSID=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6   '			
			sOutput +='	standby="Loading Microsoft Windows Media Player components..."      	'
			sOutput +='	TYPE="application/x-oleobject" width="'+widthMediaPlayer+'" height="'+heightMediaPlayer+'" VIEWASTEXT> 	'
			sOutput +='	<PARAM NAME="url" VALUE="' + file + '">                             	'
			sOutput +='	<PARAM NAME="AutoStart" VALUE="true">                               	'
			sOutput +='	<PARAM NAME="uiMode" VALUE="full">                                  	'
			sOutput +='	<PARAM NAME="stretchtofit" VALUE="true">                            	'
			sOutput +='	<embed name="WMPlay" id="WMPlay"             	'
			sOutput +='		type="application/x-mplayer2"                               		'
			sOutput +='		pluginspage="http://www.microsoft.com/windows/windowsmedia/"		'
			sOutput +='		SRC ="'+ file +'"                                           		'
			sOutput +='		displaysize="0"                                             		'
			sOutput +='		displaymode="0"                                             		'
			sOutput +='		showcontrols="1"                                            		'
			sOutput +='		showcontrols="1"                                           			'
			sOutput +='		showaudiocontrols="1"                                       		'
			sOutput +='		showpositioncontrols="1"                                    		'
			sOutput +='		showtracker="1"                                             		'
			sOutput +='		showstatusbar="1"                                           		'
			sOutput +='		animationatstart="0"                                        		'
			sOutput +='		autostart="1"                                               		'
			sOutput +='		transparentatstart="0"                                      		'
			sOutput +='		width="'+widthMediaPlayer+'"                                        '
			sOutput +='		height="'+heightMediaPlayer+'"                                 		'
			sOutput +='	</embed>                                                            	'
			sOutput +='</OBJECT>		                                                    	'		

			document.getElementById('divPlayer').innerHTML = sOutput;
			document.getElementById('divPlayer').style.width = widthDiv;
			document.getElementById('divPlayer').style.height = heightDiv;							
		}else{
			//albumWin = openWin( file , 'multimediaMozzilla', 'width=10,height=10,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0' );
			//setTimeout ("albumWin.close()", 6000 );
			window.open(file);
		}
	}
	
	function PrintRealPlayerVideo(file)
	{
		var sOutput = '';
		if (document.all){
			sOutput +='<object id="RVOCX" classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="'+widthRealPlayer+'" height="'+heightRealPlayer+'">'
			sOutput +='	<param name="src" value="' + file + '">                                                                       '
			sOutput +='	<param name="autostart" value="true">                                                                             '
			sOutput +='	<param name="controls" value="ImageWindow">                                                                       '
			sOutput +='	<param name="console" value="video">                                                                              '
			sOutput +='	<param name="maintainaspect" value="true">                                                                        '
			sOutput +='<embed id="RVOCX" src="' + file + '" type="audio/x-pn-realaudio-plugin" controls="ImageWindow" width="'+widthRealPlayer+'" height="'+heightRealPlayer+'" nojava="true" console="video" autostart="true" maintainaspect="true" />'
			sOutput +='</object>'
			sOutput +='<OBJECT ID=RVOCXCONTROLS CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" WIDTH='+widthRealPlayer+' HEIGHT='+heightRealPlayerToolbar+'>'
			sOutput +='	<param name="src" value="' + file + '">'
			sOutput +='	<PARAM NAME="CONTROLS" VALUE="ControlPanel">'
			sOutput +='	<PARAM NAME="CONSOLE" VALUE="one">'
			sOutput +='<EMBED SRC="' + file + '" WIDTH='+widthRealPlayer+' HEIGHT='+heightRealPlayerToolbar+' NOJAVA=true CONTROLS=ControlPanel CONSOLE=one>'
			sOutput +='</OBJECT>'
			
			document.getElementById('divPlayer').innerHTML = sOutput;
			document.getElementById('divPlayer').style.width = widthDiv ;
			document.getElementById('divPlayer').style.height = heightDiv ;			
			
		}else{
			//albumWin = openWin( file , 'multimediaMozzilla', 'width=10,height=10,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0' );
			//setTimeout ("albumWin.close()", 6000 );
			window.open(file);
		}
	}
	
	function PrintRealPlayerAudio(file)
	{
		sOutput="";
		if (document.all){
			sOutput +='<object id="RVOCX" classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="' + widthRealPlayer + '" height="' + heightRealPlayer + '">';
			sOutput +='	<param name="src" value="' + file + '">                                                                           ';
			sOutput +='	<param name="autostart" value="true">                                                                             ';
			sOutput +='	<param name="controls" value="ImageWindow">                                                                       '
			sOutput +='	<param name="console" value="video">                                                                              '
			sOutput +='	<param name="maintainaspect" value="true">                                                                        '
			sOutput +='<embed id="RVOCX" src="' + file + '" type="audio/x-pn-realaudio-plugin" controls="ImageWindow" width="'+widthRealPlayer+'" height="'+heightRealPlayer+'" nojava="true" console="video" autostart="true" maintainaspect="true" />'
			sOutput +='</object>'
			sOutput +='<OBJECT ID=RVOCXCONTROLS CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" WIDTH='+widthRealPlayer+' HEIGHT='+heightRealPlayerToolbar+'>'
			sOutput +='	<param name="src" value="' + file + '">'
			sOutput +='	<PARAM NAME="CONTROLS" VALUE="ControlPanel">'
			sOutput +='	<PARAM NAME="CONSOLE" VALUE="one">'
			sOutput +='	<param name="autostart" value="true">                                                                             ';
			sOutput +='<EMBED SRC="' + file + '" WIDTH='+widthRealPlayer+' HEIGHT='+heightRealPlayerToolbar+' NOJAVA=true CONTROLS=ControlPanel CONSOLE=one>'
			sOutput +='</OBJECT>'
			
			document.getElementById('divPlayer').innerHTML = sOutput;
			document.getElementById('divPlayer').style.width = widthDiv ;
			document.getElementById('divPlayer').style.height = heightDiv ;			
			
		}else{
			//albumWin = openWin( file , 'multimediaMozzilla', 'width=10,height=10,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0' );
			//setTimeout ("albumWin.close()", 6000 );
			window.open(file);
		}
	}
	
	/*##############################*/
	
	function launchItem(file){
		var sExt = file.substr(file.length -3, 3)		
		switch(sExt){
			case 'wmv':
				document.getElementById('divPlayer').innerHTML = '';
				PrintMediaPlayerVideo(file);
				centerPlayer();
				break;

			case 'mp3':
				document.getElementById('divPlayer').innerHTML = '';
				PrintMediaPlayerAudio(file);
				centerPlayer();
				break;			
						
			case 'asx':				
				document.getElementById('divPlayer').innerHTML = '';
				PrintMediaPlayerVideo(file);
				centerPlayer();
				break;
			
			case 'wma':
				document.getElementById('divPlayer').innerHTML = '';
				PrintMediaPlayerAudio(file);
				centerPlayer();
				break;
			
			case 'ram':
				document.getElementById('divPlayer').innerHTML = '';
				PrintRealPlayerAudio(file);
				centerPlayer();
				break;
			case '.ra':
				document.getElementById('divPlayer').innerHTML = '';
				PrintRealPlayerVideo(file);
				centerPlayer();
				break;

			case 'mil':
				document.getElementById('divPlayer').innerHTML = '';
				PrintRealPlayerVideo(file);
				centerPlayer();
				break;
		}
		
	}
	
	function centerPlayer(){
		if (document.getElementById('WMPlay') || document.getElementById('RVOCX') || document.getElementById('RVOCXCONTROLS')){
	
			hScreen = document.body.offsetHeight;
			wScreen = document.body.offsetWidth;
			if (document.getElementById('WMPlay')) oPlayer = document.getElementById('WMPlay');
			if (document.getElementById('RVOCX')) oPlayer = document.getElementById('RVOCX');
			if (document.getElementById('RVOCXCONTROLS')) oPlayerControls = document.getElementById('RVOCXCONTROLS');
			
			oPlayer.width = (wScreen-420)/1.8; 
			oPlayer.height = (oPlayer.width*0.97) ;

			//toolbar real player
			if (document.getElementById('RVOCXCONTROLS')) oPlayerControls.width = (wScreen-420)/1.8; 
			
			heightMediaPlayer = oPlayer.offsetHeight;
			widthMediaPlayer = oPlayer.offsetWidth;
			
				
			if(document.getElementById('divPlayer')){
				document.getElementById('divPlayer').style.position = 'absolute';
				document.getElementById('divPlayer').style.top = (hScreen/2)  - (heightMediaPlayer/2) - 15 +  'px';
				document.getElementById('divPlayer').style.left = ((wScreen-420)/2) - (widthMediaPlayer/2)  + 'px';
			}
		}
	}
	
	function killItem(file){
			if (document.all) {
				document.getElementById('divPlayer').innerHTML = '';
			}else{
				if (albumWin) albumWin.close();
			}			
			
	}	
	
	function hideItem(){
		if (document.all){
			document.getElementById('divPlayer').style.visibility = 'hidden';
		}else{
			if (albumWin) albumWin.focus();
		}
	}
	
	function unHideItem(){
		if (document.all){
			document.getElementById('divPlayer').style.visibility = 'visible';
		}else{
			if (albumWin) albumWin.focus();
		}
	}	
	
	function register_validate() {
		var elems = document.forms['registration'].elements;
		for(x = 0; x < elems.length; x++)
		{	
			
			if (elems[x].required == 'required' && elems[x].value =='') 
			{
				alert('I campi seguiti da (*) sono  obbligatori.');
				elems[x].focus();
				return false;
			}
			
			if (elems[x].required == 'required' && elems[x].textmail == 'yes') 
			{
				if(elems[x].value == "" || elems[x].value.indexOf('@') < 0 || elems[x].value.indexOf('.') < 0 || elems[x].value.length < 6){
				    alert("Inserire un indirizzo e-mail valido");
				    elems[x].focus();
					return false;
			  	}
			}			
		}

			if(elems['pw1'].value != elems['pw2'].value || elems['pw1'].value == '' ) {
				alert('Il campo password e conferma password non corrispondono.');
				if (elems['pw1'].value == '') 
				{
					elems['pw1'].focus();
				}else{
					elems['pw2'].focus();
				}
				return false;
			}else{
				return true;
			}		
	}
	
	
	//ricerca catalogo
	
	//hide

var sCSS="";

// initialize the value of "browser"

var browser = "oldAndInTheWay";

var bName = navigator.appName;

var bVersion = parseInt(navigator.appVersion);

// check for Netscape

if (bName == "Netscape") {

  browser = "ns" + bVersion;

} else {

// check for MSIE

if (bName == "Microsoft Internet Explorer") {

if (bVersion >= 4) {

browser = "ie" + bVersion;

    } else {

      browser = "ie3";

    }

  }

}

if (bName == "Netscape") {

sCSS = '<link rel=stylesheet href="/css/adelphinet.css" type="text/css" >'

  }

if (bName == "Microsoft Internet Explorer") {

sCSS = '<link rel="stylesheet" href="/css/adelphi.css" type="text/css" >'

  }

document.write(sCSS) ;



function ChanCategorie(N)
{
	eval('document.searchform.categoriaH' + N + '.value = document.searchform.categoria' + N + '.value');
}

function CheckForm(sForm){
	oForm = document.getElementById(sForm);
	//alert(oForm.titolo.value);	
	//alert(oForm.autore.value);
	//alert(oForm.anno.value);
	//alert(oForm.categorie.value);

	bCampi = (oForm.titolo.value!=''||oForm.autore.value!=''||oForm.anno.value!='');

	aCheckBox = document.getElementById('categorySearch').getElementsByTagName('input');
	bCategorie = false;

	for( i=0; i<aCheckBox.length; i++){
		if(aCheckBox[i].checked){
			bCategorie = true;
			break;
		}
	}
	
	if(!bCampi&&!bCategorie){
		alert('devi compilare uno dei campi o selezionare una categoria')
	}else{
		oForm.submit();
	}
	
	

}


function linkClick(node){
	oCheckBox = node.parentNode.previousSibling;
	sValue = oCheckBox.value;
	oCheckBox.checked = (oCheckBox.checked)?false:true;
	scriviCategorie();
}

function selectClick(node){
	scriviCategorie();
}


function scriviCategorie(){
	var sMessage = '';
	//var z = 0;
	aCheckBox = document.getElementById('categorySearch').getElementsByTagName('input');
	sMessageTop = '<div style=\"width: 165px;background-color: #EEF4F9;color: #61809D;padding: 5px;\">';
	for (var i=0;i<aCheckBox.length;i++){
		//z = z + 22
		if (aCheckBox[i].checked) {
			var valoreStringa = aCheckBox[i].value.replace("'", "^");
			var valoreStringaTesto = aCheckBox[i].value;
			var azione = " onclick=\"cancellaCategoria('" +  valoreStringa   +  "')\" ";
			
			sMessage += "<div style=\"height: 22px;\"><div style=\"width: 140px;float: left;margin: 0;padding: 0;font-size: 9pt;background-color: #EEF4F9;color: #000;\">" + valoreStringaTesto + "</div><div style=\"float: right;text-align: center;padding: 0;width: 17px;height: 17px;\"><a href=\"#\" style=\"padding: 0;margin: 0;color: #fff;\" title=\"Cancella la categoria\" " + azione  + " ><img src=\"../img/catalogo_catsel_elimina.gif\" width=\"17\" height=\"17\" alt=\"\" border=\"0\"></a></div></div>";
		//if (aCheckBox[i].checked)document.getElementById("btCerca").style.top = 360 + z + 'px'
		}
	}
	
	sMessageBot = '</div>';
	
	if(sMessage != ''){
		sMessage = '<br/><h2 style=\"display: block;width: 160px;font-size: 9pt;margin-bottom: 10px;\">Categorie selezionate</h2>' + sMessageTop + sMessage + sMessageBot;
	}else{
		sMessage = '<p class=\"txt_small\" style=\"display: block;width: 165px;\">&Egrave; possibile selezionare una o pi&ugrave; categorie dalla lista qui a destra</p>';
	}
	
	document.getElementById('divCategorie').innerHTML = sMessage;
}

function cancellaCategoria(categoria){
    categoria = categoria.replace("^", "'")
	aCheckBox = document.getElementById('categorySearch').getElementsByTagName('input');
	for (var i=0;i<aCheckBox.length;i++){
		if(aCheckBox[i].value == categoria){
			aCheckBox[i].checked = false;
		}
	}
	scriviCategorie()
}

function ResetCategorie()
{
	aCheckBox = document.getElementById('categorySearch').getElementsByTagName('input');
	for (var i=0;i<aCheckBox.length;i++){
		if (aCheckBox[i].checked) 
			cancellaCategoria(aCheckBox[i].value);
	}
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openWin( windowURL, windowName, windowFeatures ) { 
	return window.open( windowURL, windowName, windowFeatures ) ; 
} 


	//apre i blocchi dei dati dell'autore
	function  openRecensioni(blocco,elemento){
		sDiv = document.getElementById(blocco);
		sLinkOpen = document.getElementById(elemento);
			if(sDiv.style.display == 'none'){
				sDiv.style.display = 'block';
				sLinkOpen.className = 'btDatiAutoreOpen';
			}else{
				sDiv.style.display = 'none';
				sLinkOpen.className = 'btDatiAutore';
			}
	}

	//si usa per i tasti di votazione
	function lightBt(num){
		for(var i = 0; i < num + 1; i ++){
			document.getElementById('voto' + i).src = sbasePath +'img/quadrato_arancio.gif'
		} 
	}
	function turnoffLightBt(num){
		if (num != 'no'){
			for(var i = 0; i < 5; i ++){
				if(i<=num){
					document.getElementById('voto' + i).src = sbasePath +'img/quadrato_rosso.gif'
				}else{
					document.getElementById('voto' + i).src = sbasePath +'img/quadrato_grigio.gif'
				}
			} 	
		}else{
			for(var i = 0; i < 5 ; i ++){
				document.getElementById('voto' + i).src = sbasePath +'img/quadrato_grigio.gif'
			} 
		}
	}	

	
function newwind(url,name,options){
		window.open(url,name,options);
	}