// JavaScript Document
// Adds the ulu images to the page then switches them on hover
// Last edited: 08/17/2010
// Dev: Chris Peterson

$(document).ready(function() {
	loadImages();
	uluSwitch();					   
});

function loadImages() {
	$(".ulu-container.left span").html('<img src="images/left_ulu.png" />');
	$(".ulu-container.right span").html('<img src="images/right_ulu.png" />');
}

function uluSwitch() {
	
	$(".ulu-container").bind({
		mouseenter: function() {
			var cur_img = getCorrectImage($(this), false);
			var hover_img = getCorrectImage($(this), true);
			
			$(this).children("span").children("img").attr("src",hover_img);
		},
		mouseleave: function() {
			var cur_img = getCorrectImage($(this), false);
			var hover_img = getCorrectImage($(this), true);
			
			$(this).children("span").children("img").attr("src",cur_img);
		}
	});
};

function getCorrectImage(container, getHover) {
	var img_path = "images/";
	
	if(container.hasClass("left") && getHover == false)
		return img_path + "left_ulu.png";
	else if(container.hasClass("left") && getHover == true)
		return img_path + "left_ulu_hover.png";
	else if(container.hasClass("right") && getHover == false)
		return img_path + "right_ulu.png";
	else
		return img_path + "right_ulu_hover.png";
}
