var sizes, img;
var isFrame, onlyFrame = false;










function showGame() {
	var splash = jQuery('#wstaw-gre');
	var embed = jQuery('#kod-gry embed').css('visible', 'none');
	var frame = jQuery('#kod-gry iframe').css('visible', 'none');

	jQuery('#game-slider').hide();

	if ( typeof( embed.attr('height') ) == 'undefined' ) {
		embed = frame.find('embed');
		if ( typeof( embed.attr('height') ) == 'undefined' ) {
			onlyFrame = true;
		}
		isFrame = true;
	}

	sizes = { embed: {}, frame: { } };

	if ( onlyFrame == false ) {
		sizes['embed']['width'] = embed.attr('width');
		sizes['embed']['height'] = embed.attr('height');
	}
	if ( isFrame == true ) {
		sizes['frame']['width'] = frame.attr('width');
		sizes['frame']['height'] = frame.attr('height');
	}

	if ( onlyFrame == false ) {
		splash.css({'width': sizes['embed']['width']+'px', 'height': sizes['embed']['height']+'px'}).show();
		embed.attr({width: 1, height: 1});
	}
	if ( isFrame == true ) {
		frame.attr({width: '1px', height: '1px'});
	}

	setTimeout(function(){
		if ( isFrame == true ) {
			frame.css({width: sizes['frame']['width']+'px', height: sizes['frame']['height']+'px'});
		} else {
			jQuery('#game-slider').fadeIn();
		}

		if ( onlyFrame == false ) {
			embed.attr({width: sizes['embed']['width'], height: sizes['embed']['height']});
		}

		splash.remove();
	}, 10000);
}

function refreshSize() {
	var ratio = jQuery("#slider").slider("value");
	var embed = jQuery('#kod-gry embed');
	var originalHeight = embed.attr("heightO");
	var originalWidth = embed.attr("widthO");
	var height = sizes['embed']['height'];
	var width = sizes['embed']['width'];

	if ( originalHeight == null ) {
		embed.attr("heightO", height);
		embed.attr("widthO", width);

		originalHeight = height;
		originalWidth = width;
	}

	width = Math.round(originalWidth * ratio);
	height = Math.round(originalHeight * ratio);

	if ( jQuery('#kod-gry object') ) {
		jQuery('#kod-gry object').attr("height", height);
		jQuery('#kod-gry object').attr("width", width);
	}
	embed.attr("height", height);
	embed.attr("width", width);
}


