var sub_navigation_width = 0;

jQuery(document).ready(function() {
	var links = jQuery("#main_navigation > a");
	links.mouseover(function() {
		this.style.textTransform="uppercase";
		var colorSpot = jQuery("#"+this.id+"_spot");
		colorSpot.css({backgroundColor: "white"});
	});
	links.mouseout(function() {
		this.style.textTransform="";
		var colorSpot = jQuery("#"+this.id+"_spot");
		colorSpot.css({backgroundColor: ""});
	});
	
	var sub_navigation = jQuery("#sub_navigation");
	var container = jQuery("#container");
	sub_navigation_width = sub_navigation.width()+14;
	container.css({left: ''+sub_navigation_width+'px'});
});

jQuery(document).ready(function() {
	var image_tooltips = jQuery("a.small_image");
	image_tooltips.each(function() {
		var image = document.createElement("img");
		image.setAttribute("src", this.getAttribute("href"));
		image.setAttribute("class", "tooltip");
		new Tooltip(this, image);
		this.setAttribute("href", "#");
	});
});

var Tooltip = function(opener) {
	this.opener = jQuery(opener);
	this.content = jQuery(arguments[1] || this.opener.next());
	opener.tooltip = this;
	this.content.appendTo(document.getElementsByTagName('body')[0]);
	this.enable();
};

Tooltip.prototype.display = function() {
	this.content.show();
};

Tooltip.prototype.hide = function() {
	this.content.hide();
};

Tooltip.prototype.setPosition = function(x, y) {
	this.content.css("left", x+10);
	this.content.css("top", y+10);
};

Tooltip.prototype.enable = function() {
	this.opener.bind("mouseenter", this.handleMouseover);
	this.opener.bind("mouseleave", this.handleMouseout);
	this.opener.mousemove(this.handleMousemove);
	this.hide();
};

Tooltip.prototype.handleMouseover = function(event) {
	var tooltip = this.tooltip;
	tooltip.setPosition(event.pageX, event.pageY);
	tooltip.display();
};

Tooltip.prototype.handleMouseout = function(event) {
	var tooltip = this.tooltip;
	tooltip.hide();
};

Tooltip.prototype.handleMousemove = function(event) {
	var tooltip = this.tooltip;
	tooltip.setPosition(event.pageX, event.pageY);
};

