function registerHomeScroller() {
	$('#homeScroller-btnUp').click(function() {
		if($('#homeScroller-content').position().top < 85 && !$('#homeScroller-content').is(':animated')) {
			$('#homeScroller-content').animate({
				top: '+=85'
			}, 500, function() {
				if($('#homeScroller-content').position().top >= 3) {
					$('#homeScroller-content').css('top', -592);
				}
			});
		}
	});
	
	$('#homeScroller-btnDown').click(function() {
		if($('#homeScroller-content').position().top > -$('#homeScroller-content').height() + 200 && !$('#homeScroller-content').is(':animated')) {
			$('#homeScroller-content').animate({
				top: '-=85'
			}, 500, function() {
				if($('#homeScroller-content').position().top <= -932) {
					$('#homeScroller-content').css('top', -340);
				}
			});
		}
	});
	
	var contentHTML = document.getElementById('homeScroller-content').innerHTML;
	var contentDiv = document.createElement('div');
	var contentDiv1 = document.createElement('div');
	$(contentDiv).html(contentHTML);
	$(contentDiv1).html(contentHTML);

	$('#homeScroller-content').html('');
	$('#homeScroller-content').append(contentDiv);
	
	$('#homeScroller-content').append(contentDiv1);
	
	$('#homeScroller-content').css('top', - $(contentDiv1).height() + 43+'px');
}

function registerHistoryScroller() {
	var container = $('#historyScroller');
	var blobContainer = $("#historyBlobContainer");
	var panelBottom = $('#historyScroller .panelBottom');
	var ul = $('#historyScroller ul');
	var lis = container.find("li");
	
	ul.css('width', (lis.length * 54)+'px');
	
	/*
	if(ul.width() > 540) {
		panelBottom.mousemove(panelBottom_MOUSEMOVE);
	}
	*/
	var posId = 0;
	lis.each(function(i) {
			this.pos = posId;
			$(this).click(date_CLICK);
			posId++;
	});
	
	function panelBottom_MOUSEMOVE(e) {
		var posP =  (e.pageX - panelBottom.offset().left - 55) / 550;
		posP = posP < 0 ? 0 : posP > 1 ? 1 : posP;
		var pos = (590 - (lis.length * 54)) * posP + 10;
		ul.css('left', pos+'px');
		blobContainer.css('left', pos+'px');
	}
	
	function date_CLICK() {
		if(lis.length > 11) {
			if(lis.length / 2 < this.pos) {
				var pos = (610 - (lis.length * 54));
			
				ul.animate({left: pos}, 400);
				blobContainer.animate({left: pos}, 400);
			}	else {
				ul.animate({left: 10}, 400);
				blobContainer.animate({left: 10}, 400);
			}	
		}
		
		lis.each(function(i) {
			$(this).removeClass('clicked');
			$('#history-page-'+$(this).find('.link').html()).hide();
		});
		$("#historyBlob").stop();
		$("#historyBlob").animate({left: $(this).position().left - 10}, 400);
		$("#historyBlob").html($(this).find('.year').html());
		$(this).addClass('clicked');
		
		var ss = '#history-page-'+$(this).find('.link').html();
		$(ss).show();
	}
	
	lis.last().click();
}

function registerSlideshow(elemId) {
	var przes = 384;
	var container = $('#'+elemId);
	var imgs = container.find("img");
	var img;
	var inner = document.createElement("div");
	var outer = document.createElement("div");
	var btnLeft = document.createElement("div");
	var btnRight = document.createElement("div");
	$(inner).addClass('inner');
	$(outer).addClass('outer');
	$(btnLeft).addClass('btnLeft');
	$(btnRight).addClass('btnRight');
	container.append(outer);
	$(outer).append(inner);
	container.append(btnLeft);
	container.append(btnRight);
	
	var imgsLength = imgs.length; // * 2;
	
	var currentImg = container.attr('rel');
	$(inner).css('left', -currentImg * przes);
	
	var slideShowInterval = setInterval(timer, 5000);
	
	function timer() {
		currentImg++;
		if(currentImg > imgsLength-1) {
			currentImg = 0;
		}
		$(inner).animate({left: -currentImg * przes}, 400);
	}
	
	$(inner).append(imgs);
	
	imgs.each(function(i) {
		img = $(this);
		img.addClass('picture');
		img.css('left', i*przes+'px');
	});

	
	$(btnLeft).click(btnLeft_CLICK);
	$(btnRight).click(btnRight_CLICK);
	
	$(outer).mouseout(outer_MOUSEOUT);
	$(outer).mouseover(outer_MOUSEOVER);
	$(btnLeft).mouseover(outer_MOUSEOVER);
	$(btnLeft).mouseout(outer_MOUSEOUT);
	$(btnRight).mouseover(outer_MOUSEOVER);
	$(btnRight).mouseout(outer_MOUSEOUT);
	
	function outer_MOUSEOVER() {
		clearInterval(slideShowInterval);
	}
	
	function outer_MOUSEOUT() {
		slideShowInterval = setInterval(timer, 5000);
	}
 	
	function btnLeft_CLICK() {
		currentImg--;
		if(currentImg < 0) {
			currentImg = imgsLength -1;
			$(inner).css('left', -currentImg * przes);
			currentImg--;
		}
		$(inner).animate({left: -currentImg * przes}, 400);
	}
	
	function btnRight_CLICK() {
		currentImg++;
		if(currentImg > imgsLength-1) {
			currentImg = 0;
			$(inner).css('left', -currentImg * przes);
			currentImg++;
		}
		
		$(inner).animate({left: -currentImg * przes}, 400);
	}
}

function gpMainMenuOn() {
if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
	var ieversion = new Number(RegExp.$1);
	if(ieversion<8 && ieversion>=7) {
	if(document.getElementById('entry-content')) document.getElementById('entry-content').style.zIndex= -1;
}}
}

function gpMainMenuOff() {
if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
        var ieversion = new Number(RegExp.$1);
        if(ieversion<8 && ieversion>=7) {
        if(document.getElementById('entry-content')) document.getElementById('entry-content').style.zIndex= 0;
}}
}

