/**
 * Created by JetBrains PhpStorm.
 * User: christoph.rath@rsk.com
 * Date: 25.11.11
 * Time: 17:47
 * To change this template use File | Settings | File Templates.
 */
$(document).ready(function(){
    $("#clients-items .item").hover(
        function () {
            $(this).css({backgroundPosition:'0 -165px'});
        },
        function () {
            $(this).css({backgroundPosition:'0 0'});
        }
    );

    // PARALLAX HORIZONTAL
    // $('.parallax').jparallax({mouseActiveOutside: true});

    $('#parallax .parallax-layer')
        .parallax({
            mouseport:$('#parallax')
        });

    $('#parallax2 .parallax-layer')
        .parallax({
            mouseport:$('#parallax2-mouseport')
        });

    $('#parallax3 .parallax-layer')
        .parallax({
            mouseport:$('#parallax3')
        });
    /* new parallax */
    $('ul#parallax-profil li').parallax({
        mouseport:$('#parallax-profil-mouseport')
    });

    $('ul#parallax-clients li').parallax({
        mouseport:$('#parallax-clients-mouseport')
    });

    $('ul#parallax-showcases li').parallax({
        mouseport:$('#parallax-showcases-mouseport')
    });

    $('ul#parallax-solutions1 li').parallax({
        mouseport:$('#parallax-solutions1-mouseport')
    });

    $('ul#parallax-solutions2 li').parallax({
        mouseport:$('#parallax-solutions2-mouseport')
    });

    $('ul#parallax-solutions3 li').parallax({
        mouseport:$('#parallax-solutions3-mouseport')
    });

    $('ul#parallax-kontakt li').parallax({
        mouseport:$('#parallax-kontakt-mouseport')
    });
    /* Intro X-mas */
    $('ul#parallax-intro-xmas li').parallax({
        xtravel:'10%',
        mouseport:$('#parallax-intro-xmas-mouseport'),
        yparallax:false,
        mouseResponse:true,
        mouseActiveOutside:true,
        xorigin:'left'

    });
    /* Intro stratic */
    $('ul#parallax-intro-stratic li').parallax({
        xtravel:'10%',
        mouseport:$('#parallax-intro-stratic-mouseport'),
        yparallax:false,
        mouseResponse:true,
        mouseActiveOutside:true,
        xorigin:'left'

    });
    /* Intro nissanapp */
    $('ul#parallax-intro-nissanapp li').parallax({
        xtravel:'10%',
        mouseport:$('#parallax-intro-nissanapp-mouseport'),
        yparallax:false,
        mouseResponse:true,
        mouseActiveOutside:true,
        xorigin:'left'

    });

  
    // MENU CLICKS
    $('a.nav-item, a.back_to_top_btn').click(function(e) {
        e.preventDefault();
        var targetID = $(this).attr('href');
        var posY = $('#'+targetID).offset().top;
        $('html, body').animate({scrollTop: posY - 130}, 2100, 'easeInOutExpo');
    })

    // SLIDESHOW
    // initialize scrollable together with the navigator plugin
    $(".slideshow").scrollable({ easing: 'easeInOutExpo', speed: 1200, circular: true }).navigator();

    /*$("#clients-items a.item").not('cloned').attr('rel', 'clients-gallery').fancybox({
        'titleShow':false,
        'transitionIn':'fade',
        'transitionOut':'fade',
        'speedIn':1000,
        'speedOut':1000,
        'changeFade':'fast',
        'changeSpeed':0,
        'autoDimensions':'true',
        'width':960,
        'height':600,
        'cyclic':'false',
        'type':'ajax',
        'centerOnScroll':'true',
        'showNavArrows':'false',
        ajax:{
            type:"POST",
            url:$(this).attr('href')
        }
    });*/
    $("#showcases-items a.item").not('cloned').attr('rel', 'showcases-gallery').fancybox({
        'titleShow':'false',
        'overlayColor' : '#fff',
        'overlayOpacity' : 0.9,
        'transitionIn':'fade',
        'transitionOut':'fade',
        'speedIn':1000,
        'speedOut':1000,
        'changeFade':'fast',
        'changeSpeed':0,
        'autoDimensions':'true',
        'width':960,
        'height':600,
        'cyclic':'false',
        'type':'ajax',
        'centerOnScroll':'true',
        'showNavArrows':'false',
        'ajax':{
            type : "POST",
            url  : $(this).attr('href')
        },
        'onComplete':function() {
            if ($(".client-content .navi-container").length != 0) {
                $(".client-content .slideshow").scrollable({ easing: 'easeOutExpo', speed: 1000, circular: true }).navigator();
            }
        }
    });
    $("#solutions a.more").attr('rel', 'solutions-gallery').fancybox({
        'titleShow':'false',
        'overlayColor':'#fff',
        'overlayOpacity':0.9,
        'transitionIn':'fade',
        'transitionOut':'fade',
        'speedIn':1000,
        'speedOut':1000,
        'changeFade':'fast',
        'changeSpeed':0,
        'autoDimensions':'true',
        'width':960,
        'height':600,
        'cyclic':'false',
        'type':'ajax',
        'centerOnScroll':'true',
        'showNavArrows':'false',
        'ajax':{
            type:"POST",
            url:$(this).attr('href')
        },
        'onComplete':function () {
            if ($(".client-content .navi-container").length != 0) {
                $(".client-content .slideshow").scrollable({ easing:'easeOutExpo', speed:1000, circular:true }).navigator();
            }
        }
    });
    $("a.imprint").fancybox({
        'titleShow':false,
        'overlayColor':'#fff',
        'overlayOpacity':0.9,
        'transitionIn':'fade',
        'transitionOut':'fade',
        'speedIn':1000,
        'speedOut':1000,
        'changeFade':'fast',
        'changeSpeed':0,
        'autoDimensions':'true',
        'width':960,
        'height':600,
        'cyclic':'false',
        'centerOnScroll' : 'true',
        'type':'ajax',
        'showNavArrows':'false',
        'ajax':{
            type:"POST",
            url:$(this).attr('href')
        }
    });
    $("a.contact").fancybox({
            'titleShow':false,
            'overlayColor':'#fff',
            'overlayOpacity':0.9,
            'transitionIn':'fade',
            'transitionOut':'fade',
            'speedIn':1000,
            'speedOut':1000,
            'changeFade':'fast',
            'changeSpeed':0,
            'autoDimensions':'true',
            'width':960,
            'height':600,
            'cyclic':'false',
            'centerOnScroll' : 'true',
            'type':'ajax',
            'showNavArrows':'false',
            'ajax':{
                type:"POST",
                url:$(this).attr('href')
            }
        });


    // MENU OPEN/CLOSE
    $("div.nav").hover(function () {
        // stop animation in case of hover during animation
        $(this).stop();
        // hide menuswitch & topmenu in case it was visible
        $('a.menuswitch, ul.topmenu', this).hide();

        // let nav-bar grow
        $(this).animate({height:"139"}, {
            duration:200,
            easing:'easeInOutSine',
            complete:function () {
                // show menu when animation ready
                $('ul.topmenu', this).css({'display':'block', 'opacity':0}).animate({'opacity':1}, 200);
            }
        });
    }, function () {
        // stop animation in case of hover during animation
        $(this).stop();
        // hide menu
        $('ul.topmenu', this).hide();
        $(this).animate({height:"60"}, 100, function () {
            // show menuswitch when animation ready
            $('a.menuswitch', this).show();
        });
    });

    // HOVERBAR
    $('div.hoverbar span.hover-title').hide();

    $('div.hoverbar').hover(function () {
        $('.hover-title', this).css({
            'display':'block',
            'height':0,
            'opacity':0
        }).animate({
            'opacity':1,
            'height':'22px'
            }, {
            'easing':'easeOutSine',
            'duration':100
            });
    }, function () {
        $('.hover-title', this).animate({
            'height':0,
            'opacity':0
        }, {
            'easing':'easeOutSine',
            'duration':100
        });
    });

});
