Ext.namespace('SABS.Config');

// little helper fn
SABS.Config.swapKeyValue = function(obj){
    var i, nobj={};
    for(i in obj){
        //if(obj[i] instanceof Array);
        var strVal = obj[i].toString();
        if(nobj[strVal]){
            if(!( nobj[strVal] instanceof Array )){
                nobj[strVal] = [ nobj[strVal] ];
            }
            nobj[strVal].push(i);
        }
        else{
            nobj[strVal] = i;
        }
    }
    return nobj;
};

/**
*   This only sets checked/disabled features of search types checkboxex
*   and therefore what searches will be run
*/
SABS.Config.activeProducts = {
    'grid'              : true, // essentially holidays
    'expandgrid'        : true, // essentially holidays
    'holiday'           : true,
    'accommodation'     : true, // this is Apartments!
    'hotel'             : true,
    'flight'            : true,
    'flight_charter'    : true,
    //'flight_scheduled'  : true,
    'flight_budget'     : true,
    'transfer'          : true,
    'transfer_taxi'     : true,
    'transfer_limousine': true,
    'carhire'           : true,
    'holidaypark'       : true,
    'cottage'           : true,
    'boat'              : true
    //'attractionticket'  : true
    //'villa'             : true
};

/**
*   This governs what panels and forms are accessible by user
*   'allproduct' is a special type that has dummy panel and a form
*   able to do searches for multiple products. These products are switched on/off
*   in SABS.Config.activeProducts configuration object
*/
SABS.Config.SearchProfileLists = {
    'international_trips' : [
        'allproduct',
        'holiday',
        'accommodation',
        'flight',
        'transfer',
        'carhire'
     ],
    'uk_breaks' : [
        'allproduct',
        'holidaypark',
        'cottage',
        'boat'
    ]//,
    //'worldwide_hotels' : [
        //'allproduct',
        //'hotel',
        //'flight',
        //'transfer',
        //'carhire'
    //]
};

SABS.Config.SearchProfileNames = {
    'international_trips'   : 'International trips',
    'uk_breaks'             : 'UK Breaks',
    'worldwide_hotels'      : 'Worldwide hotels'
};
/**
*   Complementary products are those that are displayed in the cross selling bar
*/
SABS.Config.complementaryProducts = {
    'holiday': ['carhire', 'transfer'],
    'accommodation': ['flight', 'transfer', 'carhire'],
    'hotel': ['flight', 'transfer', 'carhire'],
    'flight': ['accommodation', 'hotel', 'transfer', 'carhire'],
    'transfer': ['accommodation', 'hotel', 'flight', 'carhire'],
    'carhire': ['accommodation', 'hotel', 'flight', 'transfer']
    // add holidaypark, cottage, boat
};

SABS.Config.productNames = {
    'holiday': { sing: 'package holiday', pl: 'package holidays' },
    'accommodation': { sing: 'accommodation', pl: 'accommodation' },
    'hotel': { sing: 'hotel', pl: 'hotels' },
    'flight': { sing: 'flight', pl: 'flights' },
    'transfer': { sing: 'taxi transfer', pl: 'taxi transfers' },
    'carhire': { sing: 'car hire', pl: 'car hire' },
    'attractionticket': { sing: 'attraction ticket', pl: 'attraction tickets' },
    'holidaypark': { sing: 'holiday park', pl: 'holiday parks' },
    'cottage': { sing: 'cottage', pl: 'cottages' },
    'boat': { sing: 'boat', pl: 'boats' }
};

SABS.Config.cheapestSearchableProducts = {
    'holiday': true,
    'accommodation': true,
    'flight': true
};

SABS.Config.apiProductCodeToProduct = {
    'HOL': 'holiday',
    'ACC': ['accommodation', 'hotel', 'holidaypark', 'cottage', 'boat', 'villa'],
    'FLT': 'flight',
    'JNY': 'flight',
    'TRS': ['carhire', 'transfer']
};

SABS.Config.productToApiType = {
    'expandgrid'        :   'EGD',
    'grid'              :   'CGO',
    'holiday'           :   'CHO',
    'accommodation'     :   'CAO', 
    'hotel'             :   'CAO', 
    'flight'            :   'CFM',
    'flight_charter'    :   'CFC',
    'flight_budget'     :   'CFL',
    'transfer'          :   'CTX',
    'transfer_taxi'     :   'CTX',
    'transfer_limousine':   'CTX',
    'carhire'           :   'CCH',
    'holidaypark'       :   'CAO',
    'boat'              :   'CBO',
    'villa'             :   'CVO',
    'cottage'           :   'CVO'
};

