//THIS ARRAY MUST BE SORTED IN ASCENDING ORDER
var zoomLevels = [0.5, 0.75, 1.0, 1.25, 1.5];
var zoomLevel = [];

function resizeStatic(id, sourceWidth, sourceHeight, multiplier) {
	jQuery.each(id, function() {
		$('#'+this).css({width: sourceWidth * multiplier, height: sourceHeight * multiplier});
	});
}

function initZoom(id) {
	if(zoomLevel[id] == null) {
                zoomLevel[id] = jQuery.inArray(1.0, zoomLevels);
        }
}

function sizeUp(sourceWidth, sourceHeight) {
	var id = ['objectembed', 'flashembed'];
	initZoom(id);
	if(zoomLevel[id] < zoomLevels.length - 1) {
		zoomLevel[id] += +1;
		resizeStatic(id, sourceWidth, sourceHeight, zoomLevels[zoomLevel[id]]);
	}
}

function sizeDown(sourceWidth, sourceHeight) {
	var id = ['objectembed', 'flashembed'];
	initZoom(id);
	if(zoomLevel[id] > 0) {
		zoomLevel[id] -= 1;
		resizeStatic(id, sourceWidth, sourceHeight, zoomLevels[zoomLevel[id]]);
	}
}

var lights = true;
function toggleLights() {
	if(lights) {
		$('#mask').css({ 'width': $(window).width(), 'height': $(document).height()}); $('#mask').fadeIn(1000);
	} else {
		$('#mask').fadeOut(1000);
	}
	lights = !lights;
}

function addFavourite(gameTitle) {
	var url = 'http://www.maxgames.com/play/'+gameTitle.toLowerCase().replace(/ /g, '-')+'.html';
	var pageTitle = 'Play '+gameTitle+' : Max Games';
	
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(pageTitle, url, '');
	} 
	else if(window.external) { // IE Favorite
		window.external.AddFavorite(url, pageTitle);
	}
	else if(window.opera && window.print) { // Opera Hotlist
		return true;
	}
}