function gallery() {
	$(".gallery").each( function() {
		$('.prev', this).remove();
		$('.next', this).remove();
		$('.bigpicture', this).remove();
		if(location.pathname.indexOf("multimedia") == -1 && location.pathname.indexOf("video") == -1){
			$(this).append('<div class="prev"><a></a></div><div class="next"><a></a></div>');
			
			$('.prev').css('opacity','.5');
			$('.next').css('opacity','.5');
		}
		var bigpicture = $('<div class="bigpicture"><div></div></div>');
		$(this).prepend(bigpicture);
		
		$("a.imagethumb", this).each(function(i, a) {
			$(this).click(function() {
				act_pic = i;
				var href = $(this).attr("href");
				var title = $("img", this).attr("alt");
				var me = this;
				if($(this).attr("rel") == "video"){
					$("div", bigpicture).animate({opacity:0}, 400, null, function(){
						bigpicture.empty();
						bigpicture.append('<div><p>'+title+'</p><object style="margin-top:45px; type="application/x-shockwave-flash" data="/flash/player_flv_mini.swf" width="800" height="450"><param name="movie" value="/flash/player_flv_mini.swf" /><param name="FlashVars" value="flv='+href+'&amp;width=800&amp;height=450&amp;autoplay=1" /></object></div>');
						$("div", bigpicture).animate({opacity:1},400);
					});
				}else{
					$("div", bigpicture).animate({opacity:0}, 400, null, function(){
						bigpicture.empty();
						bigpicture.append('<div><p>'+title+'</p><img src="'+href+' alt="" /></div>');
						$("div", bigpicture).animate({opacity:1},400);
					});
				}
				return false;
			});
		});
	});
	
	$("div.thumbnails img").mouseover(function(){
              $(this).animate({opacity:0.7},220);
         }).mouseout(function(){
              $(this).animate({opacity:1},220);
        });
	if(location.pathname.indexOf("multimedia") == -1 && location.pathname.indexOf("video") == -1){
		$("div.prev").mouseover(function(){
			$(this).animate({opacity:1}, 180);	
		 }).mouseout(function(){
			$(this).animate({opacity:.5}, 180);
		}).click(function(){
			if(act_pic == 0){
				act_pic = $("div.thumbnails a").size()-1;
			}else{
				act_pic -= 1;
			}
			
			var act_click = $("div.thumbnails a").get(act_pic);
			$(act_click).click();
			
			
		});
		$("div.next").mouseover(function(){
			$(this).animate({opacity:1}, 180);										 
		 }).mouseout(function(){
			$(this).animate({opacity:.5}, 180);
		}).click(function(){
			if(act_pic == $("div.thumbnails a").size()-1){
				act_pic = 0;
			}else{
				act_pic += 1;
			}
			var act_click = $("div.thumbnails a").get(act_pic);
			$(act_click).click();
		});
	}
	
	var act_pic = 0 //Math.floor(Math.random()*($("div.thumbnails a").size())+1);
	var first_click = $("div.thumbnails a").get(act_pic);
	
	$(first_click).click();
	
}
function video()
{
}
function thumbnails() {
	$("div.thumbnails").mouseover(function(e){
		$(document).bind('mousemove', thumbnails_mozog);
	 }).mouseout(function(){
		// esemény elvétel:
		$(document).unbind('mousemove', thumbnails_mozog);
	});
}
function thumbnails_mozog(e) {
	var pozicio = $("div.jqmWindow").css("left");
	var margin = $("div.jqmWindow").css("margin-left");
	var thumbnailsWidth = $(".thumbnails").width()
	var ulWidth = $(".thmbsUl").width()
	var newpozicio = pozicio.substr(0,pozicio.length-2) - margin.substr(1,margin.length-3) + 10
	if(ulWidth >= thumbnailsWidth){
		$('div.thumbnails ul').css({ "left":-(((e.pageX-newpozicio)/thumbnailsWidth)*(ulWidth-thumbnailsWidth))});
	}
	
}
gallery();
thumbnails();


