		$(document).ready(function() {

			var index = 0;
			var indit;
			var tarolo = $('div.latest div.folio');
			var next = index + 1;
			var prev = $(tarolo).children().size() - 1;
			var valtido = 8000;
			var animido;
			
			function Kepvalt(index) {
				clearInterval(indit);
				
				if (index >= $(tarolo).children().size()) {
					index = 0;
					next = index + 1;
					prev = $(tarolo).children().size() - 1;
				} else {
					if (index < 0) { index = $(tarolo).children().size() - 1; }
					prev = index - 1;
					next = index + 1;
				}
				
				
				var pos = index * 730;
				var maxpos = $(tarolo).children().size() * 730;
				
				if (pos < maxpos) { pos = (index * -730); animido = 1000; } else { pos = 0;  animido = 1500;}
				
				$(tarolo).animate({ left: pos }, animido);
				
				indit = setInterval(function() { Kepvalt(next); }, valtido);
				
				$('ul.scroll li a').removeClass('active');
				var link = index + 1;
				$('ul.scroll li a#w' + link).attr('class', 'active');
				
				
				
			}
			
			indit = setInterval(function() { Kepvalt(next); }, valtido);
			
			$(tarolo).mouseover(function() { clearInterval(indit); }).mouseout(function() { indit = setInterval(function() { Kepvalt(next); }, 3000); });
			
			$('a#next').click(function () {
				clearInterval(indit);
				Kepvalt(next);
			});
			
			$('a#prev').click(function () {
				clearInterval(indit);
				Kepvalt(prev);
			});
			
			$('ul.scroll li a').click(function() {
				var href = $(this).attr("id").replace(/w/g, '');
				href--;
				Kepvalt(href);
			});
			
			var twitt = $('div.twitter');
			var t;
			
			function bekapcs() {
				if ($(twitt).css('display') == 'none') {
					$(twitt).css('display', 'block');
					$(twitt).css('opacity', '0');
					$(twitt).animate({bottom: '130px', opacity: '1.0'}, 'normal');
				}
			}
			
			function kikapcsol() {
				alert('ittvagyunk');
			}
			
			$('div.photo').mouseover(function() {
				clearTimeout(t);
				bekapcs();
			}).mouseout(function() {
				t = setTimeout(function() {
					if ($(twitt).css('display') == 'block') {
						$(twitt).animate({bottom: '140px', opacity: '0'}, 'normal', '', function() {
							$(twitt).css('bottom', '120px');
							$(twitt).css('display', 'none');
						});
					}
				}, 500);
			});
			
			$(twitt).mouseover(function() {
				clearTimeout(t);
			}).mouseout(function() {
				t = setTimeout(function() {
					if ($(twitt).css('display') == 'block') {
						$(twitt).animate({bottom: '140px', opacity: '0'}, 'normal', '', function() {
							$(twitt).css('bottom', '120px');
							$(twitt).css('display', 'none');
						});
					}
				}, 500);
			});
			
		});
