$(document).ready(function() {
    if ($("#InspirationSplash").hasClass("none")) {
        $("#CaseInfo").addClass("closed");
    }
    if ($('#mycarousel').length > 0) {
        $('#mycarousel').jcarousel({
            buttonNextHTML: '<div class="jcarouselRight hand"></div>',
            buttonPrevHTML: '<div class="jcarouselLeft hand"></div>'
        });
    }

    /***** InspirationImage stuff **********/
    $("#InspirationImage").mouseover(function() {
        if ($("#InspirationSplash").hasClass("none")) {
            $(".hotspot").removeClass("none");
            $(".roomButton").removeClass("none");

        }
    });

    $("#InspirationImage").mouseout(function() {
        $(".hotspot").addClass("none");
        $(".roomButton").addClass("none");
    });

    $(".roomButton").mouseover(function() {
        if ($("#InspirationSplash").hasClass("none")) {
            $(this).addClass("orange");
        }
    });

    $(".roomButton").mouseout(function() {
        $(".roomButton").removeClass("orange");
    });

    $(".roomButton").click(function(e) {
        window.location = $(this).attr("url");
    });



    /********** HOTSPOTS ***********/
    $(".hotspot").mouseover(function(e) {
        $.post("/CorpSite/Units/hotspot.ashx", { id: $(this).attr("PageLinkId"), lang: $(this).attr("CurrentLanguage") }, function(response) {
            $("#InspirationRight").html(response);
        });
    });


    /************ OTHER CASES ******************/
    $("#CaseInfoTitle").click(function() {
        if ($("#InspirationSplash").hasClass("none")) {
            if ($("#CaseInfo").hasClass("closed")) {
                $("#CaseInfo").animate({
                    top: "201px", height: "102px"
                }, 700);
                $("#CaseInfo").toggleClass("closed");
            }
            else {
                $("#CaseInfo").animate({
                    top: "277px", height: "25px"
                }, 700);
                $("#CaseInfo").toggleClass("closed");
            }
        }
    });

    $("#CaseInfoTitle").mouseover(function() {
        if ($("#InspirationSplash").hasClass("none")) {
            $("#CaseInfoTitle").addClass("orange");
        }
    });

    $("#CaseInfoTitle").mouseout(function() {
        $("#CaseInfoTitle").removeClass("orange");
    });


    /***************** SPLASH SCREEN *************/
    $("#InspirationSplash a").click(function() {
        $("#InspirationSplash").addClass("none");
        $("#CaseInfo").addClass("block");
        $("#CaseInfo").addClass("closed");
    });



    /********** PREV & NEXT *************/
    $("#LeftSide").mouseover(function() {
        if ($("#InspirationSplash").hasClass("none")) {
            $("#hasPrev").removeClass("none");
        }
    });

    $("#LeftSide").mouseout(function() {
        $("#hasPrev").addClass("none");
    });

    $("#RightSide").mouseover(function() {
        if ($("#InspirationSplash").hasClass("none")) {
            $("#hasNext").removeClass("none");
        }
    });

    $("#RightSide").mouseout(function() {
        $("#hasNext").addClass("none");
    });

});

function sleep(naptime){
      //naptime = naptime * 1000;
      var sleeping = true;
      var now = new Date();
      var alarm;
      var startingMSeconds = now.getTime();
      //alert("starting nap at timestamp: " + startingMSeconds + "\nWill sleep for: " + naptime + " ms");
      while(sleeping){
         alarm = new Date();
         alarmMSeconds = alarm.getTime();
         if(alarmMSeconds - startingMSeconds > naptime){ sleeping = false; }
      }      
   }
 

            