/**
 * Controls the page interactivity for Arcade Games
 * 
 * @author Karl Stanton (Fi)
 * @version 1.0
 */


$('a.maximize', '#contentMain').click(function () {
	
	var contentDiv = $('#contentMain');
	
	if(contentDiv.hasClass('maximize')){
		// Minimize
		contentDiv.removeClass('maximize');
		embedFlash(config.flash_width_min, config.flash_height_min);
		$(this).removeClass('minimize').addClass('maximize').children('span').text('Maximize');
	} else {
		// Maximize
		contentDiv.addClass('maximize');
		embedFlash(config.flash_width_max, config.flash_height_max);
		$(this).removeClass('maximize').addClass('minimize').children('span').text('Minimize');
	}
	
	return false;

});


function embedFlash (swf, width, height) {

	var flashvars = {};
	var params = {
		allowFullScreen: "true",
		allowScriptAccess: "always"
	};
	var attributes = {
		id: "arcade_game"
	};
	
	// Embed the flash
	$('#arcade_game').after('<div id="arcade_game"></div>').remove();
	swfobject.embedSWF(swf, "arcade_game", width, height, "9", "", flashvars, params, attributes);

}


embedFlash(config.arcade_game, config.flash_width_max, config.flash_height_max);

function score_filter() {
	filter = document.getElementById('filter_text').value;
	window.frames.highscores_iframe.do_search(filter);
}

function filter_focus() {
	filter_box = document.getElementById('filter_text');
	if (filter_box.value == filter_box.defaultValue) filter_box.value = '';
}

function filter_reset() {
	filter_box = document.getElementById('filter_text');
	filter_box.value = filter_box.defaultValue;
}

function filter_blur() {
	filter_box = document.getElementById('filter_text');
	if (filter_box.value.length == 0) filter_reset();
}


