/***********************************************************************************************
 * Copyright (c) 2007 InIT, ZHAW Zürcher Hochschule für angewandte Wissenschaften
 * All rights reserved.
 * 
 * AIR TRAFFIC v1.8 - Visualisierung von Transponder-Daten mittels Mashup
 *
 * --- DIPLOMARBEIT 2007 ---
 * 
 * Authors:  Daniel Kramarz <kramadan@students.zhaw.ch>
 *           Andreas Loeber <loberand@students.zhaw.ch>
 *
 * Tutor:    Dr. Karl Rege <karl.rege@zhaw.ch>
 ***********************************************************************************************/


//-----------------------------------------------------------------------------
// AJAX Configuration
//-----------------------------------------------------------------------------
var tomcatInstances = 2;
var airtrafficService = 'http://radar.zhaw.ch/proxy/app' + Math.ceil(tomcatInstances*Math.random()) + '/AirTrafficService';
var updateTimeout = 12;                               //update interval (in seconds) 
var ajaxConnectionFailedTimeout = 18;                 //connection timeout (in seconds)

//-----------------------------------------------------------------------------
// Options - Default values (on startup)
//-----------------------------------------------------------------------------
var defaultLanguage = 'de';                           //language ('de', 'en', 'fr' or 'it')
var defaultUnits = 'metric';                          //units 'metric' or 'aviatic'
var defaultMapType = 0;                               //map type (0 = street map, 1 = satelite, 2 = hybrid)
var defaultTrackingEnabled = false;                   //tracking enabled when clicking on airplane?
var defaultShadowEnabled = true;                      //airplane shadows enabled?
var defaultColorBar = 'automatic';                    //color bar 'automatic', '3colors' or '5colors'

//for defaultColorBar = 'automatic':
var defaultColorBarOnStreetMap = '3colors';
var defaultColorBarOnSatelliteMap = '5colors';
var defaultColorBarOnHybridMap = '3colors';

//-----------------------------------------------------------------------------
// Map Configuration
//-----------------------------------------------------------------------------
var defaultMapCenterLatitude = 47.50479421370602;     //center of map on startup
var defaultMapCenterLongitude = 8.49294662475586;
var defaultMapZoom = 10;                              //default zoom on startup
var minMapZoomLevel = 9;                              //minimal zoom level
var maxMapZoomLevel = 15;                             //maximum zoom level

//-----------------------------------------------------------------------------
// Airplane Control
//-----------------------------------------------------------------------------
var airplaneTTL = 3;                                  //airplane Time-To-Live
var zeppelinTTL = 30;                                 //zeppelin Time-To-Live
var airplaneIconSizeWidth = 32;                       //airplane icon width in pixel
var airplaneIconSizeHeight = 32;                      //airplane icon height in pixel
var airplaneShadowIconSizeAltitudeShrinkFactor = 0.4; //pixel per 1000 feet (0 = shrinking disabled)
var airplaneShadowIconMinDisplacementX = 3;           //minimal displacement in pixel
var airplaneShadowIconMinDisplacementY = 3;           //minimal displacement in pixel
var airplaneShadowIconDisplacementXFactor = 1.0;      //displacement in pixel per 1000 feet
var airplaneShadowIconDisplacementYFactor = 0.8;      //displacement in pixel per 1000 feet
var airplaneIconPrefixOnStreetMap = '';               //airplane icon colors:
var selectedAirplaneIconPrefixOnStreetMap = 'r_';     //'' = black, 'r_' = red, 'y_' = yellow, 'g_' = gray
var airplaneIconPrefixOnSatelliteMap = 'y_';
var selectedAirplaneIconPrefixOnSatelliteMap = 'r_';
var airplaneIconPrefixOnHybridMap = 'y_';
var selectedAirplaneIconPrefixOnHybridMap = 'r_';
var showExtrapolatedPositionsGray = false;
var hideOnGroundAirplanes = false;

