function csHotel(o) {
    this.passportCode = filterNull(o.passportCode);
    this.hotelName = filterNull(o.hotelName);
    this.cityName = filterNull(o.cityName);
    this.addressLine = filterNull(o.addressLine);
    this.minPrice = filterNull(o.minPrice);
    this.aboutMinPrice = filterNull(o.aboutMinPrice);
    this.transferedMinPrice = filterNull(o.transferedMinPrice);
    this.minPricePaymentType = filterNull(o.minPricePaymentType);
    this.maxPrice = filterNull(o.maxPrice);
    this.currency = filterNull(o.currency);
    this.aboutCurrency = filterNull(o.aboutCurrency);
    this.languageCode = filterNull(o.languageCode);
    this.latitude = filterNull(o.latitude);
    this.longitude = filterNull(o.longitude);
    this.description = filterNull(o.description);
    this.phone = filterNull(o.phone);
    this.fax = filterNull(o.fax);
    this.websiteUrl = filterNull(o.websiteUrl);
    this.needGuarantee = filterNull(o.needGuarantee);
    this.hotelRating = filterNull(o.hotelRating);
    this.equilantRating = o.equilantRating;
    this.groupCode = filterNull(o.groupCode);
    this.administrativeAreaCode = filterNull(o.administrativeAreaCode);
    this.commercialAreaCode = filterNull(o.commercialAreaCode);
    this.favorite = filterNull(o.favorite);
    this.hotHotel = o.hotHotel;
    this.realTimeConfirm = o.realTimeConfirm;
    this.equilantRating = o.equilantRating;
    this.hotelCategory = o.hotelCategory;
    this.bookingNote = filterNull(o.bookingNote);
    this.derbyBookingNote = filterNull(o.derbyBookingNote);
    this.reviewCount = filterNull(o.reviewCount);
    this.reviewAverage = filterNull(o.reviewAverage);
    this.cancelPolicyCategory = filterNull(o.cancelPolicyCategory);
    this.lastUpdateTime = o.lastUpdateTime;

    this.chargeItem = filterNull(o.chargeItem);
    this.amenities = o.amenities;

    if (o.roomRates) {
        this.roomRates = tranRoomRates(o.roomRates);
    }

    this.isAgentHotel = function() {
        return this.hotelCategory.toUpperCase() == 'AGENT';
    }

    this.isGroupHotel = function() {
        return this.hotelCategory.toUpperCase() == 'GROUPHOTEL';
    }

    function tranRoomRates(rs) {
        var roomRates = new Array();
        for (var i = 0; i < rs.length; i++) {
            roomRates[i] = new csRoomRate(rs[i]);
        }
        return roomRates;
    }

    function csRoomRate(r) {
        this.ratePlanName = filterNull(r.ratePlanName);
        this.needGuarantee = filterNull(r.needGuarantee);

        this.roomTypeCode = filterNull(r.roomTypeCode);
        this.ratePlanCode = filterNull(r.ratePlanCode);
        this.roomTypeName = filterNull(r.roomTypeName);
        this.roomDescription = filterNull(r.roomDescription);
        this.serviceChargeInfo = filterNull(r.serviceChargeInfo);
        this.taxInfo = filterNull(r.taxInfo);
        this.serviceChargeAmount = filterNull(r.serviceChargeAmount);
        this.serviceChargePercent = filterNull(r.serviceChargePercent);
        this.taxAmount = filterNull(r.taxAmount);
        this.taxPercent = filterNull(r.taxPercent);

        this.taxAndFeesType = filterNull(r.taxAndFeesType);
        this.cancelPolicies = r.cancelPolicies;
        this.mealPlanValues = r.mealPlanValues;
        this.roomAmenityValues = r.roomAmenityValues;

        this.maxOccupancy = filterNull(r.maxOccupancy);//最大入住人数
        this.maxAddMealNumber = filterNull(r.maxAddMealNumber);//最大加餐数
        this.maxAddBedNumber = filterNull(r.maxAddBedNumber);//最大加床数
        this.allotment = filterNull(r.allotment); //可定房间数
        this.bookingNote = filterNull(r.bookingNote);
        if (r.currency) {
            this.currency = filterNull(r.currency);
        }
        if (r.cashRates) {
            this.cashRates = tranRates(r.cashRates);
        }
        if (r.prepayRates) {
            this.prepayRates = tranRates(r.prepayRates);
        }
    }

    function tranRates(vRs) {
        var rates = new Array();
        for (var i = 0; i < vRs.length; i++) {
            rates[rates.length] = new csViewOfRate(vRs[i]);
        }
        return rates;
    }

    function csViewOfRate(vR) {
        this.start = filterNull(vR.start);
        this.end = filterNull(vR.end);

        this.includeTax = vR.includeTax;

        this.cashAmount = getTwoFloat(vR.cashAmount);
        this.commissionAmount = getTwoFloat(vR.commissionAmount);

        this.aboutCashAmount = filterNull(vR.aboutCashAmount);
        this.aboutCommissionAmount = filterNull(vR.aboutCommissionAmount);

        this.cashScore = getTwoFloat(vR.cashScore);

        this.prepayAmount = getTwoFloat(vR.prepayAmount);
        this.prepayCostAmount = getTwoFloat(vR.prepayCostAmount);
        this.prepayHotelAmount = getTwoFloat(vR.prepayHotelAmount);

        this.aboutPrepayAmount = filterNull(vR.aboutPrepayAmount);
        this.aboutPrepayCostAmount = filterNull(vR.aboutPrepayCostAmount);

        this.prepayDiscount=getTwoFloat(vR.prepayDiscount);

        this.serviceCharge = vR.serviceCharge;

        this.viewOfRoomTypeAdditionalInfo = vR.viewOfRoomTypeAdditionalInfo;
        if (this.viewOfRoomTypeAdditionalInfo) {
            this.breakfastType = filterNull(this.viewOfRoomTypeAdditionalInfo.breakfastType);
            this.breakfastNumber = filterNull(this.viewOfRoomTypeAdditionalInfo.breakfastNumber);
            this.addBedPrice = filterNull(this.viewOfRoomTypeAdditionalInfo.addBedPrice);
            this.addMealPrice = filterNull(this.viewOfRoomTypeAdditionalInfo.addMealPrice);
        }
    }

    this.haveRate = function() {
        if (this.minPrice != "" || this.maxPrice != "") {
            return true;
        }
        return false;
    }

    this.isFavorite = function() {
        if (this.favorite == "") {
            return false;
        }
        return this.favorite;
    }
}

