﻿$(document).ready(function () {
    // Ready Begin.

    /* From here */

    Debug.active = false;

    var obj = $(".gallerylist a");
    if (obj.length > 0) {
        obj.fancybox({
            'titleShow': false,
            'transitionIn': 'elastic',
            'transitionOut': 'elastic',
            'easingIn': 'easeOutBack',
            'easingOut': 'easeInBack'
        });
    }

    var obj = $("#slide_content");
    if (obj.length > 0) {
    obj.cycle({
        fit: 1
        , fx: 'scrollHorz'
        , speed: 500
        , timeout: 6000
        , pause: 0
        , next: '#slide .next'
        , prev: '#slide .prev'
        , pager: '#slidepager'
        , pagerAnchorBuilder: pagerAnchorBuilder
        //,before: onBefore
    });
    }

    var obj = $("#latestNewsTicker");
    if (obj.length > 0) {
    obj.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.
});
