//$(window).load(function(){    
$(document).ready(function(){ 
	 textisvisible = 0 ;
	 transisstarsted = 0 ;
	 var aktdetail;
	 $("#slideshow").fadeIn('slow'); 

	
	$('#imagenaveprev')
		.css( {backgroundPosition: "-24px 181px"} ) 
		.mouseover(function(){
			$('#slideshow').cycle('pause');
			$('body').css('cursor', 'pointer');
			$(this).stop().animate({backgroundPosition:"(0px 181px)"}, {duration:200})
		})
		.mouseout(function(){
		$('body').css('cursor', '');
			$('#slideshow').cycle('resume');
			$(this).stop().animate({backgroundPosition:"(-24px 181px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "-24px 181px"})
			}})
		})

		
	$('#imagenavenext')
		.css( {backgroundPosition: "344px 181px"} ) 
		.mouseover(function(){
			$('#slideshow').cycle('pause');
			$('body').css('cursor', 'pointer');
			$(this).stop().animate({backgroundPosition:"(320px 181px)"}, {duration:200})
		})
		.mouseout(function(){
		$('body').css('cursor', '');
			$('#slideshow').cycle('resume');
			$(this).stop().animate({backgroundPosition:"(344px 181px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "344px 181px"})
			}})
		})	
		
	 
	 
	  $("a[rel^='prettyPhoto']").prettyPhoto();

	
	  $('#imagebox').mousemove(function(e){	
		//top.xpos= e.pageX;
		//top.ypos= e.pageY;
		
		//alert(e.pageX);
		//if (e.pageX > 40 && e.pageX < 728 && e.pageY > 96 &&  e.pageY < 482 ){
			if (textisvisible == 0){ 
					textisvisible = 1;
					$(".displayinfo").show();
					$('.'+top.aktdetail).show();
			}
		// }else{
		//	 if (textisvisible == 1){ 
		//			textisvisible = 0;
		//			$(".displayinfo").hide();
		//			$('.'+top.aktdetail).hide();
		//	 }
		// }
		});
		
		$('#imagebox').mouseleave(function(e){	
		//top.xpos= e.pageX;
		//top.ypos= e.pageY;
		
		//alert(e.pageX);
		//if (e.pageX > 40 && e.pageX < 728 && e.pageY > 96 &&  e.pageY < 482 ){
		
		// }else{
			 if (textisvisible == 1){ 
					textisvisible = 0;
					$(".displayinfo").hide();
					$('.'+top.aktdetail).hide();
			 }
		// }
		});
	
	
	
});
	
	function onBefore(curr, next, opts){
		$('#imagebox').show();
		for (i=1; i<=opts.slideCount; i++){
			$('.v'+i).hide();
		}
		thenumber = str_replace('item', '', this.id);
		
		//alert(document.getElementById('item'+thenumber).offsetHeight)
		     

	 	// $('#imagenaveprev').css('height', $('#item'+thenumber).height());
	 	// $('#imagenavenext').css('height', $('#item'+thenumber).height());
		//$('#imagebox').css('height', $('#item'+thenumber).height());
		
	}
	
	function onAfter(curr, next, opts){
		for (i=1; i<=opts.slideCount; i++){
			theheight = $('#item'+i).height();
			  $('.v'+i).hide();
			 // $('.v'+i).css('top', $('#item'+i).height()-24);
		} 
		top.aktdetail = 'v'+thenumber ;
		if (top.xpos > 40 && top.xpos < 728 && top.ypos > 96 && top.ypos< 482 ){
			 $('.'+top.aktdetail).fadeIn('slow');
		}
	}

	function str_replace(search, replace, subject) {
		return subject.split(search).join(replace);
	} 
