/*
Funzione per disabilitare il tasto destro
*/
function noCode(event) {
  
  if (event.button==2) { 
    alert(' IPS ON-Line ');    
  }  
}

function annulla(path) {
  
  location.href=path
  closing=false   
  
}

/*
Calcola la data fine

Parametri in input
	gg	Giorno Inizio
	mm      Mese Inizio
	aaaa    Anno Inizio
	giorni  Numero totale giorni
*/
function data_fine(gg, mm, aaaa, giorni) {

  var data = new Date()
  var data_millisecondi 
  var giorni_millisecondi
  var mese
  var giorno
	
	
  /*Imposto la data*/
  data_millisecondi=data.setFullYear(eval(aaaa),eval(mm)-1,eval(gg))
		
  /*Converto i giorni in millisecondi*/
  giorni_millisecondi= (60*60) * (24 * (giorni - 1)) * 1000
  
  data_millisecondi= data_millisecondi + giorni_millisecondi //86400000 un giorno	
  data.setTime(data_millisecondi)

  if (data.getDate < 10 ) {
	giorno='0' + escape(data.getDate())
  } else {
	giorno=data.getDate()
  }

  if (data.getMonth()+1 < 10 ) {
	mese='0' + escape(data.getMonth()+1)
  } else {
	mese=data.getMonth()+1
  }
             
  return (escape(data.getFullYear()) + escape(mese) + escape(giorno))
  
}

/*
Legge i cookie
*/
function getCookie(NameOfCookie) { 

  if (document.cookie.length > 0) { 
    begin = document.cookie.indexOf(NameOfCookie+"="); 
   
    if (begin != -1) 
      begin += NameOfCookie.length+1; 
    
    end = document.cookie.indexOf(";", begin);

    if (end == -1) 
      end = document.cookie.length;
    return unescape(document.cookie.substring(begin, end)); 
  } 
  
  return ''; 
}

/*
Imposta i cookie
*/
function setCookie(NameOfCookie, value, expiredays) { 

  var ExpireDate = new Date ();
  ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
  document.cookie = NameOfCookie + "=" + escape(value) + 
  ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

/*
Cancella i cookie
*/
function delCookie (NameOfCookie) { 

  if (getCookie(NameOfCookie)) {
    document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

var TimerFrec = null;
var TimerStatus = false;
var MinsLeft=5;
var SecsLeft= 0 ;
var LogOut = 1;

function UpdateStatus() {
	if( ( (SecsLeft - 1 ) == 0 ) || ( SecsLeft == 0 ) ) {
		if( MinsLeft == 0 ) {
		window.status="Sei stato disconnesso da IPS.";
			LogOut = 0;

/*			location.href='https://azsx1029995/asp/else/timeout.asp';    SERVER SER TEST   
			location.href='http://172.20.0.150/ips/asp/else/timeout.asp' SERVER SER STAGE ;*/
			location.href='http://ips.alitalia.it/ips/asp/else/timeout.asp';

		} else {
			MinsLeft--;
			SecsLeft = 58;
		}
	} else {
		SecsLeft--;
	}
	if(LogOut) {
		if ( MinsLeft != 1 ) {
			var MinSuffix = "i";
		} else {
			var MinSuffix = "o";
		}
		if ( SecsLeft !=1 ) {
			var SecSuffix = "i";
		} else {
			var SecSuffix = "o";
		}
		window.status = 'Sarai disconnesso da IPS per inattivita\' fra '+MinsLeft+' minut'+MinSuffix+' '+SecsLeft+' second'+SecSuffix+'.';
		TimerFrec = setTimeout( "UpdateStatus()",1000);
		TimerStatus = true;
	} else {
		KillTimer();
	}
}

/*
var TimerFrec = null;
var TimerStatus = false;
*/

function KillTimer () {
	if( TimerStatus )
		clearTimeout( TimerFrec );
	TimerStatus = false;
}

function StartTimer () {
	KillTimer();
	UpdateStatus();
}

var shut=true;
var w, h;
var x, y;
var s;

function exitcon() {
  
  if (shut) {
    
    w = 600;
    h = 200;

    if ( window.screen ) {
      x = (screen.width-w)/2;
      y = (screen.height-h)/3;
    } else {
      x = 100;
      y = 100;
    }

    s = "width=600,height=600,resizable=no,scrollbars=no,status=no," + "width=" + w + ",height=" + h + ",left=" + x + ",top=" + y;
    open('http://ips.alitalia.it/asp/else/forceabandon.asp','IPSOnLine',s);
/*  open('http://172.20.0.150/asp/else/forceabandon.asp','IPSOnLine',s); */
 
    /* 
    exWin = open('', 'Exitwin',s);
    exWin.blur();
    */
/*     exWin.location = 'http://172.20.0.150/asp/else/forceabandon.asp';
   exWin.location = 'https://azsx1029995/asp/else/forceabandon.asp'*/
    /*
    exWin.location = 'http://n4341589/ips_test/asp/else/forceabandon.asp';
    exWin = open('http://n4341589/ips_test/asp/else/forceabandon.asp', 'Exitwin',s);
    exWin.blur();
    */         
  } 
}  
  
function getNomeMese(numeroMese) {
	
	if (numeroMese==1)
	  return('Gennaio');
	
	if (numeroMese==2)
	  return('Febbraio');
	  
	if (numeroMese==3)
	  return('Marzo');
	  
	if (numeroMese==4)
	  return('Aprile');
	  
	if (numeroMese==5)
	  return('Maggio');
	
	if (numeroMese==6)
	  return('Giugno');
	
	if (numeroMese==7)
	  return('Luglio');
	
	if (numeroMese==8)
	  return('Agosto');
	
	if (numeroMese==9)
	  return('Settembre');
	  
	if (numeroMese==10)
	  return('Ottobre');
	  
	if (numeroMese==11)
	  return('Novembre');
	  
	if (numeroMese==12)
	  return('Dicembre');

        return(' ' );
}