$(document).ready(function(){



    // this initialises the demo scollpanes on the page.
	 $('.scroll-pane').jScrollPane({showArrows:true, arrowSize:11, scrollbarWidth:11});
    
  
	//Hide (Collapse) the toggle containers on load
	//$(".toggle_container").hide();  

	//Switch the "Open" and "Close" state per click
	$("div.trigger").toggle(function(){
		$(this).addClass("active");
		$("h2.opener").css("background-position", "168px 0px");
		}, function () {
		$(this).removeClass("active");
		$("h2.opener").css("background-position", "-500px 0px");
	});
	
	//Slide up and down on click
	$("div.trigger").click(function(){
		$(this).next(".toggle_container").slideToggle("300");
	});
	
    // $(".portfolio").jCarouselLite({
    //     btnNext: ".next",
    //     btnPrev: ".prev",
    //     visible: 5,
    //     easing: "easeOutBack",
    //     scroll: 5,
    //     speed: 800
    // });
    // 
    $(".portfolio_featured").jCarouselLite({
        btnNext: ".next_featured",
        btnPrev: ".prev_featured",
        visible: 5,
        easing: "easeOutCirc",
        scroll: 5,
        speed: 800
    });	
    
    
	$(function() {
   		 setInterval( "slideSwitch()", 10000 );
	});
	

});

function slideSwitch() {
    var $active = $('#slideshow div.active');

    if ( $active.length == 0 ) $active = $('#slideshow div:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow div:first');

    $active.addClass('last-active')
		.animate({opacity : 0.0}, 1000);
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
        $active.removeClass('active last-active');
        });
}

	
