if(typeof NICK == "undefined" || !NICK) var NICK = {};

NICK.namespace("video");

$(document).ready(function() {
	/* Disabled this functionality for the static icon*/
	/*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) {
	if (0 == $(this).children("a:first").length) {
		var parent = $(this).find("div a:first");
		var cointainer = parent;
	} else {
		var parent = $(this).children("a:first");
		var cointainer = $(this);
	}

	var icon = $("<div />").attr("id", "video-overlay-icon").appendTo(parent);
	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($(cointainer).width() / 2) - Math.round(icon.width() / 2) + "px"
	});
};

NICK.video.removeVideoPlayIcon = function() { $("#video-overlay-icon").remove(); }

NICK.video.goPlaylistVideo = function(index) {
	var playlistUrl = document.location.href;
	var params = document.location.search;

	playlistUrl = playlistUrl.replace("\/playlist\/", "/playlist/play/");
	playlistUrl += ((params != null && params.indexOf("?") >= 0) ? "&" : "?") + "&listId="+index+"&carouselId="+index; 

	document.location.href = playlistUrl;
	return false;
}
