if(typeof NICK == "undefined" || !NICK) var NICK = {};

NICK.namespace = function() {
    var a = arguments, o = null, i, j, d;
    for (i = 0; i < a.length; i++) {
        d = a[i].split(".");
        o = NICK;

        // NICK is implied, so it is ignored if it is included
        for (j = (d[0] == "NICK") ? 1 : 0; j < d.length; j++) {
            o[d[j]]=o[d[j]] || {};
            o=o[d[j]];
        }
    }
    return o;
};

NICK.namespace("video");

$(document).ready(function() {
	NICK.video.initVideoPlayIcon();
	
	$("#submenu td a").each(function() {
		$(this).attr("title", $(this).attr("title").replace(/ episodes/g, '') );	
	});
});

NICK.video.initVideoPlayIcon = function() {
	$(".with-nick-tooltip")
		.unbind("mouseenter", NICK.video.addVideoPlayIcon)
		.unbind("mouseleave", NICK.video.removeVideoPlayIcon)
		.bind("mouseenter", NICK.video.addVideoPlayIcon)
		.bind("mouseleave", NICK.video.removeVideoPlayIcon);
}

NICK.video.addVideoPlayIcon = function(j) {
	var icon = $("<div />").attr("id", "video-overlay-icon").appendTo($(this).children("a:first"));
	if ( $(this).parent().parent().parent().hasClass("thumbnail-touts") ) {
		icon.addClass("large-icon");
	}
	var img = $(this).find("img");
	icon.css({
		top: Math.round(img.height() / 2) - Math.round(icon.height() / 2) + "px",
		left: Math.round($(this).width() / 2) - Math.round(icon.width() / 2) + "px"
	});
};

NICK.video.removeVideoPlayIcon = function() { $("#video-overlay-icon").remove(); }