﻿var mousemovedout = true;
$(document).ready(function() {
    $('a.viewMultiple').hover(function(e) {
        mousemovedout = false;
        showMultiScenePreview($(this));
    }, //next is the hover-out function.
    function() {
        mousemovedout = true;
        $('#multiscenePreview').hide();
        //just hide because fading out seems to cause problems when moving quickly between hover-able elements.
    });

    $('#multiscenePreview').mousemove(function(e) {
        showMultiScenePreview($(this));
    });

    GetAutoRecoverList();
});

function GetAutoRecoverList() {
    $.ajax({
        async: true,
        type: "POST",
        data: "{}",
        url: "AjaxWebServices/AutoRecoverAjax.asmx/GetAutoRecoverList",
        contentType: "application/json; charset=utf-8",
        success: function(msg) {
            if (msg != null && msg.length > 0) {
                var h = JSON.parse(msg)

                if (h.d.length > 0) {
                    $("body").append(h.d);

                    var ulWidth = 0;
                    $(".scroll li").each(function() {
                        ulWidth += parseInt($(this).css("width")) + parseInt($(this).css("margin-left")) + parseInt($(this).css("margin-right"));
                    });
                    $(".scroll ul").width(ulWidth);
                    makeModalDialog("#savedRecoveryContainer", null);
                    if ($.browser.msie == true && parseInt($.browser.version) < 7) {
                        window.scrollBy(0, 2); //ie 6 fix!
                        setTimeout("adjustModalDialogPosition('#savedRecoveryContainer');$('#savedRecoveryContainer').show();", 2000)

                    }
                    $("myScroll").children().each(function() {
                           $(this).css("width", "");
                    });

                }
            }
        },
        error: function(msg) {
            var errText = msg; //allows Firebug to set breakpoint
        }
    });
}

function removeAutoSaves(e) {
    $.ajax({
        async: true,
        type: "POST",
        data: "{}",
        url: "AjaxWebServices/AutoRecoverAjax.asmx/RemoveAutoSaves",
        contentType: "application/json; charset=utf-8"
    });
    closeRecoveryDialog(e);
}

function closeRecoveryDialog(e) {
    closeModalDialog('#savedRecoveryContainer');
}

