/*
Namespace: CLEAR

About: Version
	1.0

Description:
	A collection of functions to be used on the order complete page

Requires:
	jQuery 1.3 <http://jquery.com>
*/

// JS Lint Globals
/*global window, document, $, jQuery */

// Global Namespace
var CLEAR = window.CLEAR || {};

// Project Subnamespace
CLEAR.com = CLEAR.com || {};

// Project Subnamespace
CLEAR.com.OrderComplete = CLEAR.com.OrderComplete || {};

// When the DOM is ready.
(function () {
	
	// Storing a variable to reference
	var $space = CLEAR.com;
	var $self = this;
	
	// Shared variables
	$self.vars = $.extend($self.vars, {});
	
	// Shared utilities
	$self.utils = $.extend($self.utils, {});
	
	$self.applyToolTipCaps = function() {
		$(".state dl").append('<dd class="cap top"></dd><dd class="cap bottom"></dd>');
	};
	
	$self.mapHover = function () {
		$(".state").each(function() {
			var state = $(this),
			    dl = state.find("dl"),
			    /* just the */ tip = dl.wrap('<div class="tooltip"></div>').parent();
			
			function animate(opacity, callback) {
				tip.stop().animate({
					opacity : opacity
				}, {
					duration : 250,
					complete : callback
				});
			}
			
			state.hover(function() {
				tip.show();
				animate(1);
			}, function() {
				animate(0, function() {
					tip.hide();
				});
			});
			
			tip.css({
				opacity : 0
			}).hide();
		});
	};
	
	// Initialize
	$space.utils.init($self);
	
}).call(CLEAR.com.OrderComplete);