SABS.Config.ApiTypeToProduct = {
   'EGD': 'expandgrid',
   'CGO': 'grid',
   'CHO': 'holiday',
   'CAO': ['accommodation', 'hotel', 'holidaypark'],
   'CVO': ['cottage', 'villa'],
   'CBO': 'boat',
   'CFM': 'flight',
   'CFC': 'flight_charter',
   'CFL': 'flight_budget',
   'CTX': 'transfer',
   'CCH': 'carhire'
};

SABS.Config.productToPanel = {
    'expandgrid'     : 'holiday',
    'grid'           : 'grid', //not real panel
    'holiday'           : 'holiday',
    'accommodation'     : 'accommodation',
    'villa'             : 'accommodation',
    'hotel'             : 'hotel',
    'flight'            : 'flight',
    'flight_charter'    : 'flight',
    'flight_budget'     : 'flight',
    'transfer'          : 'transfer',
    'transfer_taxi'     : 'transfer',
    'transfer_limousine'    : 'transfer',
    'carhire'               : 'carhire',
    'holidaypark'           : 'holidaypark',
    'cottage'               : 'cottage',
    'boat'                  : 'boat'
};

SABS.Config.ApiTypeToJsonResponseType = {
    'EGD' : 'expandgrid',
    'CGO' : 'grid',
    'CHO' : 'package',
    'CAO' : 'accom',
    'CBO' : 'boat',
    'CVO' : 'villa',
    'CFM' : 'flight',
    'CFC' : 'flightc',
    'CFL' : 'flightb',
    'CTX' : 'taxi',
    'CCH' : 'car'
};

SABS.Config.JsonResponseTypeToApiType = SABS.Config.swapKeyValue(
    SABS.Config.ApiTypeToJsonResponseType);

SABS.Config.JsonResponseTypeToType = {
    'expandgrid'    : 'expandgrid',
    'grid'    : 'grid',
    'package' : 'holiday',
    'accom'   : ['accommodation', 'hotel', 'holidaypark'], 
    'villa'   : ['villa', 'cottage'],
    'flight'  : 'flight',
    'flightb' : 'flight',
    'flightc' : 'flight',
    'taxi'    : 'transfer',
    'car'     : 'carhire',
    'boat'    : 'boat'
};

SABS.Config.AccommodationOperatorsToAccommodationSubTypes = {
    'MCR' : 'hotel',
    'HSN' : ['cottage', 'villa'],
    'HSB' : 'boat'
};

SABS.Config.BoardBasisCodes = {
    'BB'    :       'Bed and Breakfast',
    'SC'    :       'Self Catering',
    'HB'    :       'Half Board',
    'FB'    :       'Full Board',
    'AI'    :       'All Inclusive'
};

SABS.Config.BoardBasisNameToCode = SABS.Config.swapKeyValue(SABS.Config.BoardBasisCodes);


// if not in here, it should be assumed, the place is in the UK
SABS.Config.AirportToCountry = {
    'DUB': 'IRL',
    'ORK': 'IRL',
    'SNN': 'IRL',
    'NOC': 'IRL'
};

// if not in here, assume its sterling
SABS.Config.CountryToCurrency = {
    'IRL': 'EUR',
    'GB' : 'GBP'
};

SABS.Config.CurrencyToUnicode = {
    'EUR' : '\u20AC',
    'GBP' : '\u00a3'
};

SABS.Config.OperatorToMandatoryBookingForm = {
    'RHP': [ 'FlightNumberForm' ],
    'HTX': [ 'AccommodationNameForm' ]
};
SABS.Config.SupplierCodeToName = {
    'WSP' : 'Worldspan'
};

/*
BrochuresForProducts - which products have brochures
*/
SABS.Config.BrochuresForProducts = {
    'holiday'           : true,
    'accommodation'     : true, // this is Apartments!
    'hotel'             : true,
    'flight'            : false,
    'flight_charter'    : false,
  //  'flight_scheduled'  : false,
    'flight_budget'     : false,
    'transfer'          : false,
    'transfer_taxi'     : false,
    'transfer_limousine': false,
    'carhire'           : false,
    'holidaypark'       : true,
    'cottage'           : true,
    'boat'              : true
  //  'attractionticket'  : true,
  //  'villa'             : true
};
SABS.Config.DetailPaneOperatorLogo = {
    'ADF' : 'http://images.sabsagent.com/images/TourOp/large/ADF.gif',
    'GDN' : 'http://images.sabsagent.com/images/TourOp/large/GDN.gif',
    'GDP' : 'http://images.sabsagent.com/images/TourOp/large/GDP.gif',
    'JTA' : 'http://images.sabsagent.com/images/TourOp/large/JTA.gif'
};
SABS.Config.HomePageEditors = [
    'jacek', 'sarahw', 'chrisl', 'jeremyredsky', 'lauren_test', 'gary_test'
];
