/**
 * Game scripts
 * !! If you are in here changing, move stuff into base.dg.js instead !!
 * !! NOTHING can be added to this file !!
 */
function closeAndGoto ( vTarget, noUnload ) {
	window.opener.location.href = vTarget;
	if (noUnload)
		this.onbeforeunload = null;
	window.close();
}

function navigate ( vUrl ) {
	this.onbeforeunload = null;
	document.location.href = vUrl;
}

function fullGame ( id, noDb ) {
	cUrl = '/'+language+'/gamesFullsize.php?id='+id+'&maintenance='+noDb;
	var gameWin = window.open(cUrl, 'fullSizeGame', 'resizable=yes,menubar=no,toolbar=no,statusbar=no');
	gameWin.focus();
}

function goTo () {
	if (confirm(message)) {
		document.location.href = '/'+language+'/album.php';
	}
}

function addEvent_confBeforeUnload ( oBody ) {
	this.onbeforeunload = confBeforeUnload;
}

function confBeforeUnload () {
	return "\n"+message;
}

// Comments
function getComments(id, page) {
	ajaxEngine.sendRequest('gameComments', 'id='+id, 'page='+page);
}

var commentArea;
var gameName;
function addComment(id, name) {
	if (!commentArea) {
		commentArea = document.getElementById("gameCommentArea");
	}
	if (!gameName) {
		gameName = document.getElementById("gameName");
	}

	var comment = commentArea.value;
	if (comment.length > 0) {
		ajaxEngine.sendRequest('gameComments', 'action=add', 'id='+id, 'comment='+comment, 'gameName='+name);
	}
	commentArea.value='';
}

function deleteComment(game, id) {
	ajaxEngine.sendRequest('gameComments', 'action=delete', 'id='+game, 'cid='+id);
}


ajaxEngine.registerRequest('gameComments', '/'+language+'/ajax/gameComments.php');