﻿/// <reference path="~\Javascript\jquery-vsdoc.js"/>
var animationRunning = false;

function SetupBasket() {
    $(document).ready(function() {
        $("#TopBasket").hover(function() {
            if (!animationRunning) {
                animationRunning = true;
                $("#TopBasket").addClass("Open");
                if ($("#TopBasket").hasClass("Open")) {
                    ($("#TopBasket").css("z-index", "50"));
                    $(".basketdown").animate({ height: "show", opacity: "show" }, "slow", function() {
                        animationRunning = false;
                    });
                }
            }
        }, function() {
            //if (!animationRunning) {
            animationRunning = true;
            $(".basketdown").animate({ height: "hide", opacity: "hide" }, "slow", function() {
                animationRunning = false;
                $("#TopBasket").removeClass("Open");
            });
            //}
        });
    });
}

function showTopBasketWithTimeout() {
    if (!animationRunning) {
        $(".Alert").floating("", parseInt(($(window).height()/2)-50), 341).fadeIn("slow");
        $("#TopBasket").addClass("Open");
        if ($("#TopBasket").hasClass("Open")) {
            $("#ShowAlwaysBox").show("slow");
            $(".basketdown").animate({ height: "show", opacity: "show" }, "slow", function() {
                $(".topBasketTable").find("tr:nth-child(" + (parseInt($(".topBasketTable").find("tr").size()) - 2) + ")").find("td:gt(0)").animate({ backgroundColor: '' + bgcolor, color: "#FFF" }, "slow", function() {
                    $(this).animate({ backgroundColor: '#FFF', color: "#8a8a8a" }, "slow");
                });
                setTimeout(function() {
                    if ($("#TopBasket").hasClass("Open")) {
                        $(".basketdown").animate({ height: "hide", opacity: "hide" }, "slow", function() {
                            $("#TopBasket").removeClass("Open");
                            $(".Alert").hide("slow");
                        });
                    }
                }, 2000);
            });
        }
    }
}


