
var ile;
var objHeight;
var top;
$(document).ready(function(){
	var anonse = $('a.anons').each(function(){
		dostosujText($(this));	
		});
	ile = anonse.length;
	if(ile < 13) dostosujAnonseBox($('#anonse'));
	
	if($('#anons')) dostosujAnonsBox($('#anons'));
	
	$('#blind').css('opacity',0.8);
	});

function dostosujAnonsBox(obj) {
	if(obj==null) return false;
	objHeight = obj.height();
	top = Math.floor(( 719 - objHeight - 46) / 2);
	obj.css({'top':top});
	}//e f

function dostosujAnonseBox(obj) {
	if(obj==null) return false;
	var anonse = $('a.anons');
	ile = anonse.length;
	var height = obj.innerHeight();
	if(ile < 5) {
		height = 140;
		}
	else if(ile < 9) {
		height = 280;
		}
	else if(ile < 13) {
		height = 420;
		}
	obj.css({'height':height+'px'});
	var contentHeight = 719;
	var objHeight = obj.innerHeight();
	var top = (contentHeight - objHeight - 110) / 2;
	obj.css({'top':top});
	}//e f

function dostosujText(obj) {
	var size = { width:$(obj).innerWidth() , height:$(obj).innerHeight() }
	var change = -1;
	if(size.width > 130) {
		var font = parseFloat(obj.css('fontSize'))-1;
		$(obj).css({'font-size':font+'px','fontWeight':'bold'});
		change = 1;
		}
	if(size.height > 130) {
		var html = obj.html();
		var m = html.replace('<BR>',' ');
		if(m==html) {
			m = html.replace('<br>',' ');
			}
		if(m!=html) {
			obj.html(m);
			change = 1;
			}
		}
	if(change==1) {
		dostosujText(obj);
		}
	if(change==-1) obj.css({'height':'130px'})
	}//e f
