// JavaScript Document FCM Web Scouting

	<!--
	
	// Apre nuova finestra centrata
	function NewWindow(mypage,myname,w,h,scroll)
	{
		var win = null;
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',noresize'
		win = window.open(mypage,myname,settings)
	}
	
	// La funzione verifica se il dato passato è un numero
	function IsNumber(Expression)
	{
		Expression = Expression.toLowerCase();
		RefString = "0123456789.-";
		
		if (Expression.length < 1) 
			return (false);
		
		for (var i = 0; i < Expression.length; i++) 
		{
			var ch = Expression.substr(i, 1);
			var a = RefString.indexOf(ch, 0);
			if (a == -1)
				return (false);
		}
		return(true);
	}
	
	// La funzione verifica se il dato passato è un'ora valida
	function IsTime(timeStr)
	{
		RefString = "0123456789:";
		// Controllo la lunghezza del campo
		if (timeStr.length < 5)
			return (false);
		// Controllo il campo ORA
		if (timeStr.substr(0,2)>24)
			return (false);
		// Controllo il campo divisore
		if (timeStr.substr(2,1)!=':')
			return (false);		
		// Controllo il campo Minuti
		if (timeStr.substr(3,2)>59)
			return (false);
	}
	
	// La funzione verifica se il dato passato è una data
	function IsDate(dateStr) 
	{
		var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
		var matchArray = dateStr.match(datePat); // is the format ok?
		
		if (matchArray == null) {
			alert("Inserire una data nel formato gg/mm/aaaa !");
			return false;
		}
	
		day = matchArray[1];
		month = matchArray[3];
		year = matchArray[5];
	
		if (month < 1 || month > 12) { 
			alert("Indicare il mese con un numero da 1 a 12");
			return false;
		}
	
		if (day < 1 || day > 31) {
			alert("Indicare il giorno con un numero da 1 a 31");
			return false;
		}
	
		if ((month==4 || month==6 || month==9 || month==11) && day==31) {
			alert("Il mese "+month+" non ha 31 giorni!")
			return false;
		}
	
		if (month == 2) { // Febbraio
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (day > 29 || (day==29 && !isleap)) {
				alert("Nell'anno " + year + " il mese di febbraio non ha " + day + " giorni!");
				return false;
			}
		}

		// Nessun errore, la data è valida
		return true; 
	}	
	
	function DataOdierna()
	{
		d = new Date();
		giorno = d.getDate() >= 10 ? d.getDate() : '0'+d.getDate();
		mese = (d.getMonth() + 1) >= 10 ? (d.getMonth() + 1) : '0'+ (d.getMonth() + 1)
		data = giorno + '/' + mese + '/' + d.getFullYear(); 
		return data;
	}
	
	// Verifica indirizzo eMail
	function isEMail(eMail)
	{
		var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
		if (!espressione.test(eMail)) { return false; }
	}
			
	// Verifca se l'elemento passato esiste
	function isExist(id) 
	{
		var el = document.getElementById(id);
		if (el != null) { return true; }
		return false;
	}
	
	// Trova l'estensione di un file
	function get_estensione(path) 
	{
		posizione_punto=path.lastIndexOf(".");
		lunghezza_stringa=path.length;
		estensione=path.substring(posizione_punto+1,lunghezza_stringa);
		return estensione;
	}
	
	// Gestione del Focus sul campo
	function gfocus(ovalue) 
	{ 
		ovalue.style.backgroundColor="yellow"; 
	}
	
	// Gestione del onFocus sul campo
	function lfocus(ovalue) 
	{ 
		ovalue.style.backgroundColor="white";
	}	
	
	// Posiziona il Focus sul campo selezionato
	function setFocus(ovalue)
	{
	    if (isExist(ovalue)) { document.getElementById(ovalue).focus(); }
	}
	
	// Rimanda alla pagina, facendo un Submit sul Form
	function submitForm(ovalue)
	{
		document.cmsForm.target = "";
		document.cmsForm.method = "post";
		document.cmsForm.action = ovalue;
		document.cmsForm.submit();	
	}

	// -------------------------------------------------------------------------------- //
	
	function show_allegato(scheda)
	{
		// scheda contiene il nome del boxmodel che devo visualizzare in quanto
		// quello per le immagini è diverso da quello per i files

		oMenuA = document.getElementById('background');
		oMenuB = document.getElementById(scheda);
		
		if(oMenuA.style.display=='block') 
		//if(oMenuB.style.display=='block') 
		{
			// Nasconde il box
			oMenuA.style.display='none';
			oMenuB.style.display='none';
		} 
		else 
		{
			// Calcola altezza
			backHeigh = document.body.clientHeight + document.body.scrollHeight;
			
			// Visualizza il box
			iHeight = (document.body.clientHeight / 2) + document.body.scrollTop;
			oMenuA.style.display	='block';
			oMenuA.style.height		= backHeigh;
			oMenuB.style.display	='block';
			oMenuB.style.top		= iHeight;
		}
	}
	
	function delimage(spg, iedit)
	{
		myVar=confirm("ELIMINARE L'IMMAGINE ?\n\nFai clic su OK per confermare, altrimenti fai clic su Annulla");
		if(myVar=="0") { alert('Operazione annullata!'); } 
		  else { 
		submitForm("index.php?op=cfileimg&pg="+spg+"&edit="+iedit); }
	}
	
    // Menu //
    
    function StatoMenu(oDiv) 
    {
        var mydiv = document.getElementById(oDiv);
        if(mydiv.style.display=='block') { 
            mydiv.style.display='none';
        }
        else if(mydiv.style.display=='none') {
            mydiv.style.display='block';
        } 
        else if(mydiv.style.display==''){
            mydiv.style.display='none';
        }
    }
    
    function VisualizzaMenu(oDiv) 
    { 
        document.getElementById(oDiv).style.display = "block"; }
    
    function NascondiMenu(oDiv)
    { 
        document.getElementById(oDiv).style.display = "none";  }    
	-->
