﻿var totalSlides = 0;
var currentSlide = 1;
var contentSlides = "";

var moveForward = true;

$(document).ready(function () {
    if ($("#page").hasClass("gallery")) {
        //var totalWidth = 0;
        //contentSlides = $(".slideshow-content");
        //contentSlides.each(function (i) {
        //    totalWidth += this.clientWidth;
        //    totalSlides++;
        //});
        //console.log("Total number of slides: " + totalSlides);
        //$("#slideshow-holder").width(totalWidth);
        //$("#slideshow-scroller").attr({ scrollLeft: 0 });

        //setInterval(function () { runSlideShow() }, 6000);
        // Load the classic theme
        //$('#gallery img:first').addClass('active');
        //Galleria.loadTheme('/Scripts/galleria/themes/classic/galleria.classic.min.js');
        // Initialize Galleria
        //getGallery();
        $("#gallery").show();

        Galleria.loadTheme('/Scripts/galleria/themes/classic/galleria.classic.min.js');
        galleria();
        Galleria.ready(function () {
            this.bind('idle_enter', function (e) {
                this.play();
            });
        });

    }

    Cufon.replace('nav a', {
        hover: true
    });
    Cufon.replace('nav ul ul a', {
        hover: true
    });
    Cufon.replace('h1');
    //Cufon.replace('#main h3');
    Cufon.replace('button');
    Cufon.replace('.free-quote');

    $('nav ul ul a.active').parents('ul').show();
});

//function runSlideShow() {

//    console.log("Slide show starting");
//    //  moveForward
//    if (currentSlide == totalSlides) {
//        currentSlide = totalSlides--;
//        moveForward = false;
//        //console.log("Slide moving back");
//    }
//    else if (currentSlide == 1) {
//        moveForward = true;
//        currentSlide++
//        //console.log("Slide moving forward");
//    }
//    else {
//        if (moveForward) {
//            currentSlide++
//            //console.log("Slide moving forward");
//        }
//        else {
//            currentSlide--;
//            //console.log("Slide moving back");
//        }
//    }

//    $('#photoControl' + currentSlide).click();

//}

//function showSlide(position) {

//    currentSlide = position;
//    updateContentHolder();
//    updateButtons(position);
//}

//function updateContentHolder() {
//    var scrollAmount = 0;
//    var contentWidth = 0;
//    contentSlides.each(function (i) {
//        if (currentSlide - 1 > i) {
//            scrollAmount += this.clientWidth;
//        }
//        contentWidth += this.clientWidth;
//    });

//    $("#slideshow-holder").width(contentWidth);
//    $("#slideshow-scroller").animate({ scrollLeft: scrollAmount }, 800);
//}

//function updateButtons(position) {

//    galleryControls = $(".gallerycontrol");
//    galleryControls.each(function (i) {

//        if (i == (position - 1)) {
//            $(this).attr("src", "/Content/Images/Selected.png");
//        }
//        else {
//            $(this).attr("src", "/Content/Images/Unselected.png");
//        }
//    });
//}



function galleria() {
    $(".gallery-container").galleria({
        width: 740,
        autoplay: true,
        height: 327,
        showImagenav: false,
        showCounter: false,
        showInfo: false,
        thumbnails: "empty"
    });
};

