﻿if ( !window.Entities )
    window.Entities = {};
    
Entities.TripLeg = function( xmlData )
{
    for ( var k=0; k<xmlData.childNodes.length; k++ )
    {
        if ( xmlData.childNodes[k].nodeName == "airline" )
            this.airline = xmlData.childNodes[k].childNodes[0].nodeValue;
        if ( xmlData.childNodes[k].nodeName == "orig" )
            this.orig = xmlData.childNodes[k].childNodes[0].nodeValue;
        if ( xmlData.childNodes[k].nodeName == "dest" )
            this.dest = xmlData.childNodes[k].childNodes[0].nodeValue;
        if ( xmlData.childNodes[k].nodeName == "depart" )
            this.depart = xmlData.childNodes[k].childNodes[0].nodeValue;
        if ( xmlData.childNodes[k].nodeName == "arrive" )
            this.arrive = xmlData.childNodes[k].childNodes[0].nodeValue;
        if ( xmlData.childNodes[k].nodeName == "stops" )
            this.stops = xmlData.childNodes[k].childNodes[0].nodeValue;
        if ( xmlData.childNodes[k].nodeName == "duration_minutes" )
            this.duration = xmlData.childNodes[k].childNodes[0].nodeValue;
        if ( xmlData.childNodes[k].nodeName == "cabin" )
            this.cabin = xmlData.childNodes[k].childNodes[0].nodeValue;
        else if ( xmlData.childNodes[k].nodeName == "segment" )
            this.segments[ this.segments.length ] = new Entities.TripLegSegment( xmlData.childNodes[k] );
    }
}

Entities.TripLeg.prototype.airline = null;
Entities.TripLeg.prototype.orig = null;
Entities.TripLeg.prototype.dest = null;
Entities.TripLeg.prototype.depart = null;
Entities.TripLeg.prototype.arrive = null;
Entities.TripLeg.prototype.stops = null;
Entities.TripLeg.prototype.duration = null;
Entities.TripLeg.prototype.cabin = null;
Entities.TripLeg.prototype.segments = [];

Entities.TripLeg.prototype.getAirline = function()
{
    return this.airline;
}
Entities.TripLeg.prototype.getOrig = function()
{
    return this.orig;
}
Entities.TripLeg.prototype.getDest = function()
{
    return this.dest;
}
Entities.TripLeg.prototype.getDepart = function()
{
    return this.depart;
}
Entities.TripLeg.prototype.getArrive = function()
{
    return this.arrive;
}
Entities.TripLeg.prototype.getStops = function()
{
    return this.stops;
}
Entities.TripLeg.prototype.getDuration = function()
{
    return this.duration;
}
Entities.TripLeg.prototype.getCabin = function()
{
    return this.cabin;
}
Entities.TripLeg.prototype.getSegments = function()
{
    return this.segments;
}