
//Ridimesionamento del contenuto principale
function Sizer() {
	var objContent = document.getElementById("content").offsetHeight;
	//alert("objContent="+objContent);
	if (objContent<300) {
	    var altezza = document.getElementById("appuntamento");
	    if (altezza==undefined){altezza = document.getElementById("letture")}
	    if (altezza==undefined){altezza = document.getElementById("news")}
	    if (altezza==undefined){altezza = document.getElementById("right")}
	    //alert(altezza);right
	    if (altezza!=undefined){altezza.style.height = "300px";}
    	    
	}
}



// JavaScript Document

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*FUNZIONE PER NASCONEDERE I LAYER*/
function hideShowCommenti(nome1,nome2){ 
	var spn1 = document.getElementById(nome1);
	var spn2 = document.getElementById(nome2);
	if (spn1.style.display == "none"){
		spn1.style.display = "block";
		spn2.style.display = "none";
		//visualizzo l'etichetta inserisci il commento
		MM_swapImage('lbl_inscomm','','images/lbl_think.gif',1)
	}else{
		spn1.style.display = "none";
		spn2.style.display = "block";
		//visualizzo l'etichetta trona alla prefazione
		MM_swapImage('lbl_inscomm','','images/btn_backpref.gif',1)
	} 
}

// FUNZIONE PER CAMPI OBBLIGATORIE E UTENTE CHE INVIA DI PAOLO CREPET
function formController(which){
    //Definisco l'array dei messaggi di errore
	var error_txt = new Array();
	error_txt["commento"] = "Commento";
	error_txt["titolo"] = "Titolo";
	error_txt["nome"] = "Nome";
	error_txt["eta"] = "Età";
	
	var reqString ="Attenzione!!\nE necessario riempire i seguenti campi:\n ";
	var reqPass = true ;
	var check = 0;
	var password = "";
	var conf_password = "";
	
	
	
	for (campo in error_txt) {
	    if (which[campo]!=undefined){
    			if (which[campo].value=="") {
    				reqString += ("\n-" + error_txt[campo]);
    				reqPass = false ;
    			}
	    }
	}
	
	if (!reqPass) {
		alert(reqString);
		return false ;
	}
	if (which["nome"]!=undefined){
	       controllo_nome=" "+which["nome"].value+" ";
	       controllo_nome=controllo_nome.toLowerCase();
	       if (controllo_nome.indexOf(" crepet ")>-1){
	            alert("Il nome Crepet non può essere utilizzato!");
	            return false;
	         }
	}
}