//-----------------------------------------------------------------------------
// Airport Control
//-----------------------------------------------------------------------------
var airportIconImage = 'images/airport.png';          //airport icon
var airportIconSizeWidth = 24;                        //airport icon width in pixel
var airportIconSizeHeight = 24;                       //airport icon height in pixel



//-----------------------------------------------------------------------------
// Polyline/Track Control
// (for more information consume our diploma thesis documentation)
//-----------------------------------------------------------------------------
var polylineAngleDifferential = 15;                   //angle differential in degrees
var polylineAltitudeDifferential = 1500;              //altitude differential in feet
var polylineDistanceDifferential = 20;                //distance differential in km
var maxTrackLength = 50000;                           //maximum track length in meters
var minTrackLength = 30000;                           //minimal track length in meters (takes priority over maxTrackLength)
var polylineFadeTimout = 2000;                        //timeout between each fade (defines the speed of polyline fading)


//-----------------------------------------------------------------------------
// XTabs - Scrollable Tabs
// In Firefox the animation fluency depends on the amount of memory Firefox is
// holding. Firefox suffers of memory leaks (especially with Google Maps)!
// The width of the tabs is defined in the CSS.
//-----------------------------------------------------------------------------
var xTabsScrollVelocity = 8;                          //<4 langsam, 4-7 mittel, >7 schnell


//-----------------------------------------------------------------------------
// ICAO number for Zeppelin
//-----------------------------------------------------------------------------
var zeppelinICAO = new Array();
zeppelinICAO['4138283'] = new Object(); // Zeppelin D-LZZF

//-----------------------------------------------------------------------------
// Translations
//-----------------------------------------------------------------------------
var texts = new Array();

// english
texts['en'] = new Object();
texts['en'].language = 'Language';
texts['en'].properties = 'Properties';
texts['en'].about = 'About';
texts['en'].mapType = 'Map Type';
texts['en'].zoomIn = 'Zoom in';
texts['en'].zoomOut = 'Zoom out';
texts['en'].streetMap = 'Street map';
texts['en'].satelliteMap = 'Satellite map';
texts['en'].hybridMap = 'Hybrid map';
texts['en'].tracking = 'Tracking';
texts['en'].activated = 'activated';
texts['en'].deactivated = 'deactivated';
texts['en'].feet = 'Feet';
texts['en'].meter = 'Meter';
texts['en'].knots = 'Knots';
texts['en'].colorGradient = 'Color Gradient';
texts['en'].colors = 'colors';
texts['en'].flight = 'Flight';
texts['en'].airplane = 'Airplane';
texts['en'].flightInformation = 'Flight Information';
texts['en'].aircraftInformation = 'Aircraft Information';
texts['en'].airline = 'Airline';
texts['en'].airport = 'Airport';
texts['en'].departure = 'Departure';
texts['en'].arrival = 'Arrival';
texts['en'].speed = 'Speed';
texts['en'].altitude = 'Altitude';
texts['en'].position = 'Position';
texts['en'].verticalRate = 'Vertical rate';
texts['en'].trackingInformation = 'Tracking Information';
texts['en'].scheduledDepartureTime = 'Scheduled time';
texts['en'].actualDepartureTime = 'Actual time';
texts['en'].scheduledArrivalTime = 'Scheduled time';
texts['en'].estimatedArrivalTime = 'Estimated time';
texts['en'].registration = 'Registration';
texts['en'].manufacturer = 'Manufacturer';
texts['en'].model = 'Model';
texts['en'].type = 'Type';
texts['en'].buildYear = 'Build year';
texts['en'].delivery = 'Delivery';
texts['en'].notAvailable = '-';
texts['en'].units = 'Units';
texts['en'].shadow = 'Shadow';
texts['en'].metric = 'metric';
texts['en'].aviatic = 'aviatic';
texts['en'].automatic = 'automatic';

