$(document).ready(function () {
	resizeContent();

	$(window).bind('resize', resizeContent);
	$(window).bind('load', resizeContent);
	$(document).bind('change', resizeContent);
});

function resizeContent() {

	//alert('resizeContent');
	windowh = Number($(window).height());
	windoww = Number($(window).width());
	
	//alert (windoww +' x ' + windowh);
	
	wb1 = (1200 * windowh) / 1048;
	wb1 = Math.round(wb1).toFixed(0);
	
	wb3 = (300 * windowh) / 1048;
	wb3 = Math.round(wb3).toFixed(0);
	
	wb2 = windoww - wb1 - wb3;	
	
	//alert (wb1 + ' ir ' + wb3);
	
	$('#block1').css('height', windowh + 'px');
	$('#block2').css('height', windowh + 'px');
	$('#block3').css('height', windowh + 'px');
	
	$('#block1').css('width', wb1 + 'px');
	$('#block2').css('width', wb2 + 'px');
	$('#block3').css('width', wb3 + 'px');
	
	//pasiskaiciuojam marginus
	
	marginT = Number((windowh * 88) / 1048);
	marginT = Math.round(marginT).toFixed(0);
	
	marginL = Number((wb1 * 42) / 1200);
	marginL = Math.round(marginL).toFixed(0);
	
	marginR = Number((wb3 * 257) / 300);
	marginR = Math.round(marginR).toFixed(0);
	
	marginB = Number((windowh * 19) / 1048);
	marginB = Math.round(marginB).toFixed(0);	
	
	var safew = Number(windoww - marginL - marginR);
	var safeh = Number(windowh - marginT - marginB);
	
	var positionL = Number(safew - 660);
	positionL = Number(positionL / 2);
	positionL = Math.round(positionL).toFixed(0);
	positionL = Number(positionL);
	
	var a = parseInt(positionL);
	var b = parseInt(marginL);
	var positionL = a + b;
	
	var positionT = Number(safeh - 500);
	positionT = Number(positionT / 2);
	positionT = Math.round(positionT).toFixed(0);
	positionT = Number(positionT);
	
	var c = parseInt(positionT);
	var d = parseInt(marginT);
	var positionT = c + d;	
	
	$('#canvas').css('left', positionL + 'px');
	$('#canvas').css('top', positionT + 'px');
	$('#canvas').css('display', 'block');
	
};
