/*
	Worktank Clients Fancification
*/
$(document).ready(function()
{
	//Set up all of the client details and hide 'em
	$("ul.clientlist li div").each(function(i)
	{
		var top = ($(this).parent().offset().top) - 125;
		var left = $(this).parent().offset().left;

		var offset = ((parseInt(document.body.clientWidth))/2) - 495;
		var breakpoint = offset + 600;

		if (left > breakpoint) { 
			$(this).addClass("left");
			$(this).parent().children("a").children("img").addClass("left");
		}
		left += ((left > breakpoint) ? -336 : 166) -  $("ul.clientlist").offset().left;
		$(this).css({position:"absolute", "z-index": "500",top: top, left: left});
		$(this).hide();
	});

	//mouseover handler - display the details and swap the img
	$("ul.clientlist li a img").bind("mouseover", function(){ 
		$(this).parent().parent().children("div").queue(function()
		{
			$(this).fadeIn("fast");
			$(this).dequeue();
		});
		var url = $(this).attr("src").split("/");
		url[url.length-1] = url[url.length-1].replace(/_off/g, "_on");
		var newurl = url.join("/");
		$(this).attr({"src":newurl});
		$(this).parent().parent().css({"background":"#bccc5c"});
	});
	
	//mouseout handler - hide the details and swap the img
	$("ul.clientlist li a img").bind("mouseout", function(){
		$("ul.clientlist img").stop();
		$(this).parent().parent().children("div").queue(function()
		{
			$(this).hide();
			$(this).dequeue();
		});
		var url = $(this).attr("src").split("/");
		url[url.length-1] = url[url.length-1].replace(/_on/g, "_off");
		var newurl = url.join("/");
		$(this).attr({"src":newurl});
		$(this).parent().parent().css({"background":"#FFF"});
	});
});