// deutsch
texts['de'] = new Object();
texts['de'].language = 'Sprache';
texts['de'].properties = 'Einstellungen';
texts['de'].about = '&Uuml;ber';
texts['de'].mapType = 'Kartentyp';
texts['de'].zoomIn = 'Hineinzoomen';
texts['de'].zoomOut = 'Herauszoomen';
texts['de'].streetMap = 'Strassenkarte';
texts['de'].satelliteMap = 'Satellitenkarte';
texts['de'].hybridMap = 'Hybridkarte';
texts['de'].tracking = 'Flugverfolgung';
texts['de'].activated = 'aktiviert';
texts['de'].deactivated = 'deaktiviert';
texts['de'].feet = 'Fuss';
texts['de'].meter = 'Meter';
texts['de'].knots = 'Knoten';
texts['de'].colorGradient = 'Farbverlauf';
texts['de'].colors = 'Farben';
texts['de'].flight = 'Flug';
texts['de'].airplane = 'Flugzeug';
texts['de'].flightInformation = 'Fluginformationen';
texts['de'].aircraftInformation = 'Flugzeuginformationen';
texts['de'].airline = 'Fluggesellschaft';
texts['de'].airport = 'Flughafen';
texts['de'].departure = 'Abflug';
texts['de'].arrival = 'Ankunft';
texts['de'].speed = 'Geschwindigkeit';
texts['de'].altitude = 'H&ouml;he';
texts['de'].position = 'Position';
texts['de'].verticalRate = 'Steig-/Sinkrate';
texts['de'].trackingInformation = 'Aktuelle Situation';
texts['de'].scheduledDepartureTime = 'Geplante Abflugszeit';
texts['de'].actualDepartureTime = 'Effektive Abflugszeit';
texts['de'].scheduledArrivalTime = 'Geplante Ankunftszeit';
texts['de'].estimatedArrivalTime = 'Erwartete Ankunftszeit';
texts['de'].registration = 'Registration';
texts['de'].manufacturer = 'Hersteller';
texts['de'].model = 'Modell';
texts['de'].type = 'Typ';
texts['de'].buildYear = 'Baujahr';
texts['de'].delivery = 'Lieferung';
texts['de'].notAvailable = '-';
texts['de'].units = 'Masseinheiten';
texts['de'].shadow = 'Schatten';
texts['de'].metric = 'metrisch';
texts['de'].aviatic = 'aviatisch';
texts['de'].automatic = 'automatisch';

// français
texts['fr'] = new Object();
texts['fr'].language = 'Langue';
texts['fr'].properties = 'Param&egrave;tres';
texts['fr'].about = '&Agrave; propos';
texts['fr'].mapType = 'Type de carte';
texts['fr'].zoomIn = 'zoom';
texts['fr'].zoomOut = 'zoom';
texts['fr'].streetMap = 'carte routi&egrave;re';
texts['fr'].satelliteMap = 'carte de satellite';
texts['fr'].hybridMap = 'carte hybride';
texts['fr'].tracking = 'Poursuite d&#39;avion';
texts['fr'].activated = 'actif';
texts['fr'].deactivated = 'inactif';
texts['fr'].feet = 'pieds';
texts['fr'].meter = 'm&egrave;tres';
texts['fr'].knots = 'n&oelig;uds';
texts['fr'].colorGradient = 'Trac&eacute; de couleur';
texts['fr'].colors = 'couleurs';
texts['fr'].flight = 'Vol';
texts['fr'].airplane = 'Avion';
texts['fr'].flightInformation = 'Informations de vol';
texts['fr'].aircraftInformation = 'Informations d&#39;avion';
texts['fr'].airline = 'Compagnie a&eacute;rienne';
texts['fr'].airport = 'A&eacute;roport';
texts['fr'].departure = 'D&eacute;part';
texts['fr'].arrival = 'Arriv&eacute;e';
texts['fr'].speed = 'Vitesse';
texts['fr'].altitude = 'Altitude';
texts['fr'].position = 'Position';
texts['fr'].verticalRate = 'Vitesse verticale';
texts['fr'].trackingInformation = '&Eacute;tat actuel';
texts['fr'].scheduledDepartureTime = 'Heure de d&eacute;part pr&eacute;vu';
texts['fr'].actualDepartureTime = 'Heure de d&eacute;part effectif';
texts['fr'].scheduledArrivalTime = 'Heure d&#39;arriv&eacute;e pr&eacute;vu';
texts['fr'].estimatedArrivalTime = 'Heure d&#39;arriv&eacute;e attendu';
texts['fr'].registration = 'Registration';
texts['fr'].manufacturer = 'Constructeur';
texts['fr'].model = 'Mod&egrave;le';
texts['fr'].type = 'Type';
texts['fr'].buildYear = 'Ann&eacute;e de construction';
texts['fr'].delivery = 'Livraison';
texts['fr'].notAvailable = '-';
texts['fr'].units = 'Unit&eacute;s';
texts['fr'].shadow = 'Ombrage';
texts['fr'].metric = 'm&eacute;trique';
texts['fr'].aviatic = 'aviatique';
texts['fr'].automatic = 'automatique';

