if(typeof NICK == "undefined" || !NICK) var NICK = {};
NICK.namespace("games.utils");

/*--David Jordan 5/26/2009 */
$(document).ready(function() {
	//NICK.games.utils.initPersonalBest();
	NICK.games.utils.initCharacterCarouselTooltip();
});
NICK.games.utils.initCharacterCarouselTooltip = function(){
	$("#carousel-character-carousel .image").tooltip({
		id: "label-tooltip",
		contentTitle: true,
		followMouse: true,
		allowAccess: false,
		lockTo: "top",
		allowFlip: false,
		delay: 0
	});
}

/*Temporary removal of personal best
 * Will need to uncomment the initPersonalBest() above
 * Will need add, or uncomment add-attribute value="games.high-scores" from the games config 
 * game play page definition
 */
/*
NICK.games.utils.initPersonalBest = function(){
	$("#games-high-scores").hide();
	
	$(document).bind("authStatus", function(response){
		NICK.utils.doLog("----games Util Response:" + response.nickName);
		NICK.games.utils.initGamePlayPage();
	})
	$(document).bind("loggedIn", function(response){
		NICK.utils.doLog("---- -games Util Response:" + response.nickName);
		NICK.games.utils.initGamePlayPage();
	})	
	
}

NICK.games.utils.initGamePlayPage = function(){
	if(NICK.userData.loggedIn == "true"){
		NICK.games.utils.getPersonalBest();
	}
}
NICK.games.utils.getPersonalBest= function() {
	//var nick_url = NICK.utils.getNickDomain();
	var URL = "http://"+ "www.nick-d.mtvi.com" + "/common/score/json/getPersonalBest.jhtml";
	NICK.request.doRequest({
		dataType: "jsonp",
		url: URL,
		data: {
			user: NICK.userData.nickName.toLowerCase(),
			id: NICK.get("cmsId")
		},
		onSuccess: function(response){
			
			if (NICK.userData.nickName != "null") {
				$("#hs-user-name").html(NICK.userData.nickName);
				$("#times-played").html("[TIMES PLAYED]");
				var score = response.data[0].myScore[0].score
				score = score != "null" ? score : "";
				$("#my-score").html(score);
				var nickpoints = response.data[0].game[0].nickpoints
				nickpoints = nickpoints != "null" ? nickpoints : "";
				$("#nickpoints-earned").html(nickpoints);
				var rankIndex = response.data[0].rank[0].index
				rankIndex = rankIndex != "null" ? rankIndex : "";
				$("#current-rank").html(rankIndex);
				
				if(score != "" && score != "0"){
					$("#games-high-scores").show();
				}
			}
		},
		onFail: function(errors){
			for (var error in errors) {
				NICK.utils.doLog("Bad load: Error: " + error + " - " + errors[error]);
			}
		}
	});
}
*/
/* Ad loader support - This is the function we handed to the games team */
NICK.games.launchGame = function() {
	NICK.utils.doLog("Nick.games.launchGame");
}
