// JavaScript Document

var stranice = {
	maxh:		980,
	t:			1,
	h:			'div#content-left',
	ht:			'div#content-left div.text-area',
	hs:			'div#content-left div#scroller',
	c:			0,
/*
	init
*/
	init: function() {
		h =					Number($(stranice.ht).outerHeight());
		h1 =				Number($(stranice.h+' h1').outerHeight());
		pages_top = 		Number($('.page-links.top').outerHeight())
		stranice.maxh =		stranice.maxh - (h1) - pages_top;
		
		//alert(h+'\n'+h1+'\n'+stranice.maxh);
		//return false;
		while (h > stranice.maxh) {stranice.t++; h = h - stranice.maxh - 45}
		stranice.maxh =		String(stranice.maxh - 45);
		HTML = '<div id="scroller" style="position: relative; margin-top: 0px;">'+$(stranice.ht).html()+'</div>';
		$(stranice.ht).empty().append(HTML).css({
			'position':		'relative',
			'height':		stranice.maxh+'px',
			'overflow':		'hidden'
		});
		HTML = null;
		current = '';
		// stranice
		if (stranice.t > 1) {
			HTML = '';
			HTML += '';
			for (i = 1; i <= stranice.t; i++) {
				if(i==1){current = 'current'} else {current =''}
				HTML += '<a onclick="stranice.page('+i+' , this);" class="'+current+'" style="cursor:pointer;">'+i+'</a>';
			}
			HTML += '<div class="clear"></div>';
			$(".page-links").html(HTML);
			//$(HTML).insertAfter(stranice.h+' h1');
		}
		HTML = h = h1 = null;
	},
/*
	stranice
*/
	page: function(w , el) {
		w = w - 1;
		m = String(stranice.maxh * w * -1)+'px';
		/*
		$(stranice.hs).css('margin-top', m);*/
		$(stranice.hs).animate({
			'margin-top':		m
		}, 500);
		
		$('.page-links a').removeClass('current')
		var n = $(el).index()
		//alert(n)
		$('.page-links.top a').eq(n).addClass('current')
		$('.page-links.bottom a').eq(n).addClass('current')
	}
};

