$(document).ready(function(){
	
	// popup aktuell
	$("a.link_aktuell").mouseover(function(evt){
		$(this).css("color","#82b9cf");
		$(this).css("cursor","pointer");
	});
	$("a.link_aktuell").mouseout(function(evt){
		$(this).css("color","#3f2d22");
	});
	$("a.link_aktuell").click(function(evt){
		
		$("#arrows").css("display","none");
		
		$("#popupimg").attr("src","data/" + $(evt.target).attr('rel'));
		$("#popup").css("display","none");
		$("#popup").fadeIn(500);
		
		$("#popup").css({
			"position": "absolute",
			"top":  evt.pageY-100 + "px",
			"left":  evt.pageX-100  + "px"
		});
	});

	$("a.link_bilder").mouseover(function(evt){
		$(this).css("color","#82b9cf");
		$(this).css("cursor","pointer");
	});
	$("a.link_bilder").mouseout(function(evt){
		$(this).css("color","#3f2d22");
	});
	$("a.link_bilder").click(function(evt){
		
		loadImage();
		$("#arrows").css("display","block");
		$("#popup").css("display","none");
		$("#popup").fadeIn(500);
		
		$("#popup").css({
			"position": "absolute",
			"top":  evt.pageY-100 + "px",
			"left":  evt.pageX-100  + "px"
		});
	});
	
	
	// img hover
	$(".imghover img").mouseover(function(evt){
		$(this).attr("src","img/" + $(evt.target).attr('rel') + "_rgb.jpg");
		//$(this).css("cursor","pointer");
	});
	$(".imghover img").mouseout(function(evt){
		$(this).attr("src","img/" + $(evt.target).attr('rel') + "_bw.jpg");
	});
	/*
	$(".imghover img").click(function(evt){
		
		$("#arrows").css("display","none");
		
		$(this).attr("src","img/" + $(evt.target).attr('rel') + "_rgb.jpg");
		$("#popup").css("display","none");
		$("#popup").fadeIn(500);
		
		$("#popup").css({
			"position": "absolute",
			"top":  evt.pageY-100 + "px",
			"left":  evt.pageX-100  + "px"
		});
	});
	*/
});

arrImages = new Array("1","2","3","4","5","6","7");
var activeImage = 0;

function closePopup() {
	$("#popup").fadeOut(200);
}

function loadImage() {

	$("#popupimg").fadeOut(200)
		.queue( function(){
			$(this).attr("src","img/speziell/" + arrImages[activeImage] +".jpg");
			$(this).dequeue();
		});
	
	$("#popupimg").load( function() {
		$("#popupimg").fadeIn(500);
	});
}
function nextImage() {
	if(activeImage < arrImages.length-1) {
		activeImage++;
	} else {
		activeImage = 0;
	}
	loadImage();
		
}

function prevImage() {
	if(activeImage > 0) {
		activeImage--;
	} else {
		activeImage = arrImages.length-1;
	}
	loadImage();
}



