jQuery(document).ready(function($) {
    // $() will work as an alias for jQuery() inside of this function







// imageSwitch
var $newone;
$("#content-slider-inside li").css({'position' : 'absolute', 'left' : '0', 'top':'0', 'z-index':'1', 'display':'none'});
$("#content-slider-inside li:first").addClass('ontop').css({'display':'block', 'z-index':'10'});


		$("a.gallerythumb").click(function(e){
			e.preventDefault();
			$newone = $('#content-slider-inside li'+ $(this).attr('href'));
			$newone.css({'position' : 'absolute', 'left' : '0', 'top':'0', 'z-index':'100', 'display':'none'})
					.fadeIn(function(){	$('li.ontop').removeClass('ontop').hide();
										$newone.addClass('ontop').css({'display':'block', 'z-index':'10'});
										});
		});	
	
	
			
		/*
		//this one capable of moving one step forward
		
		$("a.gallerythumb").click(function(e){
e.preventDefault();
  var $active = $('#content-slider-inside li.active');
  var $next = ($('#content-slider-inside li.active').next().length > 0) ? $('#content-slider-inside li.active').next() : $('#content-slider-inside li:first');
    $active.removeClass('active').css({'display':'none'});
    $next.fadeIn().addClass('active');
    	});
  
*/			



// gallery more views switch + aktual x
$(".moreViews span").hover(function(){
	var thumbclass = $(this).attr('class'); //get thumb class
	$(this).parents('li').find('div').removeClass('selected').addClass('unselected');
	$('#'+thumbclass+'').addClass('selected').removeClass('unselected'); 	
});

$('a.gallerythumb').click(function () {
  $('.unselected').removeClass('unselected') // remove selected class from all images

  $('a.gallerythumb span.selected').fadeOut().removeClass('selected');
  $(this).find('span.aktualx').fadeIn().addClass('selected');
});








// jQuery scroll




/*
		$("a.gallerythumb").click(function(){
			$('span.aktualx').fadeIn();
			thumbtarget = $(this).attr('href');   
			
		});
*/





// e-gallery menuSwitch

$('#menuSwitch1').hover(function(){
	 $('#ulwrap_slider').animate({right: "-150"}, 300);
	 $('ul.HiddenSidebar').hover(function(){},function(){$('#ulwrap_slider').animate({right: "0"}, 600);})
	},function(){})



// content scroll
var moveInterval; //var position;

$('#contentbox').css({overflow:"hidden"})

$('#scrolldown').hover(function(){
moveInterval = setInterval(move_up,40);
	},function(){
clearInterval(moveInterval);	
})

$('#scrollup').hover(function(){
moveInterval = setInterval(move_down,20);
	},function(){
clearInterval(moveInterval);	
})

$('#scrollup').click(function(){
clearInterval(moveInterval);
$('#content_inside').animate({top: "0"}, "fast");
position=0;
$(this).fadeOut();
})

moveLimit = 250 - jQuery('#content_inside').height();
if (moveLimit>0) {$('#scrolldown').hide();}
$('#scrollup').hide();

$('#scrolldown').click(function(){
clearInterval(moveInterval);
$('#content_inside').animate({top: moveLimit}, "fast");
position=moveLimit;
$(this).fadeOut();
})

				
			$(window).mousewheel(function(objEvent, intDelta){
			    if (intDelta > 0 && position<0){
			    move_down();move_down();			    
			   				}
			    else if (intDelta < 0 && position > moveLimit){
			    move_up();move_up();

				}
			});




});


//var position;
var position=0;



 function move_up() {
 	if (position==0) {
 	 	 	jQuery('#scrollup').fadeIn();
 	}
 
	 if (position > moveLimit) {

		position=position-5;
		jQuery('#content_inside').css('top', position);
	} else {
	jQuery('#scrolldown').fadeOut();
	}
 }

 function move_down() {
 	 if (position<0) {
 	 	jQuery('#scrolldown').fadeIn();
	position=position+5;
	jQuery('#content_inside').css('top', position);
	}else {
	jQuery('#scrollup').fadeOut();
	}
 }
 
 
 
 
 
 
 //jquery loves analytics
 
 $('a.gallerythumb').track();
 

