﻿$(document).ready(function () {
    // Ready Begin.

    Debug.active = false;

    $(".gallerylist a").fancybox({
        'titleShow': false,
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'easingIn': 'easeOutBack',
        'easingOut': 'easeInBack'
    });

    /* From here */
    $(".bigslider #slide_content").cycle({
		fx: 'scrollHorz'
        , speed: 500
        , timeout: 6000
        , pause: 0
        , pager: '#slidepager'
        , pagerAnchorBuilder: pagerAnchorBuilder
        //,before: onBefore
    });

    $("#main #slide_content").cycle({
		fx: 'scrollHorz',
		speed: 500,
		timeout: 6000,
		pause: 1,
		next: '#main .next.navigator',
		prev: '#main .prev.navigator'
        //,before: onBefore
    });
/*
	var toggle = $('#toggle').click(function() {
		var paused = slideshow.is(':paused');
		slideshow.cycle(paused ? 'resume' : 'pause', true);
	});
*/
	$("div#play").hide();
	$("div#play").click(function() {
		$("#slide_content").cycle("resume");
		$(this).hide();
		$("div#pause").show();
	});

	$("div#pause").click(function() {
		$("#slide_content").cycle("pause");
		$(this).hide();
		$("div#play").show();
//		var paused = slideshow.is(':paused');
//		slideshow.cycle(paused ? 'resume' : 'pause', true);
	});

    $("#latestNewsTicker").cycle({
        fx: 'scrollUp'
        , speed: 500
        , timeout: 4000
    });

    function pagerAnchorBuilder(idx, 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.
});
