/*
 * Generic Tour JS object.
 *
 * Use this to implement any tour-only javascript methods that would otherwise be
 * global functions.
 */
var Tour = new Class({

	initialize: function(options) {
	
		this.menupath = options.menu;
		this.episodepath = options.episode;
		this.ratingboxes = [];
	
		$(window.document.body).getElements('div.site_heading div.menu img').each(function(menu_image){
			menu_image.addEvent('mouseenter',this.hoverImage.pass([this.menupath,menu_image],this));
			menu_image.addEvent('mouseleave',this.unHoverImage.pass([this.menupath,menu_image],this));
		},this);
		
		$(window.document.body).getElements('div.episode div.entice img').each(function(entice_image){
			entice_image.addEvent('mouseenter',this.hoverImage.pass([this.episodepath,entice_image],this));
			entice_image.addEvent('mouseleave',this.unHoverImage.pass([this.episodepath,entice_image],this));
		},this);
		
	},
	
	getHoverLocation: function(rel) {
		return rel.split(':').pop();
	},
	
	hoverImage: function(path,image) {
		var gethover = this.getHoverLocation(image.getProperty('rel'));
		image.src = path+'over/'+gethover+'.gif';
	},
	
	unHoverImage: function(path,image) {
		var gethover = this.getHoverLocation(image.getProperty('rel'));
		image.src = path+'regular/'+gethover+'.gif';
	},
	
	addBookmark: function(title,url) {
		if (Client.Engine.ie6 || Client.Engine.ie7)
		{ // IE Favorite
			window.external.AddFavorite(url, title);
		}
		else if(Client.Engine.opera)
		{ // Opera Hotlist
			return true;
		}
		else
		{
			alert("Press CTRL + D to bookmark this page");
		}
	}

});

/* Mootools 1.2 compat */

// CORE
var Window = window;
var Document = document;
var $native = Native;
window.extend(Client.Engine);

// SELECTORS

function $E(selector, filter){
	return ($(filter) || document).getElement(selector);
};

function $ES(selector, filter){
	return ($(filter) || document).getElementsBySelector(selector);
};

function debug(thing)
{
	if (window.gecko)
		console.debug(thing);
}

