
$(function() {
    
    //overstates
    $(".menuoverstate").each(function(i) {

        preload_image = new Image();
        preload_image.src = this.src.replace(".jpg", "_o.jpg");

        $(this).hover(
            function() {
                if (this.src.indexOf("_o.jpg") == -1) {
                    this.src = this.src.replace(".jpg", "_o.jpg");
                }

            },

            function() {
                this.src = this.src.replace("_o.jpg", ".jpg");

            });

        });
    
    //navigation
            
        $("#nav").lavaLamp({
            fx: "backout", 
            speed: 700,
            click: function(event, menuItem) {
            return true;
            }
        });
        
    //scroll to top
        $('a.top').click(function(){
        $.scrollTo( 0, 500);
        return false;
        });
        
    //slideshow
    $('#slideshow-inner').cycle({
	fx:     'scrollHorz', 
        prev:   '#prev', 
        next:   '#next',
        timeout: 15000,
        easing:  'backinout'
    });
    
    
    //gallery overstates
    $(".gallery-image img").css({opacity: 0.9});
    
    $(".gallery-image img").hover(
        function() {
            $(this).stop().animate({opacity: 1.0}, 200);
        },
        function() {
            $(this).stop().animate({opacity: 0.9}, 200);
    });
    
    //fancybox
    $("a.popup-image").fancybox({
	'titleShow': false
        });
        
});