function FlightSegment( segment, search ) {
	this.thousandsSeparator = search.thousandsSeparator;
	this.currencySymbol = search.currencySymbol;
	this.priceUnset = search.priceUnset;
	this.isRoundtrip = search.isRoundtrip;
    
    //Entfernt
    /*
    this.departure = segment.departure;
	this.arrival = segment.arrival;
    this.stopovers = segment.stopovers;
    */
    
    //New
	this.carrierIdPostfixes = search.carrierIdPostfixes;
	this.carrierIdPrefix = search.carrierIdPrefix;
	this.maxLegInfos = search.maxLegInfos;
    
	this.maxSupplements = search.maxSupplements;
	this.grossPriceId = search.grossPriceId;
    
    //New
	this.legCount = segment.legCount;
	this.legInfos1 = segment.legInfos1;
	this.legInfos2 = segment.legInfos2;
	this.carrierCodes = segment.carrierCodes;
    
	this.travelDate = segment.travelDate;
	this.compartment = segment.compartment;
	this.compartmentName = segment.compartmentName;
	this.grossPrice = segment.grossPrice;
	this.netPrice = segment.netPrice;
	this.supplementNames = segment.supplementNames;
	this.supplementPrices = segment.supplementPrices;
	this.seats = segment.seats;
	this.value = segment.value;
    //Add: boundDate
    this.boundDate = segment.boundDate;
	this.segmentList = segment.segmentList;

	var that = this;

	this.setSegment = function () {
		that.setFlightDetails();
		that.setPriceDetails();
		xGetElementById(that.segmentList.flightDetailsSegmentId).value = that.value;
		xGetElementById(that.segmentList.priceDetailsSegmentId).value = that.value;
        //Add: searchDateId, vacancyDateId 
        xGetElementById(that.segmentList.searchDateId).value = that.boundDate;      
        xGetElementById(that.segmentList.vacancyDateId).value = that.boundDate;
        
		if ( that.segmentList.isOutbound ) {
			ibe.outboundSegment = that;
		} else {
			ibe.inboundSegment = that;
		}
		that.writeTotalGrossPrice();
        //Carrier ausgeblendet
//		that.writeCarrierLegend();
	};

	//-----------------------------------------------------------------------------
	// flight class
	//-----------------------------------------------------------------------------

	this.checkCompartment = function (compartment) {
		return compartment == that.compartment;
	};

	//-----------------------------------------------------------------------------
	// flight details
	//-----------------------------------------------------------------------------
    
    //Alte Version
    /*
    this.setFlightDetails = function () {
	  xSetTextval(that.segmentList.departureId, that.departure);
	  xSetTextval(that.segmentList.arrivalId, that.arrival);
	  xSetTextval(that.segmentList.stopoversId, that.stopovers);
	  xSetTextval(that.segmentList.travelDateId, that.travelDate);
	  xSetTextval(that.segmentList.compartmentNameId, that.compartmentName);
	  xSetTextval(that.segmentList.availableSeatsTopId, that.seats);
	  xSetTextval(that.segmentList.availableSeatsBottomId, that.seats);
	};

	this.getLegCount = function () {
	  return that.legCount;
	};
    */
	this.getMaxLegInfos = function () {
		return that.maxLegInfos;
	};

	this.setFlightDetails = function () {
		xSetTextval(that.segmentList.travelDateId, that.travelDate);
		xSetTextval(that.segmentList.compartmentNameId, that.compartmentName);
		xSetTextval(that.segmentList.availableSeatsTopId, that.seats);
		xSetTextval(that.segmentList.availableSeatsBottomId, that.seats);
        //LegInfos ausgeblendet
		for ( var i = 0; i < that.legInfos1.length; i++ ) {
			xSetTextval(that.getLegInfo1Id(i), that.getLegInfo1(i));
			xSetTextval(that.getLegInfo2Id(i), that.getLegInfo2(i));
		}
		for ( var i = that.legInfos1.length; i < that.getMaxLegInfos(); i++ ) {
			xSetTextval(that.getLegInfo1Id(i), "");
			xSetTextval(that.getLegInfo2Id(i), "");
		}
	};

    
   this.getLegInfo1Id = function (index) {
		return that.segmentList.legInfo1IdPrefix + index;
	};
    
    //LegInfos2 ausgeblendet
	this.getLegInfo2Id = function (index) {
		return that.segmentList.legInfo2IdPrefix + index;
	};

	this.getLegInfo1 = function (index) {
		return that.legInfos1[index];
	};

	this.getLegInfo2 = function (index) {
		return that.legInfos2[index];
	};
	
	this.getLegCount = function () {
		return that.legCount;
	};

	//-- carrierLegend ------------------------------------------------------------
    
    //Neu!
    //Carrier ausgeblendet, table carrierlegend grid
//	this.writeCarrier = function() {
//		for ( var i = 0; i < that.carrierCodes.length; i++ ) {
//			xExpandTableRowById(that.carrierIdPrefix + that.carrierCodes[i]);
//		}
//	};
//	
//	this.writeCarrierLegend = function() {
//		for ( var i = 0; i < that.carrierIdPostfixes.length; i++ ) {
//			xCollapseTableRowById(that.carrierIdPrefix + that.carrierIdPostfixes[i]);
//		}
//
//		if ( ibe.outboundSegment ) {
//			ibe.outboundSegment.writeCarrier();
//		}
//		if ( that.isRoundtrip && ibe.inboundSegment ) {
//			ibe.inboundSegment.writeCarrier();
//		}
//	};

	//-----------------------------------------------------------------------------
	// price details, supplements, total gross 
	//-----------------------------------------------------------------------------

	//-- price details ------------------------------------------------------------

	this.getMaxSupplements = function () {
		return that.maxSupplements;
	};

	this.resetPriceDetails = function () {
		xSetTextval(that.segmentList.netPriceId, "");
		for ( var i = 0; i < that.getMaxSupplements(); i++ ) {
			xSetTextval(that.getSupplementNameId(i), "");
			xSetTextval(that.getSupplementPriceId(i), "");
		}
	};

	this.setPriceDetails = function () {
		that.resetPriceDetails();
		xSetTextval(that.segmentList.netPriceId, getPriceString(that.netPrice));
		for ( var i = 0; i < that.supplementNames.length; i++ ) {
			xSetTextval(that.getSupplementNameId(i), that.getSupplementName(i));
			xSetTextval(that.getSupplementPriceId(i), that.getSupplementPrice(i));
		}
	};

	this.getSupplementNameId = function (index) {
		return that.segmentList.supplementNameIdPrefix + index;
	};

	this.getSupplementPriceId = function (index) {
		return that.segmentList.supplementPriceIdPrefix + index;
	};

	this.getSupplementName = function (index) {
		return that.supplementNames[index];
	};

	this.getSupplementPrice = function (index) {
		return getPriceString(that.supplementPrices[index]);
	};
	
	//-- totalGross ---------------------------------------------------------------

	this.writeTotalGrossPrice = function() {
		var text = that.priceUnset;
		var outboundGrossPrice = 0;
		var inboundGrossPrice = 0;
		if ( ibe.outboundSegment ) {
			outboundGrossPrice = getPrice(ibe.outboundSegment.grossPrice);
		}
		if ( that.isRoundtrip && ibe.inboundSegment ) {
			inboundGrossPrice = getPrice(ibe.inboundSegment.grossPrice);
		}
		if ( outboundGrossPrice >= 0 && inboundGrossPrice >= 0 ) {
			text = getPriceString(outboundGrossPrice + inboundGrossPrice);
		}
		xSetTextval(that.grossPriceId, text);
	};

	//-------------------------------------------------------------------------
	// private
	//-------------------------------------------------------------------------
	// turns price (number) into 'n.nnn E'
	function getPriceString( p ) {
		var s =	"";
		if ( p >= 0 ) {
			s = ibeUtil.int_to_tt(p, that.thousandsSeparator)
			+ "&#160;" + that.currencySymbol;
		} else {
			s = that.priceUnset;
		}
		return s;
	}

	// evaluates price (number): -1, if unset
	function getPrice( p ) {
		var v = parseInt( p );
		if ( isNaN( v ) || v < 0 ) {
			v = -1;
		}
		return v;
	}

	//-------------------------------------------------------------------------
	// public
	//-------------------------------------------------------------------------
	this.unload = function( ) {
		// cbErrorSearch.js:
		// Throw everything away. This is a special service for the IE,
		// which has an own understanding of garbage collection.
		this.node_mode_ow.hd_unload( );
		this.node_mode_rt.hd_unload( );
		
		// cbLBP.js:
		for ( var i = 0; i < this.allNodes.length; i++ ) {
			var node = this.allNodes[ i ];
			Loc.clean_node( node, [ "loc" ] );

			if ( node && node.parentNode ) {
				node.parentNode.removeChild( node );
			}
		}
	};

	return this;
}


