var Bookmark = {
	'messageBox': null, 
	'profileID': 0,
	'isInitialized': false,

	'init': function(profileID) {
		if (!Bookmark.isInitialized) {
			Bookmark.messageBox = new MessageBox('GratisSpil', -80, -100, 300);
			Bookmark.messageBox.setSolidBackground();
			Bookmark.profileID = profileID;
			
			Bookmark.isInitialized = true;
		}
	}, 

	'save': function(parentDivID, gameID) {
		Bookmark.messageBox.move(parentDivID);

		if (Bookmark.profileID > 0) {
			// Ajax is included from level1.php as prototype.x.x.x.js
			new Ajax.Request(Common.HTML_ROOT + '/onlineGame/bookmark.php',
			{
				method: 'post', 
				parameters: {'id': gameID, 'profileID': Bookmark.profileID}, 
				onSuccess: function(transport) {
					var json = transport.responseText.evalJSON();

					if (json.bookmarked) {
						Bookmark.messageBox.setTitle('Spillet er gemt');
						Bookmark.messageBox.setContent("Spillet er gemt under '<a href='" + Common.HTML_ROOT + "/onlineGame/myGamesRedirect.php' style='color: #157cb1;'>Mine Spil</a>'.");
						Bookmark.messageBox.display();
					}
					else {
						Bookmark.messageBox.setTitle('Spillet er i forvejen gemt');
						Bookmark.messageBox.setContent("Spillet er derfor flyttet, så det står først under '<a href='" + Common.HTML_ROOT + "/onlineGame/myGamesRedirect.php' style='color: #157cb1;'>Mine Spil</a>'.");
						Bookmark.messageBox.display();
					}
					
					// Function is placed in /include/js/onlineGame.js
					displayMyGamesBasket();
				},
				onFailure: function() {
					Bookmark.messageBox.setTitle('Spillet kan ikke gemmes');
					Bookmark.messageBox.setContent("Spillet kan desværre ikke gemmes. <br /><br />Venligst fortæl <a href='" + Common.HTML_ROOT + "/about/contact.php'>webmasteren</a> om problemet.");
					Bookmark.messageBox.display();
				}
			});
		} else {
			Bookmark.messageBox.setTitle('Husk at logge ind');
			Bookmark.messageBox.setContent("Du kan først gemme spillet i 'Mine Spil', når du er logget ind.");
			Bookmark.messageBox.display();
		}
	}
}

