﻿// jquery.common.js by Derek Moseley, DerekM07@Gmail.com

// $_GET functionality
var $_GET = {};
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
	function decode(s) {
		return decodeURIComponent(s.split("+").join(" "));
	}
	$_GET[decode(arguments[1])] = decode(arguments[2]);
});

// Delayed execution of parent functions
var delay = (function() {
	var timers = {};
	return function(callback, ms, uniqueId) {
		if (timers[uniqueId]) {
			clearTimeout (timers[uniqueId]);
		}
		timers[uniqueId] = setTimeout(callback, ms);
	};
})();

var intervalDelay = (function() {
	var intervalTimers = {};
	return function(callback, ms, uniqueId) {
		if (intervalTimers[uniqueId]) {
			clearTimeout (intervalTimers[uniqueId]);
		}
		intervalTimers[uniqueId] = setInterval(callback, ms);
	};
})();

// Page rendering time
var start_time = +new Date();
$(document).ready(function() {
	$("footer p:first").append(" &middot; Page Created in " + ((+new Date() - start_time) / 1000) + "ms");
});

// Shop Aveda fixed tab
$(document).ready(function() {
	$("div#avedatab").css({ "top": "-46px" });
	var tabnote = $("<span />").appendTo("div#avedatab");
	$(tabnote).css ({
		"color": "#36454F",
		"font": "10px arial, sans-serif",
		"left": "0px",
		"position": "absolute",
		"text-align": "center",
		"text-transform": "uppercase",
		"top": parseInt($("div#avedatab").outerHeight()) + "px",
		"width": parseInt($("div#avedatab").innerWidth()) + "px"
	}).html("\u25BE Shop Aveda \u25BE");
	$("div#avedatab").mouseenter(function() {
		var tab = $(this);
		if ($(tab).css("top") == "-46px" ) {
			$(tabnote).hide();
			$(tab).animate({ "top": "0px" }, 500, "easeOutBounce", function() {
				delay(function() {
					$(tab).animate({ "top": "-46px" }, 500, "easeInBounce", function() {
						$(tabnote).show();
					});
				}, 3000, "avedatab" );
			});
		}
	});
});
