/*
	JS by Joshua Gatcke http://www.99lime.com
*/

$(document).ready(function(){
	
	// slideshow
	$('#slideshow #images img').not(':first').hide().addClass('off');
	function slideshow()
	{
		$('#slideshow #images img.off').hide();
		var current = $('#slideshow #images img').not('.off');
		var next = current.next();
		
		$('#slideshow #images img').not('.off').show();
		$('#slideshow #images img.off').hide();

		if(current.is(':last-child')) { next = $('#slideshow #images img:first'); }
		
		if ( $.browser.msie ) {
			current.addClass('off').delay(5000).show();
			next.removeClass('off').delay(5000).hide(0,slideshow);
		}else{
			current.addClass('off').delay(5000).fadeOut(1000);
			next.removeClass('off').delay(5000).fadeIn(1000,slideshow);
			next.css('opacity',1);
		}
		
	}slideshow();
	
	// Navigation
	$('#mainnav li').hover(function(){
		//$(this).find('ul:first').fadeIn('fast');
		$(this).find('ul:first').css('display','block');
	}, function(){
		//$(this).find('ul:first').fadeOut('fast');
		$(this).find('ul').css('display','none');
	});
	
	$('#mainnav li').click(function(){
		$(this).find('ul').css('display','none');
	});
	
	// navigation arrows
	$('#mainnav li ul').parent().find('a:first').append('<span></span>');
	
	// gallery lightbox
	$('.gallery a.thumb').colorbox({opacity: 0.5});
	
	// page height
	$('.pagewrap').css('min-height', $('#sidebar').height());
	
});
