﻿
   


function PositionEditButtons() {
  
    $(".positionable").each(
        function (index, element) {

            var parentElement = $("#" + $(element).attr("data-ajax-parentContainer") + "");

            var position = "";

            if ($(element).attr("data_ajax_horizontal") != null) {
                position = $(element).attr("data_ajax_horizontal")
            }
            else {
                position = "right"
            }

            position += " top"
            $(element).position({
                    my: position,
                    at: position,
                    of: parentElement,
                    collision: "none"
                });
        });
        }

$(document).ready(function () {
    window.onresize = PositionEditButtons;
});

$(document).ready(function () {
    PositionEditButtons();
});

function EditSuccess() {
    PositionEditButtons();
}



$(document).ready(function () {

    var images = new Array();
    if (images.length > 1) {
        Animate(3000, 4000, images, "Img1", "Img2");
    }

});



function AnimateImage(slideshowSpeed, slideshowTransitionSpeed, images, activeImg, inActiveImg, activeImgIndex) {
    activeImgIndex++;

    if (activeImgIndex >= images.length) {
        activeImgIndex = 0;
    }

    document.getElementById(inActiveImg).src = images[activeImgIndex];

    $("#" + activeImg).animate({
        opacity: 0
    }, slideshowTransitionSpeed, function () {
        document.getElementById(activeImg).src = "";
    });

    $("#" + inActiveImg).animate({
        opacity: 1
    }, slideshowTransitionSpeed, function () {

      
        window.setTimeout(
        function () {
            AnimateImage(slideshowSpeed, slideshowTransitionSpeed, images, inActiveImg, activeImg, activeImgIndex);
        }, slideshowSpeed);
    });
}

function Animate(slideshowSpeed, slideshowTransitionSpeed, images, img1Name, img2Name) {

    var imageObj = new Image();

    for (i = 0; i < images.length; i++) {
        imageObj.src = images[i];
    }

    window.setTimeout(
    function () {

        AnimateImage(slideshowSpeed, slideshowTransitionSpeed, images, img1Name, img2Name, 0);

    }, slideshowSpeed);
}