// italiano
texts['it'] = new Object();
texts['it'].language = 'Lingua';
texts['it'].properties = 'Propriet&agrave;';
texts['it'].about = 'About';
texts['it'].mapType = 'Tipo di visualizazione';
texts['it'].zoomIn = 'Zoom in';
texts['it'].zoomOut = 'Zoom out';
texts['it'].streetMap = 'Cartina stradale';
texts['it'].satelliteMap = 'Immagine satellitare';
texts['it'].hybridMap = 'Cartina ibrida';
texts['it'].tracking = 'Tracciamento';
texts['it'].activated = 'attivo';
texts['it'].deactivated = 'disattivo';
texts['it'].feet = 'Piedi';
texts['it'].meter = 'Metri';
texts['it'].knots = 'Nodi';
texts['it'].colorGradient = 'Gradiente di colori';
texts['it'].colors = 'colori';
texts['it'].flight = 'Volo';
texts['it'].airplane = 'Aeroplano';
texts['it'].flightInformation = 'Informazioni di volo';
texts['it'].aircraftInformation = 'Informazioni sul velivolo';
texts['it'].airline = 'Compagnia aerea';
texts['it'].airport = 'Aeroporto';
texts['it'].departure = 'Partenza';
texts['it'].arrival = 'Arrivo';
texts['it'].speed = 'Velocit&agrave;';
texts['it'].altitude = 'Altitudine';
texts['it'].position = 'Posizione';
texts['it'].verticalRate = 'Velocit&agrave; verticale';
texts['it'].trackingInformation = 'Informazioni di tracciamento';
texts['it'].scheduledDepartureTime = 'Orario di partenza';
texts['it'].actualDepartureTime = 'Ora attuale';
texts['it'].scheduledArrivalTime = 'Orario d\'arrivo';
texts['it'].estimatedArrivalTime = 'Orario d\'arrivo stimato';
texts['it'].registration = 'Registrazione';
texts['it'].manufacturer = 'Costruttore';
texts['it'].model = 'Modello';
texts['it'].type = 'Tipo';
texts['it'].buildYear = 'Anno di costruzione';
texts['it'].delivery = 'Consegna';
texts['it'].notAvailable = 'non disponibile';
texts['it'].units = 'Unit&agrave;';
texts['it'].shadow = 'Ombra';
texts['it'].metric = 'metrico';
texts['it'].aviatic = 'aviatico';
texts['it'].automatic = 'automatico';

// Inactivity Timeout
var inactivityCheckInterval = 60; // sec
var inactivityTimeoutTime = 600; // sec
var inactivityWarningTime = 60; // sec
var lastMouseMoveEventTimestamp = new Date().getTime(); // Initialize by current loca$
var inactivityStartTimestamp = 0;
var timeoutCheckTimer;
var timeoutWarningTimer;

// Version check Settings
var versionCheckTimer;
var versionCheckInterval = 100; // sec
var currentScriptVersion = '2.0';

// Request interval settings
var intervalCheckInterval = 100; // sec
var intervalCheckTimer;

// Delay settings
var serverTime = 0;

// Time Display
var showTimeDisplay = true;

