﻿$(document).ready(function() {
    // ----- ADMIN STYLING FOR APPLICATION [applies class to edit panel]
    $('*:header>span').each(function() {
        if ($(this).children("input").length > "0") {
            $(this).attr('class', 'editable_panel');
        }
    });
    $('.left-column span').each(function() {
        if ($(this).children("input").length > "0") {
            $(this).attr('class', 'editable_panel');
        }
    });
    $('.right-column span').each(function() {
        if ($(this).children("input").length > "0") {
            $(this).attr('class', 'editable_panel');
        }
    });
    // ---- SLIDE SHOW
    var count = 0; 
    var duration = 5000; 
    function slide() {
        if(count == "2") {
            reset();
        } else {
            $('.slide-show').animate(
                {marginLeft: '-=449px'}, 500);
//                .animate({marginLeft: '+=40px'}, 100).animate(
//                {marginLeft: '-=40px'}, 80).animate(  
//                {marginLeft: '+=15px'}, 80).animate(
//                {marginLeft: '-=15px'}, 59).animate(  
//                {marginLeft: '+=5px'}, 20).animate(
//                {marginLeft: '-=5px'}, 10);
            count++;
            setTimeout(function() { slide(count) }, duration);
        }
    }
    function reset() {
        if($('.looper').length > 0 ) {
        } else {
            var cloneLast = $('.slide-show').children('li:last').clone();
            $('.slide-show').prepend(cloneLast);
            $(cloneLast).attr('class', 'looper');
        }
        $('.slide-show').css('margin-left', '0px');
        count = -1;
        setTimeout(function() { slide(count) }, duration / 2);
    }
    setTimeout(function() { slide() }, 4000);
});
