/************************************************************************
 * 		Tour Status Zeilen im Planner									*
 * 		C 2008 by René Lange & Thomas Müller & Steve Rohrlack @ mindbox	*
 ************************************************************************/

var TourInfo = AbstractTabContent.extend({	
	maxDays : 7,
	
	// Konstruktor
	initialize : function() {
		this.container = new Element('div',{'class':'tour', 'id': 'tourInfo'});
	},
	
	// Inhalt erstellen
	build : function(mainDiv) {
		this.container = new Element('div',{'class':'tour'});

		if (mainDiv != null) {
			this.container = mainDiv; // Für Rebuild den Day Entrys Div mitgeben
		}
		
		this.tourNameContainer();
		
		this.tourLengthContainer();
		
		this.updateLengthButton();
		
		this.saveButton();
		
		tmpEl = new Clearer();
		this.container.adopt(tmpEl);
		
		return this.container;
	},
	
	
	// erstellen der Nodes für die Eingabe der Bezeichnung einer Tour
	tourNameContainer: function(){
		// label tour-name
		var tmpEl = new Element('label',{'for':'tourName'}).set('text','Tour name:');
		this.container.adopt(tmpEl);
		
		// eingabefeld tour-name
		tmpEl = new Element('input',{'id':'tourName','type':'text','name':'tourName'});
		this.container.adopt(tmpEl);
	},
	
	
	// erstellen der Nodes für die Auswahl der Anzahl der Tage einer Tour
	tourLengthContainer: function(){
		// label für tourLength
		var tmpEl = new Element('label', {'for':'tourLenght'}).set('text','Tour length:');
		this.container.adopt(tmpEl);
		
		// dropdown zur auswahl der länge eines tours
		var dcDaysLength = TourPlanner.instance.currentTour.dcDays.length;
		tmpEl = new Element('select', {'id':'tourLength','name':'tourLength'});
		for(var i = 1; i <= this.maxDays; i++){
			var opt = new Element('option', {'value': i}).set('text',i + ' days');
			if(i == dcDaysLength){
				opt.setProperty('selected','selected');
			}
			tmpEl.adopt(opt);
		}

		this.container.adopt(tmpEl);
	},
	
	
	// Button zum Aktualisieren der Liste für die Tagesplanung
	updateLengthButton: function(){
		var tmpEl = new Element('input',{'id':'tpChangeDays','type':'submit','value':'Update tour length','class':'sub'});
		this.container.adopt(tmpEl);
	},
	
	
	// erstellen eines Buttons zum Speichern der aktuellen Tour
	saveButton: function(){
		// save-button
		if (TourPlanner.instance.userStatus == 'true') {
			
			tmpEl = new Element('input', {
				'id': 'saveTour',
				'class': 'sub',
				'type': 'submit',
				'value': 'Save current tour'
			});
			this.container.adopt(new Element('div', {
				'class': 'separator'
			}));
			this.container.adopt(tmpEl);
		}
	}
	
});