// Custom class
// Clase para mostrar las descripciones de los hoteles en el menu desplegable

var HotelDetails = new Class({

	options: {
		onShow: function(detail){
			detail.setStyle('visibility', 'visible');
		},
		onHide: function(detail){
			detail.setStyle('visibility', 'hidden');
		},
		maxTitleChars: 200,
		showDelay: 100,
		hideDelay: 100,
		className: 'tool'
	},

	initialize: function(elements, options){
		this.setOptions(options);
		this.toolDetail = $('hotelDetails');
		this.wrapper = new Element('div').inject(this.toolDetail);
		$$(elements).each(this.build, this);
		if (this.options.initialize) this.options.initialize.call(this);
	},

	build: function(el){
		el.$tmp.myTitle = (el.href && el.getTag() == 'a') ? el.href.replace('http://', '') : (el.rel || false);
		if (el.title){
			el.$tmp.myText = el.title;
			el.removeAttribute('title');
		} else {
			el.$tmp.myText = false;
		}
		if (el.$tmp.myText && el.$tmp.myText.length > this.options.maxTitleChars) el.$tmp.myText = el.$tmp.myText.substr(0, this.options.maxTitleChars - 1) + "&hellip;";
		el.addEvent('mouseenter', function(event){
		this.start(el);
		}.bind(this));
		var end = this.end.bind(this);
		el.addEvent('mouseleave', end);
		el.addEvent('trash', end);
	},

	start: function(el){
		this.wrapper.empty();
		if (el.$tmp.myText){
			this.text = new Element('span').inject(new Element('div', {'class': this.options.className + '-detailText'}).inject(this.wrapper)).setHTML(el.$tmp.myText);
		}
		$clear(this.timer);
		this.timer = this.show.delay(this.options.showDelay, this);
	},

	end: function(event){
		$clear(this.timer);
		this.timer = this.hide.delay(this.options.hideDelay, this);
	},

	show: function(){
		if (this.options.timeout) this.timer = this.hide.delay(this.options.timeout, this);
		this.fireEvent('onShow', [this.toolDetail]);
	},

	hide: function(){
		this.fireEvent('onHide', [this.toolDetail]);
	}

});

HotelDetails.implement(new Events, new Options);


// Custom class
// Clase para mostrar las descripciones de los hoteles en el menu desplegable

var ExcursionDetails = new Class({

	options: {
		onShow: function(detail){
			detail.setStyle('visibility', 'visible');
		},
		onHide: function(detail){
			detail.setStyle('visibility', 'hidden');
		},
		maxTitleChars: 200,
		showDelay: 100,
		hideDelay: 100,
		className: 'tool'
	},

	initialize: function(elements, options){
		this.setOptions(options);
		this.toolDetail = $('excursionesDetails');
		this.wrapper = new Element('div').inject(this.toolDetail);
		$$(elements).each(this.build, this);
		if (this.options.initialize) this.options.initialize.call(this);
	},

	build: function(el){
		el.$tmp.myTitle = (el.href && el.getTag() == 'a') ? el.href.replace('http://', '') : (el.rel || false);
		if (el.title){
			el.$tmp.myText = el.title;
			el.removeAttribute('title');
		} else {
			el.$tmp.myText = false;
		}
		if (el.$tmp.myText && el.$tmp.myText.length > this.options.maxTitleChars) el.$tmp.myText = el.$tmp.myText.substr(0, this.options.maxTitleChars - 1) + "&hellip;";
		el.addEvent('mouseenter', function(event){
		this.start(el);
		}.bind(this));
		var end = this.end.bind(this);
		el.addEvent('mouseleave', end);
		el.addEvent('trash', end);
	},

	start: function(el){
		this.wrapper.empty();
		if (el.$tmp.myText){
			this.text = new Element('span').inject(new Element('div', {'class': this.options.className + '-detailText'}).inject(this.wrapper)).setHTML(el.$tmp.myText);
		}
		$clear(this.timer);
		this.timer = this.show.delay(this.options.showDelay, this);
	},

	end: function(event){
		$clear(this.timer);
		this.timer = this.hide.delay(this.options.hideDelay, this);
	},

	show: function(){
		if (this.options.timeout) this.timer = this.hide.delay(this.options.timeout, this);
		this.fireEvent('onShow', [this.toolDetail]);
	},

	hide: function(){
		this.fireEvent('onHide', [this.toolDetail]);
	}

});

ExcursionDetails.implement(new Events, new Options);
