/* script.js */

// Browsers don't seem to define the console by default.
function _dp_debug(s) {
	try {
		console.debug(s);
	} catch(e) {}
}

var _dp_active_section	= "artists";
var _dp_sections		= ["where"];
var _dp_active_link		= null;

/**
 * Anchor-based locations; general idea from:
 * http://blog.rebeccamurphey.com/2007/12/04/anchor-based-url-navigation-with-jquery/
 */
(function() {
 	var loc = document.location.toString().replace(/^.*#(.*)$/, "$1");
	if ((loc.length > 0) && ($.inArray(loc, _dp_sections) > -1)) {
		_dp_active_section = loc;
	}
})();


$(document).ready(function() {
	var smi_base_url	= "http://etc.deanpence.com/social-media-icons/";

	$("#body > ul > li > a")
		.each(function() {
			var _this	= $(this);

			_this
				.after(
					$(document.createElement("a"))
						.attr("href",	_this.attr("href"))
						.attr("title",	_this.attr("title"))
						.addClass("image")
						.append(
							$(document.createElement("img"))
								.attr(
									"src",
									"http://etc.deanpence.com/social-media-icons/"
										+ _this.attr("id").replace(/-link$/, "").toLowerCase() + "_32.png"
								)
								.css("width", "16px")
								.css("height", "16px")
						) /* .after() */
						.css("top",		"10px")
						.css("right",	"16px")
						.data("hoveron", function(t) {
							$(t).animate({ top: "2px", right: "8px" }, 250);
							$(t).children("img:first").animate({ width: "32px", height: "32px"}, 250);
						})
						.data("hoverout", function(t) {
							$(t).animate({ top: "10px", right: "16px" }, 250);
							$(t).children("img:first").animate({ width: "16px", height: "16px" }, 250);
						})
				) /* .after() */
				.data("hoveron", function(t) {
					$(t).addClass("hover");
				})
				.data("hoverout", function(t) {
					$(t).removeClass("hover");
				})
		})

	$("#body > ul > li")
		.each(function() {
			$(this)
				.mouseenter(function(event) {
					$(this).children("a").each(function() {
						$(this).data("hoveron")(this);
					});
				})
				.mouseleave(function(event) {
					$(this).children("a").each(function() {
						$(this).data("hoverout")(this);
					});
				});
		});
});
