/*
 * Author: Florian Boegner
 */
$(document).ready(function() {

//slideshow
	$("#slideshow").css("overflow", "hidden");
    
    $("ul#slides").cycle({
        fx: 'fade',
		speed: 4000,
		delay:  4000,
    //    pause: 1,
        prev: '#prev',
        next: '#next'
    });
    
    $("#slideshow").hover(function() {
        $("ul#nav").fadeIn();
    },
        function() {
        $("ul#nav").fadeOut();
    });



// portfolio toggle h2

$('#portfolio h2').addClass('minus');

$('#portfolio h2.minus').click(function() {
  $(this).next('ul').slideToggle()
  $(this).removeClass('plus');
  $(this).addClass('minus');
});

//

$(function(){
    //Get our elements for faster access and set overlay width
    var div = $('.gal'),
                 ul = $('.gal ul'),
                 // unordered list's left margin
                 ulPadding = 15;

    //Get menu width
    var divWidth = div.width();

    //Remove scrollbars
    div.css({overflow: 'hidden'});

    //Find last image container
    var lastLi = ul.find('li:last-child');

    //When user move mouse over menu
    div.mousemove(function(e){

      //As images are loaded ul width increases,
      //so we recalculate it each time
      var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;

      var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
      div.scrollLeft(left);
    });
});


});

$(window).load(function () {
    $("#slideshow").fadeIn(3700);
});
