$(function(){

    // ***
    // Scrolling background
    // ***

    // height of background image in pixels
    var backgroundheight = 4000;

    // get the current minute/hour of the day
    var now = new Date();
    var hour = now.getHours();
    var minute = now.getMinutes();

    // work out how far through the day we are as a percentage - e.g. 6pm = 75%
    var hourpercent = hour / 24 * 100;
    var minutepercent = minute / 30 / 24 * 100;
    var percentofday = Math.round(hourpercent + minutepercent);

    // calculate which pixel row to start graphic from based on how far through the day we are
    var offset = backgroundheight / 100 * percentofday;

    // graphic starts at approx 6am, so adjust offset by 1/4
    var offset = offset - (backgroundheight / 1);

    function scrollbackground() {
        // decrease the offset by 1, or if its less than 1 increase it by the background height minus 1
        offset = (offset < 1) ? offset + (backgroundheight - 1) : offset - 1;
        // apply the background position
        $('body').css("background-position", "50% " + offset + "px");
        // call self to continue animation
        setTimeout(function() {
            scrollbackground();
            }, 300
        );
    }

    // Start the animation
    //scrollbackground();
});



$(document).ready(function(){

    // Effet sur les miniatures de la mini-galerie
    $("#mini-galerie img").css('opacity','0.7');
    $("#mini-galerie img").mouseover(function() {$(this).animate({opacity:1}, 50);});
    $("#mini-galerie img").mouseout(function() {$(this).animate({opacity:0.7}, 500);});

    // Effet sur les miniatures du portfolio
    $("#portfolio img").css('opacity','0.9');
    $("#portfolio img").mouseover(function() {$(this).animate({opacity:1}, 50);});
    $("#portfolio img").mouseout(function() {$(this).animate({opacity:0.7}, 500);});




            $("a[rel^='prettyPhoto']").prettyPhoto({
                animationSpeed: 'fast', /* fast/slow/normal */
                padding: 40, /* padding for each side of the picture */
                opacity: 0.60, /* Value betwee 0 and 1 */
                showTitle: false, /* true/false */
                allowresize: false, /* true/false */
                counter_separator_label: ' sur ', /* The separator for the gallery counter 1 "of" 2 */
                theme: 'dark_square', /* light_rounded / dark_rounded / light_square / dark_square */
                hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
                modal: false, /* If set to true, only the close button will close the window */
                changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
                callback: function(){} /* Called when prettyPhoto is closed */
            });




    // transition effect
    style = 'easeOutQuart';
    // if the mouse hover the image
    $('.capture').hover(
        function() {
            //display heading and caption
            $(this).children('div:first').stop(false,true).animate({top:0},{duration:200, easing: style});
            $(this).children('div:last').stop(false,true).animate({bottom:0},{duration:200, easing: style});
        },
        function() {
            //hide heading and caption
            $(this).children('div:first').stop(false,true).animate({top:-70},{duration:200, easing: style});
            $(this).children('div:last').stop(false,true).animate({bottom:-70},{duration:200, easing: style});
        }
    );



});


/**
Vertigo Tip by www.vertigo-project.com
Requires jQuery
*/

this.vtip = function() {
    this.xOffset = -70; // x distance from mouse
    this.yOffset = 20; // y distance from mouse

    $(".vtip").unbind().hover(
        function(e) {
            this.t = this.title;
            this.title = '';
            this.top = (e.pageY + yOffset); this.left = (e.pageX + xOffset);
            $('body').append( '<p id="vtip">' + this.t + '</p>' );
            $('p#vtip').css("top", this.top+"px").css("left", this.left+"px").fadeIn("slow");
        },
        function() {
            this.title = this.t;
            $("p#vtip").fadeOut("slow").remove();
        }
    ).mousemove(
        function(e) {
            this.top = (e.pageY + yOffset);
            this.left = (e.pageX + xOffset);
            $("p#vtip").css("top", this.top+"px").css("left", this.left+"px");
        }
    );
};
jQuery(document).ready(function($){vtip();})
