sectionNames = new Array('review', 'photo', 'booking', 'rank');
defaultView = 'booking';

/**
 * Obsluga dynamicznego pokazywania wybranych sekcji opisu hotelu
 */
function InfoHotel(sn, dv) {
	this._sectionNames = sn;
	this._viewSection = dv;
}

/**
 * pokazuje sekcje i podswietla pozycje menu
 */
InfoHotel.prototype.show = function(sectionName, menuObj) {
	this._viewSection = sectionName;
	this.showSection(sectionName);
	this.showMenu(menuObj);
}

/**
 * zwraca obiekt sekcji informacji o hotelu
 */
InfoHotel.prototype.getSection = function(name) {
	return document.getElementById('infohotel_' + name);
}

/**
 * pokazuje sekcje informacji
 */
InfoHotel.prototype.showSection = function(name) {
	this.hideSections();
	el = this.getSection(name);
	if (el) {
		el.style.display = 'block';
	}
}

/**
 * Ukrywa wszystkie sekcje opisu
 */
InfoHotel.prototype.hideSections = function() {
	for (var i = 0; i < this._sectionNames.length; i++) {
		el = this.getSection(this._sectionNames[i]);
		if (el) {
			el.style.display = 'none';
		}
	}
}

/**
 * podswietla wybrany element menu
 */
InfoHotel.prototype.showMenu = function(el) {
	this.hideMenu(el);
	el.className = "selected";
}

/**
 * gasi wszystkie elementy menu
 */
InfoHotel.prototype.hideMenu = function(el) {
	menu = el.parentNode.getElementsByTagName('a');
	if (menu) {
		for (var i = 0; i < menu.length; i++) {
			menu[i].className = "";
		}
	}
}

var infohotel = new InfoHotel(sectionNames, defaultView);
