jQuery(document).ready(function($) {
	$('#menu ul li').corner("3px");
	$('#nav .button a').corner("3px");
	$('.imgbutton a').corner("3px");
	$('.contactinput').corner("3px");
	$('.contactinputextrawidth').corner("3px");
	$('.contacttextarea').corner("3px");
	$('#main .post img').corner("3px");
	
	var img_height = $('img').css('height');
	var nImage = 0;
	var fImage = 1;
	var imgSlideSpeed = 0;
	var play = true;
	
	$('.scrollable').scrollable({  
		size: 1, 
		speed: 0,
		clickable: false,
		easing: "swing",
	}).circular().navigator({indexed:true}).autoscroll(5000);
	
	var nImages = $(".navi a").size();
	
	if (nImages > 1) {
		api = $('div.scrollable').scrollable(); 
		api.onBeforeSeek(function(event,index){ 
			var element = jQuery("div.scrollable"); 
			if (element.css('opacity') == .01) { 
				return true; 
			} 
			element.fadeTo(400, .01, function(){ 
				api.seekTo(index); 
			}); 
			return false; 
		}).onSeek(function(){ 
			jQuery("div.scrollable").fadeTo(400, 1); 
		
			if (play == true) {			
				fImage++;
				if (fImage > nImages) {
					fImage = 1;
				}
				img_height = $('img:eq('+fImage+')').css('height');
				$('div.scrollable').animate({
					'height': img_height,
				}, 200);
			}
		});
	}		

	$('.navi a').click(function() {		
		play = false;
		nImage = $(this).text(); 
		nImage++;
		img_height = $('img:eq('+nImage+')').css('height');
		setTimeout($('.scrollable').animate({
			'height': img_height,
		}, 200),800);
	});

	$('.scrollable').css({
		'height': img_height,
	});
	
	
	$(function() {
		$(".post img").css("opacity","0.6");
		$(".post img").hover(function () {
			$(this).stop().animate({
				opacity: 1.0
			}, "slow");
		},
		function () {
			$(this).stop().animate({
				opacity: 0.6
			}, "slow");
		});
	});
	
});