﻿$(document).ready(function () {
    // Ready Begin.

    Debug.active = false;

    $(".gallerylist a").fancybox({
        'titleShow': false,
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'easingIn': 'easeOutBack',
        'easingOut': 'easeInBack'
    }); 

    /* From here */
    $("#slide_content").cycle({
        fit: 1
        , fx: 'scrollHorz'
        , speed: 500
        , timeout: 6000
        , pause: 0
        , next: '#slide .next'
        , prev: '#slide .prev'
        , pager: '#slidepager'
        , pagerAnchorBuilder: pagerAnchorBuilder
        //,before: onBefore
    });

    $("#latestNewsTicker").cycle({
        fx: 'scrollUp'
        , speed: 500
        , timeout: 4000
    });

    function pagerAnchorBuilder(idx, slide) {
        Debug.log(idx); Debug.log(slide);
        //        var title = $(slide).attr("title");
        //        return '<span title="' + title + '">' + eval(idx + 1) + '</span>';
        return '<span>' + eval(idx + 1) + '</span>';
    }

    function onBefore(curr, next, opts, fwd) {
        placeNavigation();
        //get the height of the current slide
        var $ht = $(this).height();
        //set the container's height to that of the current slide
        //$(this).parent().animate("height", $ht);
        $(this).parent().animate({
            opacity: 1,
            height: $ht
        })
    }


    //jquery cycle slidecontrols placing
    function placeNavigation() {
        var navheight = $(".navigator").height();
        var sliderheight = $("#slide").height();

        Debug.log(navheight);
        Debug.log(sliderheight);

        var px = Math.floor(eval(sliderheight / 2 - (navheight / 2)));

        Debug.log(px);
        $(".navigator").css("top", px);

        //alert($("#slide").height());
    }

    placeNavigation();

    $('form.uniForm').uniform();
    $('form.uniForm').validate();



    // Ready End.
});
