var StayAndScreamPanel = Class.create(Panel, {
	initialize: function ($super, passportReference, tridionPanelId, panelPosition) {
		$super(passportReference, tridionPanelId);
		this.panelId = 'StayAndScream';
		this.panelPosition = panelPosition;
		this.strParams = [jsHelper.formatDate(new Date(), 'm/d/Y'), jsHelper.formatDate(jsHelper.fromString('month+4'), 'm/d/Y')];
		this.classPrefix = 'sas';
    },
    doWork: function () {	
		var adultChildInput = this.panelHTML.select('[name=inputAdultChildQuantity]')[0];
		
		this.__setupInput(adultChildInput);
		
		var dataCollection = this.data.Edj;
		var calendarEl = this.panelHTML.select('.calendarLayer')[0];
		var spanDateEl = this.panelHTML.select('[id=cwdDateSelected]')[0];
		var spanPriceEl = this.panelHTML.select('[id=cwdPrice2]')[0];
		var spanTotalPriceEl = this.panelHTML.select('[id=cwdTotalPrice]')[0];
		
		this.__setupStaticCalendarWithNoTicket(dataCollection, true, calendarEl, adultChildInput, spanDateEl, spanPriceEl, spanTotalPriceEl);
		
		var priceCollection = this.__getPriceCollection(dataCollection);
		
		var lowerPrice = this.panelHTML.select('[id=initPrice]')[0];
		var higherPrice = this.panelHTML.select('[id=finalPrice]')[0];
		
		if (lowerPrice != undefined) lowerPrice.update('$' + priceCollection[0].toFixed(2));
		if (higherPrice != undefined) higherPrice.update('$' + priceCollection[priceCollection.size() - 1].toFixed(2));
		
		this.__setupAddToCart();
		this.__loadValues(['text/inputAdultChildQuantity', 'calendar/calendar']);
	},
	_formatDataAndSend: function (data) {
		var dateSelected = jsHelper.formatDate(this.calendar.options.selectedDate, 'm/d/Y');
		var itemSelected = this.eventItemSelected;
		var dataFormatted = {
			eventID: itemSelected.Eid.trim(),
			plu: itemSelected.PLU.trim(),
			resourceID: itemSelected.Rid.trim(),
			qty: data.inputAdultChildQuantity,
			date: dateSelected,
			catalogName: data.hdnVirtualCatalog
		};
		this.passportReference.addEventToCart(dataFormatted);
    },
	_validateInputData: function (data) {
		var quantity = jsHelper.toInt(data.inputAdultChildQuantity);
		return (quantity > 0 && this.eventItemSelected != null);
    }
});
