$(document).ready(
	function(){
	
	
	// Sliding panels effect
	$('#panels').kwicks({
		max : 580,
		spacing : 0,
		easing: 'easeInOutQuad',
		duration: 1200
	});


	// Projects grid
	if ($("#grid").length > 0) {
		$('.object dt').hide();
		$('.object dd').hide().fadeIn('slow');
		$('.object').hover(
			function(){
				$(this).stop().find('dt').show();
				$(this).stop().find('dd').fadeTo(300,.3);
			},
			function(){
				$(this).find('dt').hide();
				$(this).find('dd').fadeTo(1200,1);
			}
		)
	}

	// Photo gallery Cycle setup
	if ($("#gallery ul").length > 0) {
	
		zeroBasedSlideIndex = 0;
		
		if (!location.hash) { 
			startingSlide = 0;
		}
		else {
			startingSlide = location.hash.substring(1);
		}
		
		$('#gallery ul').cycle({
    		speed:   600, 
   			timeout:  0,
   			startingSlide: startingSlide,
   			cleartype: true,
			next: '#nextImage,#gallery li img',
			prev: '#previousImage',
			previous: '#previousImage',
   			sync:0,
   			easing: 'easeInOutQuad',
   			pager: null,
   			prevNextClick: prevNextClick
   		})
   	}
   	
   	
   	
   	function prevNextClick(isNext, zeroBasedSlideIndex, slideElement) { 
		//location.hash = "#"+zeroBasedSlideIndex;	
	}


	// Back button
	if($(".back").length > 0 ) {
		$(".back").click(function(event) {
				history.back();
		});
	}
	
	
	// External links
    $("a[rel='external']").addClass("external").click(function() { 
    	window.open($(this).attr('href')); 
    	return false;
    });


})
