//
// JavaScript Utilities
// Copyright (c) 2003 Gulliver S.r.L.
// All Rights Reserved.
//		
//----------------------------------------------------------------------------------------------------
//
// Funzione data e ora
//

		var timer = null;      // ID del timer
		var Partito = false;   // il flag indica se il timer è partito
		
		function dataEora() {
			var days=new Array(8);
			days[1] = "domenica";
			days[2] = "lunedi";
			days[3] = "martedi";
			days[4] = "mercoledi";
			days[5] = "giovedi";
			days[6] = "venerdi";
			days[7] = "sabato";
			var months=new Array(13);
			months[1] = "gennaio";
			months[2] = "febbraio";
			months[3] = "marzo";
			months[4] = "aprile";
			months[5] = "maggio";
			months[6] = "giugno";
			months[7] = "luglio";
			months[8] = "agosto";
			months[9] = "settembre";
			months[10] = "ottobre";
			months[11] = "novembre";
			months[12] = "dicembre";
			var dateObj=new Date()
			var wday=days[dateObj.getDay() + 1]
			var lmonth=months[dateObj.getMonth() + 1]
			var yanno=dateObj.getYear()
			
			var date=dateObj.getDate()
			 
			var ora=new Date();
			var ore = ora.getHours();
				if 
					(ore<10) ore="0" + ora.getHours();
				else
					ore=ora.getHours();
			
			var minuti = ora.getMinutes();
				if 
					(minuti<10) minuti="0" + ora.getMinutes();
				else
					minuti=ora.getMinutes();
			
			var ssecondi=ora.getSeconds();
				if 
					(ssecondi<10) ssecondi="0" + ora.getSeconds();
				else
					ssecondi=ora.getSeconds();
			
			var dataOra = wday + ", " + date + " " + lmonth + " " + yanno + " - " + "ore " + ore + ':' + minuti + ':' + ssecondi;			
			var subMenu = document.getElementById('oasi_capelli');
		    subMenu.innerHTML = dataOra;
			/* document.data.USER.value = dataOra; */					
		}
		
		/* Stop del timer */
		function Stop() {  
		 if(Partito==true)         // Se il timer gira
		 {
		  clearInterval(timer);    // ferma il timer
		  Partito = false;
		 } 
		}
		
		/* Setta il richiamo della funzione dataEora ogni secondo */
		function Start() {
		  Stop();                                   // Stop timer se partito
		  timer = setInterval("dataEora()",1000);  // Richiamo automatico ogni secondo
		  Partito = true;
		}


//----------------------------------------------------------------------------------------------------
//
// Funzioni varie
//

        function doLogon() {
		  var userTextCtrlValue = document.logonForm.userTextCtrl.value;
		  var passwordCtrlValue = document.logonForm.passwordCtrl.value;

		  if (userTextCtrlValue == '') {
		    alert("Devi specificare un nome utente ed una password per l'accesso! ");
		    document.logonForm.userTextCtrl.focus();
		  } else if (passwordCtrlValue == '') {
		    alert("Devi specificare un nome utente ed una password per l'accesso! ");
		    document.logonForm.passwordCtrl.focus();
		  } else {
		  		document.logonForm.submit();		  				  				      
		  }
		}
		
		function lanciaBrexDemo() { //v2.0 
			var h2;
			var w2;
			var w2 = screen.width;
			var h2 = screen.height;	
			var t = 0;
			var l = 0; 
			if (screen.width > 800 ) {
				w2 = 1024;
				h2 = 768;
				l = (( screen.width - w2 )/ 2 );
				t = (( screen.height - h2 )/ 2 );
			} 
			var url="http://demo.gullivernet.com/brex/homebrex_ferramenta.jsp";	
			var name="";
			var parametri="resizable=yes,width=" + w2 + ",height=" + h2 + ",location=no, top=" + t + ",left=" + l;
			window.open(url,name,parametri);
		}
		
		function lanciaFlashDemo(theURL,winName,features) { //v2.0
		  var i,j;
		  var x,y,width,height;
		  i=features.indexOf("width=");
		  i+=6;
		  j=features.indexOf(",",i);
		  if(j==-1){
			j=features.length;
		  }
		  width=parseInt(features.substring(i,j));
		  i=features.indexOf("height=",i);
		  i+=7;
		  j=features.indexOf(",",i);
		  if(j==-1){
			j=features.length;
		  }
		  height=parseInt(features.substring(i,j));
		  x=(screen.width-width)/2;
		  y=(screen.height-height)/2;
		  features+=",left="+x+",top="+y;
		  features+=",screenX="+x+",screenY="+y;
		  var win=window.open(theURL,winName,features);
		  win.focus();
		}
		
		function openService() {
			var a = document.logonForm.userTextCtrl.value;
			var b = document.logonForm.passwordCtrl.value;
			var c = a.length;
			var d = c - 15;
			var e = a.substring(d,c);
			if (e == 'gullivernet.com') {
				var url = 'http://webmail.scao.net/WorldClient.dll?View=Main&User=' + a + '&Password=' + b;	
				window.open(url,'GulliverWebmail','width=800,height=600,resizable=yes,location=no');
			} else {
					var url = 'http://192.168.1.200/gservice/index.jsp?USER=' + a + '&PASSWORD=' + b; 
					window.open(url,'GulliverService','width=800,height=600,resizable=yes,location=no');
				}
		}
				
//----------------------------------------------------------------------------------------------------
