var OrlandoFlexTicketPanel = Class.create(Panel, {
    initialize: function ($super, passportReference, tridionPanelId, panelPosition) {
		$super(passportReference, tridionPanelId);
		this.panelId = 'OrlandoFlexTicket';
		this.panelPosition = panelPosition;
		this.strParams = [];
		this.classPrefix = 'oft';
    },
    doWork: function () {
		this.calendarInput = this.panelHTML.select('[name=dateOfArrival]')[0];
		this.adultInput = this.panelHTML.select('[name=inputAdultQuantity]')[0];
		this.childInput = this.panelHTML.select('[name=inputChildQuantity]')[0];
		
		this.__setupCalendar(this.calendarInput);
		this.__setupInput(this.adultInput);
		this.__setupInput(this.childInput);

		this.oftData = this.__filterDataGroupByProperty(this.data, 'FlexType');

		var bt = this.panelHTML.select('.park2Table')[0];
	
		this.__generateRowsFor2Prices('dp1', 'productVariantCatalog', this.oftData, bt, this.adultInput, this.childInput);
		
		this.__setupAddToCart();
		this.__loadValues(['text/dateOfArrival', 'text/inputAdultQuantity', 'text/inputChildQuantity', 'radio/productVariantCatalog']);
    },
	_calculateTotalPrices: function() {
		this.__generateTotalPrice2Prices('dp1', this.oftData, this.adultInput, this.childInput);
	},
	_formatDataAndSend: function (data) {
		var ppqc = data.productVariantCatalog.split('|');
		var dataFormatted = {
			productID: ppqc[0] + "|" + ppqc[1],
			productVariantID: ppqc[2] + "|" + ppqc[3],
			qty: data.inputAdultQuantity + "|" + data.inputChildQuantity,
			catalogName: ppqc[4] + "|" + ppqc[5]
		};
		this.passportReference.addToCart(dataFormatted);
    },
    _validateInputData: function (data) {
		var adultQuantity = jsHelper.toInt(data.inputAdultQuantity);
		var childQuantity = jsHelper.toInt(data.inputChildQuantity);
		return (data.productVariantCatalog != undefined && (adultQuantity > 0 || childQuantity > 0));
    }
});