function csAir(o) {

    if (o.viewOfFlightSegments) {
        this.flights = translateFlights(o.viewOfFlightSegments);
    }

    function csOfFlight(vflight) {
        this.languageCode = filterNull(o.languageCode);
        this.bookingNote = filterNull(o.bookingNote);
        this.comment = filterNull(o.comment);
        this.providerSign = filterNull(o.providerSign);

        this.id = filterNull(vflight.id);
        this.deliverNote = filterNull(vflight.deliverNote);
        this.airlineRule = filterNull(vflight.airlineRule);
        this.originCode = filterNull(vflight.originCode);
        this.destinationCode = filterNull(vflight.destinationCode);
        this.departureDate = filterNull(vflight.departureDate);
        this.arrivalDate = filterNull(vflight.arrivalDate);
        this.airlineCode = filterNull(vflight.airlineCode);
        this.flightNumber = filterNull(vflight.flightNumber);
        this.airCode = filterNull(vflight.airCode);
        this.airType = filterNull(vflight.airType);
        this.ticketType = filterNull(vflight.ticketType);
        this.stopQuantity = filterNull(vflight.stopQuantity);
        this.voyage = filterNull(vflight.voyage);
        this.meal = filterNull(vflight.meal);
        this.basePrice = filterNull(vflight.basePrice);
        this.airportTax = getTwoFloat(vflight.airportTax);
        this.fuelTax = getTwoFloat(vflight.fuelTax);
        this.currencyCode = filterNull(vflight.currencyCode);
        this.providerName = filterNull(vflight.providerName);
        this.providerPhone = filterNull(vflight.providerPhone);



        if (vflight.cabins) {
            this.cabins = translateCabins(vflight.cabins);
        }

        this.depTimeStr = filterNull(vflight.depTimeStr);
        this.arrTimeStr = filterNull(vflight.arrTimeStr);
        this.origCityName = filterNull(vflight.origCityName);
        this.destCityName = filterNull(vflight.destCityName);
        this.airlineName = filterNull(vflight.airlineName);

        if (vflight.cheapCabin != null) {
            this.cheapCabin = new csOfCabin(vflight.cheapCabin);
        }

        this.commissionFetched = filterNull(vflight.commissionFetched);

    }

    function translateFlights(vflights) {
        var flights = new Array();
        for (var i = 0; i < vflights.length; i++) {
            flights[flights.length] = new csOfFlight(vflights[i]);
        }
        return flights;
    }

    function csOfCabin(vCabin) {
        this.cabinCode = filterNull(vCabin.cabinCode);
        this.quantity = filterNull(vCabin.quantity);
        this.cabinType = filterNull(vCabin.cabinType);
        this.cabinTypeName = filterNull(vCabin.cabinTypeName);
        this.selected = filterNull(vCabin.selected);
        this.currencyCode = filterNull(vCabin.currencyCode);
        this.cabinPrice = filterNull(vCabin.cabinPrice);
        this.discount = getTwoFloat(vCabin.discount);
        this.commissionAmount = filterNull(vCabin.commissionAmount);
        this.commissionPercent = filterNull(vCabin.commissionPercent);
        this.discountStr = filterNull(vCabin.discountStr);
        this.cabinNumStr = filterNull(vCabin.cabinNumStr);

        this.isBusiness =  this.cabinType == "BUSINESS";
        this.isFirst =  this.cabinType == "FIRST";
    }

    function translateCabins(vCabins) {
        var cabins = new Array();
        for (var i = 0; i < vCabins.length; i++) {
            cabins[cabins.length] = new csOfCabin(vCabins[i]);
        }
        return cabins;
    }


}

function filterNull(str) {
    if (str == null || str == "null" || str == undefined) {
        return "";
    }
    return str ? str : "";
}

function csCodeAndName(o) {
    this.code = o.code;
    this.name = o.name;
}

