jQuery(document).ready(function(){
	jQuery('#gallery_nav').animate({'opacity':'0.75'},500);

	jQuery('#gallery_nav_outer img#gn_down')
		.bind('mouseenter',function(){
			jQuery(this)
				.attr('src','project_files/img/down_big.png')
				.stop()
				.animate({'width':'19px',
							'height':'19px'},300);
		})
		.bind('mouseleave',function(){
			jQuery(this)
				.stop()
				.animate({'width':'14px',
							'height':'14px'},300,function(){
													jQuery(this).attr('src','project_files/img/down.png')
												});
		})
		.bind('click',function(){
			var height=jQuery('#gallery ul li:last').contents().find('img').height();
			jQuery('#gallery ul li:last')
				.css({'height':'0px'})
				.prependTo('#gallery ul')
				.animate({'height':height},500);
		});

	jQuery('#gallery_nav_outer img#gn_up')
		.bind('mouseenter',function(){
			jQuery(this)
				.attr('src','project_files/img/up_big.png')
				.stop()
				.animate({'width':'19px',
							'height':'19px'},300);
		})
		.bind('mouseleave',function(){
			jQuery(this)
				.stop()
				.animate({'width':'14px',
							'height':'14px'},300,function(){
													jQuery(this).attr('src','project_files/img/up.png')
												});
		})
		.bind('click',function(){
			jQuery('#gallery ul li:first')
				.animate({'height':'0px'},500,function(){
					var height=jQuery(this).contents().find('img').height();
					jQuery(this)
						.appendTo('#gallery ul')
						.css({'height':height});
				});
		});

	jQuery('#gallery ul li')
		.each(function(i,e){
			var height=jQuery(this).contents().find('img').height();
			jQuery(this).animate({'height':height},2000);
		});


	// content - scrolling
	jQuery('#scroll_up')
		.bind('mouseenter',function(){
			jQuery(this).attr('src','project_files/img/scroll_up_big.png');
			jQuery(this)
				.stop()
				.animate({width:'29px',height:'29px'},300);
		})
		.bind('mouseleave',function(){
			jQuery(this)
				.stop()
				.animate({width:'15px',height:'15px'},300,function(){
														jQuery(this).attr('src','project_files/img/scroll_up.png');
													});
		})
		.bind('click',function(){scrollContent('up',100)});

	jQuery('#scroll_down')
		.bind('mouseenter',function(){
			jQuery(this).attr('src','project_files/img/scroll_down_big.png');
			jQuery(this)
				.stop()
				.animate({width:'29px',height:'29px'},300);
		})
		.bind('mouseleave',function(){
			jQuery(this)
				.stop()
				.animate({width:'15px',height:'15px'},300,function(){
														jQuery(this).attr('src','project_files/img/scroll_down.png');
													});
		})
		.bind('click',function(){scrollContent('down',100)});
});


function scrollContent(dir,step) {
	var cHeight		= jQuery('#content').height();
	var cIHeight	= jQuery('#content_inner').height();
	var cITop		= parseInt(jQuery('#content_inner').css('top'));
	if(dir=='down' && ((cIHeight+cITop)>cHeight)) {
		jQuery('#content_inner').animate({top:(cITop-step)+'px'});
	} else if(dir=='up' && cITop<=(-step)) {
		jQuery('#content_inner').animate({top:(cITop+step)+'px'});
	}
}