dojo.provide("epages.cartridges.de_epages.calendar.widget.Appointment");
dojo.require("epages.widget.LocalizedWidget");
dojo.require("dojo.date.stamp");

dojo.declare(
	"epages.cartridges.de_epages.calendar.widget.Appointment",
	[epages.widget.LocalizedWidget],
	{
		/**
		 * public properties
		 */

		Alias:          '',
		AddressInfo:    '',
		ContactInfo:    '',
		ProductInfo:    '',
		StartDate:      '',
		EndDate:        '',
		StartDate_Time: '',
		EndDate_Time:   '',
		objectId:       '', // AppointmentId
		productId:      '',
		_StartDateTime: '',
		_EndDateTime: 	'',
		url:            '?',
		/**
		 * dojo widget properties
		 */
		translationName : dojo.moduleUrl('epages.cartridges.de_epages.calendar.widget','templates/translation'),
		templatePath:     dojo.moduleUrl('epages.cartridges.de_epages.calendar.widget',"templates/AppointmentElementSmall.html"),

		postMixInProperties: function () {
			this.inherited('postMixInProperties',arguments);
			// select template
			if (this.AddressInfo == '') {
				this.AddressInfo = this.translate('EMPTY_ADDRESS');
			}
			var pad = dojo.string.pad;
			var start = dojo.date.stamp.fromISOString(this.StartDate);
			this._StartDateTime = pad(start.getHours(),2) + ':' + pad(start.getMinutes(),2);
			var end = dojo.date.stamp.fromISOString(this.EndDate);
			this._EndDateTime = pad(end.getHours(),2) + ':' + pad(end.getMinutes(),2);
		},

		postCreate: function(){
			this.inherited('postCreate',arguments);
			if(this.AddressInfo){
				if(this.AddressInfo.CancelledOn){
					dojo.addClass(this.domNode,'Cancelled');
				}
				if(this.AddressInfo.AcceptedOn){
					dojo.addClass(this.domNode,'Accepted');
				}
			}
		}
	}
);