private static void LoadAirline(XmlElement airlineNode)
        {
            // chs, 2011-21-10 changed for the possibility of creating a new airline
            string airlineName = airlineNode.Attributes["name"].Value;
            string airlineIATA = airlineNode.Attributes["code"].Value;

            Boolean airlineIsSubsidiary = Convert.ToBoolean(airlineNode.Attributes["subsidiary"].Value);
            Country airlineCountry = Countries.GetCountry(airlineNode.Attributes["country"].Value);
            string color = airlineNode.Attributes["color"].Value;
            string airlineCEO = airlineNode.Attributes["CEO"].Value;
            double money = Convert.ToDouble(airlineNode.Attributes["money"].Value, new CultureInfo("de-DE", false));
            int reputation = Convert.ToInt16(airlineNode.Attributes["reputation"].Value);
            var mentality =
                (Airline.AirlineMentality)
                Enum.Parse(typeof (Airline.AirlineMentality), airlineNode.Attributes["mentality"].Value);
            var market =
                (AirlineFocus) Enum.Parse(typeof (AirlineFocus), airlineNode.Attributes["market"].Value);
            var license =
                (Airline.AirlineLicense)
                Enum.Parse(typeof (Airline.AirlineLicense), airlineNode.Attributes["license"].Value);
            Route.RouteType routefocus = airlineNode.HasAttribute("routefocus")
                                             ? (Route.RouteType) Enum.Parse(typeof (Route.RouteType), airlineNode.Attributes["routefocus"].Value)
                                             : Route.RouteType.Passenger;

            Boolean isReal = !airlineNode.HasAttribute("real") || Convert.ToBoolean(airlineNode.Attributes["real"].Value);
            int founded = airlineNode.HasAttribute("founded")
                              ? Convert.ToInt16(airlineNode.Attributes["founded"].Value)
                              : 1950;
            int folded = airlineNode.HasAttribute("folded")
                             ? Convert.ToInt16(airlineNode.Attributes["folded"].Value)
                             : 2199;

            Airline airline;
            if (airlineIsSubsidiary)
            {
                Airline parent = Airlines.GetAirline(airlineNode.Attributes["parentairline"].Value);
                airline = new SubsidiaryAirline(
                    parent,
                    new AirlineProfile(airlineName, airlineIATA, color, airlineCEO, isReal, founded, folded),
                    mentality,
                    market,
                    license,
                    routefocus) {Profile = {Country = airlineCountry}};
                parent.AddSubsidiaryAirline((SubsidiaryAirline) airline);
            }
            else
            {
                airline =
                    new Airline(
                        new AirlineProfile(airlineName, airlineIATA, color, airlineCEO, isReal, founded, folded),
                        mentality,
                        market,
                        license,
                        routefocus) {Profile = {Country = airlineCountry}};
            }
            if (airlineNode.HasAttribute("logo"))
            {
                string logo = AppSettings.GetDataPath() + "\\graphics\\airlinelogos\\"
                              + airlineNode.Attributes["logo"].Value;

                airline.Profile.AddLogo(new AirlineLogo(logo));
            }
            airline.Fleet.Clear();
            airline.Airports.Clear();
            airline.Routes.Clear();
            airline.Alliances.Clear();

            airline.Money = money;
            airline.Reputation = reputation;

            XmlNodeList logosList = airlineNode.SelectNodes("logos/logo");

            if (logosList != null)
                foreach (XmlElement logoElement in logosList)
                {
                    int logoFromYear = Convert.ToInt16(logoElement.Attributes["from"].Value);
                    int logoToYear = Convert.ToInt16(logoElement.Attributes["to"].Value);
                    string logoPath = logoElement.Attributes["path"].Value;

                    if (!File.Exists(logoPath))
                    {
                        logoPath = AppSettings.GetDataPath() + "\\graphics\\airlinelogos\\"
                                   + logoPath.Substring(logoPath.LastIndexOf('\\') + 1);
                    }

                    airline.Profile.AddLogo(new AirlineLogo(logoFromYear, logoToYear, logoPath));
                }

            var airlineContractNode = (XmlElement) airlineNode.SelectSingleNode("contract");
            if (airlineContractNode != null)
            {
                Manufacturer contractManufacturer =
                    Manufacturers.GetManufacturer(airlineContractNode.Attributes["manufacturer"].Value);
                DateTime contractSigningDate = DateTime.Parse(
                    airlineContractNode.Attributes["signingdate"].Value,
                    new CultureInfo("de-DE", false));
                int contractLength = Convert.ToInt16(airlineContractNode.Attributes["length"].Value);
                double contractDiscount = Convert.ToDouble(
                    airlineContractNode.Attributes["discount"].Value,
                    new CultureInfo("de-DE", false));
                int contractAirliners = Convert.ToInt16(airlineContractNode.Attributes["airliners"].Value);

                var contract = new ManufacturerContract(
                    contractManufacturer,
                    contractSigningDate,
                    contractLength,
                    contractDiscount) {PurchasedAirliners = contractAirliners};

                airline.Contract = contract;
            }

            // chs, 2011-17-10 added for loading of passenger happiness
            var airlinePassengerNode = (XmlElement) airlineNode.SelectSingleNode("passengerhappiness");
            if (airlinePassengerNode != null)
            {
                double passengerHappiness = Convert.ToDouble(
                    airlinePassengerNode.Attributes["value"].Value,
                    new CultureInfo("de-DE", false));
                PassengerHelpers.SetPassengerHappiness(airline, passengerHappiness);
            }

            XmlNodeList airlineFacilitiesList = airlineNode.SelectNodes("facilities/facility");
            if (airlineFacilitiesList != null)
                foreach (XmlElement airlineFacilityNode in airlineFacilitiesList)
                {
                    string airlineFacility = airlineFacilityNode.Attributes["uid"].Value;

                    airline.AddFacility(AirlineFacilities.GetFacility(airlineFacility));
                }

            XmlNodeList airlinePoliciesList = airlineNode.SelectNodes("policies/policy");

            foreach (XmlElement airlinePolicyNode in airlinePoliciesList)
            {
                string policyName = airlinePolicyNode.Attributes["name"].Value;
                object policyValue = airlinePolicyNode.Attributes["value"].Value;

                int number;
                airline.AddAirlinePolicy(int.TryParse(policyValue.ToString(), out number) ? new AirlinePolicy(policyName, number) : new AirlinePolicy(policyName, policyValue));
            }

            XmlNodeList airlineLoanList = airlineNode.SelectNodes("loans/loan");
            foreach (XmlElement airlineLoanNode in airlineLoanList)
            {
                DateTime date = DateTime.Parse(
                    airlineLoanNode.Attributes["date"].Value,
                    new CultureInfo("de-DE", false));
                double rate = Convert.ToDouble(
                    airlineLoanNode.Attributes["rate"].Value,
                    new CultureInfo("de-DE", false));
                double amount = Convert.ToDouble(
                    airlineLoanNode.Attributes["amount"].Value,
                    new CultureInfo("de-DE", false));
                int length = Convert.ToInt16(airlineLoanNode.Attributes["length"].Value);
                double payment = Convert.ToDouble(
                    airlineLoanNode.Attributes["payment"].Value,
                    new CultureInfo("de-DE", false));

                var loan = new Loan(date, amount, length, rate) {PaymentLeft = payment};

                airline.AddLoan(loan);
            }

            XmlNodeList airlineStatList = airlineNode.SelectNodes("stats/stat");
            foreach (XmlElement airlineStatNode in airlineStatList)
            {
                int year = Convert.ToInt32(airlineStatNode.Attributes["year"].Value);
                string airlineStatType = airlineStatNode.Attributes["type"].Value;
                double value = Convert.ToDouble(
                    airlineStatNode.Attributes["value"].Value,
                    new CultureInfo("de-DE", false));

                airline.Statistics.SetStatisticsValue(year, StatisticsTypes.GetStatisticsType(airlineStatType), value);
            }

            XmlNodeList airlineInvoiceList = airlineNode.SelectNodes("invoices/invoice");

            foreach (XmlElement airlineInvoiceNode in airlineInvoiceList)
            {
                var type =
                    (Invoice.InvoiceType)
                    Enum.Parse(typeof (Invoice.InvoiceType), airlineInvoiceNode.Attributes["type"].Value);
                int invoiceYear = Convert.ToInt16(airlineInvoiceNode.Attributes["year"].Value);
                int invoiceMonth = Convert.ToInt16(airlineInvoiceNode.Attributes["month"].Value);
                double invoiceAmount = Convert.ToDouble(
                    airlineInvoiceNode.Attributes["amount"].Value,
                    new CultureInfo("de-DE", false));

                airline.SetInvoice(type, invoiceYear, invoiceMonth, 1, invoiceAmount);
            }

            // chs, 2011-13-10 added for loading of airline advertisements
            XmlNodeList advertisementList = airlineNode.SelectNodes("advertisements/advertisement");

            foreach (XmlElement advertisementNode in advertisementList)
            {
                var type =
                    (AdvertisementType.AirlineAdvertisementType)
                    Enum.Parse(
                        typeof (AdvertisementType.AirlineAdvertisementType),
                        advertisementNode.Attributes["type"].Value);
                string advertisementName = advertisementNode.Attributes["name"].Value;

                airline.SetAirlineAdvertisement(AdvertisementTypes.GetType(type, advertisementName));
            }
            // chs, 2011-17-10 added for loading of fees
            var fees = new AirlineFees();

            XmlNodeList airlineFeeList = airlineNode.SelectNodes("fees/fee");
            foreach (XmlElement feeNode in airlineFeeList)
            {
                string feeType = feeNode.Attributes["type"].Value;
                double feeValue = Convert.ToDouble(feeNode.Attributes["value"].Value, new CultureInfo("de-DE", false));

                fees.SetValue(FeeTypes.GetType(feeType), feeValue);
            }

            airline.Fees = fees;

            XmlNodeList flightschoolsList = airlineNode.SelectNodes("flightschools/flightschool");

            foreach (XmlElement flightschoolNode in flightschoolsList)
            {
                string fsID = flightschoolNode.Attributes["id"].Value;
                Airport fsAirport = Airports.GetAirportFromID(flightschoolNode.Attributes["airport"].Value);

                var fs = new FlightSchool(fsAirport) {ID = fsID};

                XmlNodeList aircraftsList = flightschoolNode.SelectNodes("trainingaircrafts/trainingaircraft");

                foreach (XmlElement aircraftNode in aircraftsList)
                {
                    TrainingAircraftType aircraftType =
                        TrainingAircraftTypes.GetAircraftType(aircraftNode.Attributes["type"].Value);
                    DateTime aircraftDate = DateTime.Parse(
                        aircraftNode.Attributes["date"].Value,
                        new CultureInfo("de-DE", false));

                    fs.AddTrainingAircraft(new TrainingAircraft(aircraftType, aircraftDate, fs));
                }

                XmlNodeList studentsList = flightschoolNode.SelectNodes("students/student");

                foreach (XmlElement studentNode in studentsList)
                {
                    string firstname = studentNode.Attributes["firstname"].Value;
                    string lastname = studentNode.Attributes["lastname"].Value;
                    DateTime birthdate = DateTime.Parse(
                        studentNode.Attributes["birthdate"].Value,
                        new CultureInfo("de-DE", false));
                    Town town = Towns.GetTown(studentNode.Attributes["town"].Value);
                    DateTime startdate = DateTime.Parse(
                        studentNode.Attributes["startdate"].Value,
                        new CultureInfo("de-DE", false));

                    fs.AddStudent(
                        new PilotStudent(
                            new PilotProfile(firstname, lastname, birthdate, town),
                            startdate,
                            null,
                            null,
                            ""));
                }

                airline.AddFlightSchool(fs);
            }

            XmlNodeList airlineFleetList = airlineNode.SelectNodes("fleet/airliner");

            foreach (XmlElement airlineAirlinerNode in airlineFleetList)
            {
                Airliner airliner = Airliners.GetAirliner(airlineAirlinerNode.Attributes["airliner"].Value);

                string fAirlinerName = airlineAirlinerNode.Attributes["name"].Value;
                Airport homebase = Airports.GetAirport(airlineAirlinerNode.Attributes["homebase"].Value);
                var purchasedtype =
                    (FleetAirliner.PurchasedType)
                    Enum.Parse(
                        typeof (FleetAirliner.PurchasedType),
                        airlineAirlinerNode.Attributes["purchased"].Value);
                DateTime purchasedDate = DateTime.Parse(
                    airlineAirlinerNode.Attributes["date"].Value,
                    new CultureInfo("de-DE", false));
                var status =
                    (FleetAirliner.AirlinerStatus)
                    Enum.Parse(typeof (FleetAirliner.AirlinerStatus), airlineAirlinerNode.Attributes["status"].Value);
                DateTime groundedDate = DateTime.Parse(
                    airlineAirlinerNode.Attributes["groundeddate"].Value,
                    new CultureInfo("de-DE", false));

                // Coordinate latitude = Coordinate.Parse(airlineAirlinerNode.Attributes["latitude"].Value);
                //Coordinate longitude = Coordinate.Parse(airlineAirlinerNode.Attributes["longitude"].Value);

                string[] latitude = airlineAirlinerNode.Attributes["value"].Value.Split('°', '\'', '\'');
                string[] longitude = airlineAirlinerNode.Attributes["value"].Value.Split('°', '\'', '\'');
                var coords = new int[6];
                foreach (string l in latitude)
                {
                    int c = 0;
                    int.TryParse(l, out coords[c]);
                    c++;
                }

                foreach (string l in longitude)
                {
                    int c = 3;
                    int.TryParse(l, out coords[c]);
                    c++;
                }

                //cleaning up
                latitude = null;
                longitude = null;

                var pos = new GeoCoordinate(
                    MathHelpers.DMStoDeg(coords[0], coords[1], coords[2]),
                    MathHelpers.DMStoDeg(coords[3], coords[4], coords[5]));

                var fAirliner = new FleetAirliner(purchasedtype, purchasedDate, airline, airliner, homebase) {CurrentPosition = null, Status = status, GroundedToDate = groundedDate};

                XmlNodeList airlinerStatList = airlineAirlinerNode.SelectNodes("stats/stat");

                foreach (XmlElement airlinerStatNode in airlinerStatList)
                {
                    int year = Convert.ToInt32(airlinerStatNode.Attributes["year"].Value);
                    string statType = airlinerStatNode.Attributes["type"].Value;
                    double statValue = Convert.ToDouble(
                        airlinerStatNode.Attributes["value"].Value,
                        new CultureInfo("de-DE", false));
                    fAirliner.Statistics.SetStatisticsValue(
                        year,
                        StatisticsTypes.GetStatisticsType(statType),
                        statValue);
                }

                airline.AddAirliner(fAirliner);
            }
            XmlNodeList routeList = airlineNode.SelectNodes("routes/route");

            foreach (XmlElement routeNode in routeList)
            {
                airline.AddRoute(LoadRoute(routeNode, airline));
            }

            XmlNodeList flightNodes = airlineNode.SelectNodes("flights/flight");
            foreach (XmlElement flightNode in flightNodes)
            {
                FleetAirliner airliner =
                    airline.Fleet.Find(a => a.Airliner.ID == flightNode.Attributes["airliner"].Value);

                if (airliner != null)
                {
                    Route route = airline.Routes.Find(r => r.Id == flightNode.Attributes["route"].Value);

                    if (route != null)
                    {
                        string destination = flightNode.Attributes["destination"].Value;

                        var day = (DayOfWeek) Enum.Parse(typeof (DayOfWeek), flightNode.Attributes["day"].Value);
                        TimeSpan time = TimeSpan.Parse(flightNode.Attributes["time"].Value);
                        DateTime flightTime = DateTime.Parse(
                            flightNode.Attributes["flighttime"].Value,
                            new CultureInfo("de-DE", false));

                        var stopoverNode = (XmlElement) flightNode.SelectSingleNode("stopover");

                        Boolean isStopoverFlight = stopoverNode != null;

                        if (destination != "Service")
                        {
                            RouteTimeTableEntry rtte =
                                route.TimeTable.Entries.Find(
                                    e => e.Destination.FlightCode == destination && e.Day == day && e.Time == time);

                            var currentFlight = new Flight(rtte) {FlightTime = flightTime};
                            currentFlight.Classes.Clear();

                            if (currentFlight.IsPassengerFlight())
                            {
                                XmlNodeList flightClassList = flightNode.SelectNodes("flightclasses/flightclass");

                                foreach (XmlElement flightClassNode in flightClassList)
                                {
                                    var airlinerClassType =
                                        (AirlinerClass.ClassType)
                                        Enum.Parse(
                                            typeof (AirlinerClass.ClassType),
                                            flightClassNode.Attributes["type"].Value);
                                    int flightPassengers =
                                        Convert.ToInt16(flightClassNode.Attributes["passengers"].Value);

                                    currentFlight.Classes.Add(
                                        new FlightAirlinerClass(
                                            ((PassengerRoute) route).GetRouteAirlinerClass(airlinerClassType),
                                            flightPassengers));
                                }
                            }
                            if (currentFlight.IsCargoFlight())
                            {
                                var flightCargoNode = (XmlElement) flightNode.SelectSingleNode("flightcargo");
                                double flightCargo = Convert.ToDouble(
                                    flightCargoNode.Attributes["cargo"].Value,
                                    new CultureInfo("de-DE", false));

                                currentFlight.Cargo = flightCargo;
                            }
                            if (isStopoverFlight)
                            {
                                int currentStopoverFlight =
                                    Convert.ToInt32(stopoverNode.Attributes["currentflight"].Value);

                                XmlNodeList stopoverClassesList = stopoverNode.SelectNodes("classes/class");

                                var stopEntryAllClasses =
                                    new Dictionary<RouteTimeTableEntry, List<FlightAirlinerClass>>();

                                foreach (XmlElement stopoverClassNode in stopoverClassesList)
                                {
                                    RouteTimeTableEntry stopoverEntry =
                                        airline.Routes.SelectMany(r => r.TimeTable.Entries)
                                               .ToList()
                                               .Find(e => e.ID == stopoverClassNode.Attributes["id"].Value);

                                    XmlNodeList stopoverFlightClassList =
                                        stopoverClassNode.SelectNodes("flightclasses/flightclass");

                                    List<FlightAirlinerClass> stopoverFlightClasses = (from XmlElement stopoverFlightClassNode in stopoverFlightClassList
                                                                                       let stopoverAirlinerClassType =
                                                                                           (AirlinerClass.ClassType)
                                                                                           Enum.Parse(typeof (AirlinerClass.ClassType), stopoverFlightClassNode.Attributes["type"].Value)
                                                                                       let stopoverFlightPassengers = Convert.ToInt16(stopoverFlightClassNode.Attributes["passengers"].Value)
                                                                                       select
                                                                                           new FlightAirlinerClass(((PassengerRoute) route).GetRouteAirlinerClass(stopoverAirlinerClassType),
                                                                                                                   stopoverFlightPassengers)).ToList();

                                    stopEntryAllClasses.Add(stopoverEntry, stopoverFlightClasses);
                                }

                                XmlNodeList stopoverCargosList = stopoverNode.SelectNodes("cargos/cargo");

                                var stopEntryAllCargo = new Dictionary<RouteTimeTableEntry, double>();

                                foreach (XmlElement stopoverCargoNode in stopoverCargosList)
                                {
                                    RouteTimeTableEntry stopoverEntry =
                                        airline.Routes.SelectMany(r => r.TimeTable.Entries)
                                               .ToList()
                                               .Find(e => e.ID == stopoverCargoNode.Attributes["id"].Value);
                                    double cargoValue = Convert.ToDouble(
                                        stopoverCargoNode.Attributes["value"].Value,
                                        new CultureInfo("de-DE", false));

                                    stopEntryAllCargo.Add(stopoverEntry, cargoValue);
                                }

                                var stopoverFlight = new StopoverFlight(rtte)
                                    {
                                        AllClasses = stopEntryAllClasses,
                                        AllCargo = stopEntryAllCargo,
                                        CurrentFlight = currentStopoverFlight,
                                        FlightTime = currentFlight.FlightTime,
                                        Classes = currentFlight.Classes
                                    };

                                airliner.CurrentFlight = stopoverFlight;
                            }
                            else
                            {
                                airliner.CurrentFlight = currentFlight;
                            }
                        }
                        else
                        {
                            airliner.CurrentFlight =
                                new Flight(
                                    new RouteTimeTableEntry(
                                        route.TimeTable,
                                        GameObject.GetInstance().GameTime.DayOfWeek,
                                        GameObject.GetInstance().GameTime.TimeOfDay,
                                        new RouteEntryDestination(airliner.Homebase, "Service", null),
                                        null));

                            airliner.Status = FleetAirliner.AirlinerStatus.OnService;
                        }
                    }
                    else
                    {
                        airliner.Status = FleetAirliner.AirlinerStatus.Stopped;
                    }
                }
            }
            Airlines.AddAirline(airline);
        }
        //orders the airliners
        private void btnSignContract_Click(object sender, RoutedEventArgs e)
        {
            Boolean newContract = true;
            if (GameObject.GetInstance().HumanAirline.Contract != null)
            {
                double terminationFee = GameObject.GetInstance().HumanAirline.Contract.GetTerminationFee();
                WPFMessageBoxResult result = WPFMessageBox.Show(
                    Translator.GetInstance().GetString("MessageBox", "2010"),
                    string.Format(
                        Translator.GetInstance().GetString("MessageBox", "2010", "message"),
                        GameObject.GetInstance().HumanAirline.Contract.Manufacturer.Name,
                        terminationFee),
                    WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    AirlineHelpers.AddAirlineInvoice(
                        GameObject.GetInstance().HumanAirline,
                        GameObject.GetInstance().GameTime,
                        Invoice.InvoiceType.Purchases,
                        -terminationFee);
                    GameObject.GetInstance().HumanAirline.Contract = null;
                }
                else
                {
                    newContract = false;
                }
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(
                    Translator.GetInstance().GetString("MessageBox", "2013"),
                    string.Format(
                        Translator.GetInstance().GetString("MessageBox", "2013", "message"),
                        this.Manufacturer.Name),
                    WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.No)
                {
                    newContract = false;
                }
            }

            if (newContract)
            {
                int length = Convert.ToInt16(((ComboBoxItem)this.cbContractLenth.SelectedItem).Tag);

                double discount =
                    AirlineHelpers.GetAirlineManufactorerDiscountFactor(
                        GameObject.GetInstance().HumanAirline,
                        length,
                        true);

                var contract = new ManufacturerContract(
                    this.Manufacturer,
                    GameObject.GetInstance().GameTime,
                    length,
                    discount);
                GameObject.GetInstance().HumanAirline.Contract = contract;

                this.Contract.Contracted = contract.Manufacturer;
            }
        }