
function checkDivSize()
{
	//-- page top (logo, comboboxes)
	var topPage = $('#main_block_top').height();

	//-- page top shadow (+ menu link)
	var topShadow = $('#main_block_top_shadow').height();

	//-- page bottom
	var bottomHeight = parseInt($('#main_block_bottom').height());

	//-- the whole page height (client's height)
	var H = document.body.clientHeight;
	//-- the whole page width (client's width)
	var W = document.body.clientWidth;

	//-- delimiter size (as a part of the client's WIDTH
	// for instance, width = 1280, x20 = 1280 / 64 = 20px)
	var x20 = parseInt(W / 64);

	//alert(x20);

	var delimitersHeight = x20 * 3;
	var delimitersWidth = x20 * 6;

	var newsCaption = 32; //$('.news_caption').css('height');

	//-- the whole height of the Gummy Part
	var gummyHeight = H - (topPage + topShadow + bottomHeight + delimitersHeight + newsCaption);
	var gummyWidth = W - delimitersWidth;
	//-- height of the block 1/5 (20%):
	// 4/5 = Welcome
	// 1/5 = News

	//-- DELIMITERS ROWS & COLUMNS
	$('.h20').height(x20);
	$('.h40').height(x20 * 2);
	$('.w20').width(x20);
	$('.w40').width(x20 * 2);
	

	var percent20 = parseInt(gummyHeight / 5);
	var percent33 = parseInt(gummyWidth / 3);


	var wWelcome = gummyWidth - 2 * percent33;
	var wTillyAbout = percent33;
	var wAutomatContact = percent33;

	
	var hAutomatContact = $('#main_block_contact_hidden').height();
	var hNews = percent20;
	var hWelcome = gummyHeight - hNews;
	var hTillyAbout = hWelcome - 2 * x20 - hAutomatContact;


	//-- topPage + topShadow
	var H1 = topPage + topShadow;

	$('#delim_h1').height(x20).css('top', H1);
	
	//-- topPage + topShadow + x20
	var H2 = H1 + x20;
	
	var L1 = x20;
	var L2 = x20 + wWelcome + 2 * x20;
	var L3 = x20 + wWelcome + 2 * x20 + wTillyAbout + 2 * x20;

	$('#main_block_tilly')
		.css('left', L2)
		.css('top', H2)
		.height(hTillyAbout)
		.width(wTillyAbout)
	;
	$('#main_block_about')
		.css('left', L3)
		.css('top', H2)
		.height(hTillyAbout)
		.width(wTillyAbout)
	;

	//-- topPage + topShadow + x20 + hTillyAbout + 2 * x20
	var H3 = H2 + hTillyAbout + x20;

	$('#main_block_automat')
		.css('left', L2)
		.css('top', H3)
		.height(hAutomatContact)
		.width(wAutomatContact)
	;
	$('#main_block_contact')
		.css('left', L3)
		.css('top', H3)
		.height(hAutomatContact)
		.width(wAutomatContact)
	;

	$('#main_block_welcome')
		.css('left', L1)
		.css('top', H2)
		.height(hWelcome)
		.width(wWelcome)
	;
	
	//-- topPage + topShadow + x20 + hTillyAbout + 2 * x20 + hAutomatContact
	var H4 = H3 + hAutomatContact;
	
	$('#delim_h2').height(2 * x20).css('top', H4);

	//-- topPage + topShadow + x20 + hTillyAbout + 2 * x20 + hAutomatContact
	//-- + 2 * x20
	var H5 = H4 + 2 * x20;

	$('#main_block_news1_title')
		.css('left', L1)
		.css('top', H5)
		.height(newsCaption)
		.width(wWelcome)
	;
	$('#main_block_news2_title')
		.css('left', L2)
		.css('top', H5)
		.height(newsCaption)
		.width(wAutomatContact)
	;
	$('#main_block_news3_title')
		.css('left', L3)
		.css('top', H5)
		.height(newsCaption)
		.width(wAutomatContact)
	;

	//-- topPage + topShadow + x20 + hTillyAbout + 2 * x20 + hAutomatContact
	//-- + 2 * x20 + newsCaption
	var H6 = H5 + newsCaption;

	$('#main_block_news1')
		.css('left', L1)
		.css('top', H6)
		.height(hNews)
		.width(wWelcome)
	;
	$('#main_block_news2')
		.css('left', L2)
		.css('top', H6)
		.height(hNews)
		.width(wAutomatContact)
	;
	$('#main_block_news3')
		.css('left', L3)
		.css('top', H6)
		.height(hNews)
		.width(wAutomatContact)
	;

	//-- topPage + topShadow + x20 + hTillyAbout + 2 * x20 + hAutomatContact
	//-- + 2 * x20 + newsCaption + hNews
	var H7 = H6 + hNews;

	$('#delim_h3').height(x20).css('top', H7);

	//-- topPage + topShadow + x20 + hTillyAbout + 2 * x20 + hAutomatContact
	//-- + 2 * x20 + newsCaption + hNews + x20
	var H8 = H7 + x20;

	$('#main_block_bottom')
		.css('top', H8)
	;


	//-- text line height
	var lineHeight = parseInt($('.body_inner').css('line-height'));
	//-- big text title height (like: "TillypadXL", "About" etc)
	//var h_title = parseInt($('.small_icon_bar .title').css('line-height'));
	var h_title = 32;

	//-- small text title height (like: "")
	var h_small_title = parseInt($('.small_title').css('line-height'));


	////////////////////////////////////
	//
	//   NEWS BLOCK
	//
	////////////////////////////////////
	//-- 20% - title - "more"
	var h5 = $('.h5').height();
	var h_news_body = hNews - lineHeight - h5 - h_title;
	var h_news_min = parseInt($('.data_news').css('min-height'));
	if(h_news_body < h_news_min) {
		h_news_body = h_news_min;
	}

	$('.data_news').height(h_news_body);
	
	$('#data_news1').height(h_news_body);
	$('#data_news2').height(h_news_body);
	$('#data_news3').height(h_news_body);

	setMoreLink($('#data_news1'), lineHeight);
	setMoreLink($('#data_news2'), lineHeight);
	setMoreLink($('#data_news3'), lineHeight);

	
	
	////////////////////////////////////
	//
	//   CONTACT BLOCK
	//
	////////////////////////////////////
	var h_contact_real = hAutomatContact - h_title - h_small_title - 7;

	$('#the_whole_automat').height(h_contact_real);
	//$('#the_whole_contacts').css('top', 0);

	////////////////////////////////////
	//
	//   AUTOMAT1 BLOCK
	//
	////////////////////////////////////
	var h_automat1 = parseInt(h_contact_real / 2);
	//-- h_automat1 - "Examples of automation" - "Restaurant Gilgamesh" - "more"
	var h_automat1_body = h_automat1 - h_title - h_small_title;
	$('#data_automat1').height(h_automat1_body);
	setMoreLink($('#data_automat1'), h_small_title);
	

	////////////////////////////////////
	//
	//   AUTOMAT2 BLOCK
	//
	////////////////////////////////////
	var h_automat2 = h_contact_real - h_automat1 - 7;
	//-- h_automat2 - "Restaurant Gilgamesh" - "more" - &nbsp; - "All examples of automation"
	var h_automat2_body = h_automat2 - h_small_title - h_small_title;
	$('#data_automat2').height(h_automat2_body);
	setMoreLink($('#data_automat2'), h_small_title);


	
	////////////////////////////////////
	//
	//   TILLY BLOCK
	//
	////////////////////////////////////
	//-- remainder - "TillypadXL" - "more"
	var h_tilly_body = hTillyAbout - h_title - h_small_title - h5;
	if(h_tilly_body < 0) {
		h_tilly_body = 0;
	}
	$('#data_tilly').height(h_tilly_body);
	setMoreLink($('#data_tilly'), h_small_title);

	
	////////////////////////////////////
	//
	//   ABOUT BLOCK
	//
	////////////////////////////////////
	//-- remainder - "About" - "more" - empty row before "more"
	var h_about_body = hTillyAbout - h_title - h_small_title - h5;
	if(h_about_body < 0) {
		h_about_body = 0;
	}
	$('#data_about').height(h_about_body);
	setMoreLink($('#data_about'), h_small_title);


	
	////////////////////////////////////
	//
	//   WELCOME BLOCK
	//
	////////////////////////////////////
	//-- main picture height: x20 * 10 (200px under the width in 1280px)
	//$('#picture').height(H / 5);
	//$('#picture').height(x20 * 10);

	//initPicsSlide();

	//var sliderImg = $('#slider img');
	//sliderImg.height(100);

	var sliderImg = $('#slider img');

	var dim = getImageSize(sliderImg.attr('src'));
	var imgHeight = wWelcome * dim.height / dim.width;
	//console.info(dim.width+' x '+dim.height);

	sliderImg.width(wWelcome).height(imgHeight);
	sliderImg.css('display', '');

	$('#picture img').width(wWelcome).height(imgHeight);
	$('#picture').width(wWelcome).height(imgHeight);

	

	var pics_height = $('#picture img').height();
	var pics_width = $('#picture img').width();
	
	$('#picture').height(pics_height);

	var pics_td_width = $('#picture').width();
	if((pics_td_width - pics_width) > 0) {
		$('#picture').width(pics_td_width);
	}

	var h_welcome_pics = parseInt($('#picture img').height());
	//var h_welcome_title = parseInt($('#welcome_bar').height());
	var h_welcome_title = 0;
	//var h_welcome_body = hWelcome - h_welcome_pics - h_welcome_title + h_small_title + h_small_title + h_small_title;
	var h_welcome_body = hWelcome - h_welcome_pics - h_small_title - h_small_title - h_small_title;
	var h_welcome_min = parseInt($('#data_welcome').css('min-height'));
	if(h_welcome_body < h_welcome_min) {
		//h_welcome_body = h_welcome_min;
	}

	//h_welcome_body += x20;
	$('#data_welcome').height(h_welcome_body);
	$('#main_block_welcome_text')
		.css('top', h_welcome_pics)
		.height(hWelcome - h_welcome_pics)
	;
	
	
	var srcObj = $('#data_welcome');
	var srcHeight = srcObj.height();
	var srcWidth = srcObj.width();

	if(welcomeObj == null) {
		welcomeObj = $('#body_inner_welcome');
		welcomeText = welcomeObj.html();
	}

	var containerObj = $('#text_container');
	//containerObj.css('left', x20);

	var welcomeHeight = welcomeObj.height();

	containerObj.width(wWelcome);
	containerObj.html(welcomeText);

	var containerHeight = containerObj.height();
	//var containerWidth = containerObj.width();
	var containerWidth = wWelcome;

	var welcomeMore = $('#welcome_more');

	//console.log(srcHeight+' < '+containerHeight);

	if(srcHeight < containerHeight) {
		welcomeMore.css('display', 'block');
	} else {
		welcomeMore.css('display', 'none');
	}

	/*
	
	//$('#debug').html('<h2>'+welcomeHeight+'/'+welcomeWidth+' -> '+containerHeight+'/'+containerWidth+' -> '+srcHeight+'/'+srcWidth+', text: '+welcomeObj.html().length+'</h2>');

	var theWholePageTable = $('#the_whole_page_table').height();

	var tmpH = topPage + topShadow + bottomHeight + delimitersHeight + newsCaption;
	tmpH += h_news_body + lineHeight + lineHeight;
	

	var tmpAboutBlock = h_about_body + h_title + h_small_title
	var tmpTillyBlock = h_tilly_body + h_title + h_small_title
	var tmpAutomat1Block = h_automat1_body + h_title + h_small_title + h_small_title;
	var tmpAutomat2Block = h_automat2_body + h_small_title + h_small_title + h_small_title + h_small_title;
	var tmpContactBlock = h_contact_real;

	tmpH += tmpAboutBlock;
	tmpH += x20;
	tmpH += tmpAutomat1Block;
	tmpH += tmpAutomat2Block;

	if(DEBUG) {
		
		var s  = 'topPage : '+topPage+'<br/>';
		s += 'topShadow : '+topShadow+'<br/>';
		s += 'bottomHeight : '+bottomHeight+'<br/>';
		s += 'delimitersHeight : '+delimitersHeight+' ('+x20+')<br/>';
		s += 'newsCaption : '+newsCaption+'<br/>';
		s += 'theNewsHeight : '+theNewsHeight+'<br/>';
		s += 'tmpAboutBlock : '+tmpAboutBlock+' ('+(h_title + h_small_title)+' - '+h_about_body+')<br/>';
		s += 'tmpTillyBlock : '+tmpTillyBlock+'<br/>';
		s += 'tmpAutomat1Block : '+tmpAutomat1Block+'<br/>';
		s += 'tmpAutomat2Block : '+tmpAutomat2Block+'<br/>';
		s += 'Automat->ALL : '+(tmpAutomat1Block + tmpAutomat2Block)+'<br/>';
		s += 'tmpContactBlock : '+tmpContactBlock+'<br/>';
		s += '<hr/>TOTAL: '+H+' against '+tmpH+', MainTable = '+theWholePageTable+'<br/>';

		//$('#welcome_block').width(percent33);
		//$('#second_block').width(percent33);
		//$('#third_block').width(percent33);
		
		var w1 = $('#welcome_block').width();
		var w2 = $('#second_block').width();
		var w3 = $('#third_block').width();

		var ww = $(window).width();
		
		$('#debug').html('<h2>'+w1+'-'+w2+'-'+w3+' -> 33%='+percent33+', welcomeW='+welcomeWidth+', pictureW='+pw+'</h2>');
	}
	
	//var s = H+' - ('+topPage+' + '+topShadow+' + '+bottomHeight+' + '+delimitersHeight+' + '+newsCaption+') = '+gummyHeight+' / 5 = '+percent20;
	//$('#debug').html('<h2>'+s+'</h2>');
	
	//$('#the_whole_page_table').height(H);

	*/
	
	var divName = 'welcome';

	$('div').each(function(index) {
		var name = $(this).attr('id');
		var id = name.substring(6);
		
		if(name.substring(0, 6) == 'block_') {
			var h = $('#data_'+id).height();
			var w = $('#data_'+id).width();

			if(id != 'welcome') {
				h -= 15;
			}

			var innerHeight = Math.floor(h / 15) * 15;
			var srcObj = $('#body_inner_'+id);
			srcObj.height(innerHeight);
		}	
	});
	
	$('.news_body').each(function(index) {
		var id = $(this).attr('id').substring(5);
			
		var h = $('.data_news').height();
		var w = $('.data_news').width();
		
		//alert(id+' -> '+h);

		//$('#debug1').html('h1: '+h+', w1: '+w);
		
		var innerHeight = Math.floor(h / 15) * 15;
		srcObj1 = $('#news_body_inner1');
		srcObj2 = $('#news_body_inner2');
		srcObj3 = $('#news_body_inner3');

		srcObj1.height(innerHeight);
		srcObj2.height(innerHeight);
		srcObj3.height(innerHeight);

		//$('#debug').html(h+' : '+innerHeight);

		//$('#debug').html('h1: '+h+', w1: '+w);

	});

	alignComboboxCity();

	menuMinWidth = $('#welcome_block').width();

	//console.info();

	//console.info('checkDivSize');
}

