function addToBasket(iPID)
{
    oParam = {}
    oParam.action   = "AddToBasket";
    oParam.PID      = iPID;

    $.post('/modules/webshop/handle_basket.php', oParam, function(){$("#BasketContainer").css("display", "block")});

    return;   
}
function toggleSaveButton(iProductID, bDoDisplay, iDefaultAmount, e)
{
    if(e.keyCode == 13)
    {
        saveNewAmount(iProductID, iDefaultAmount);
    }
    else
    {
        var strDisplay = bDoDisplay ? "inline" : "none";

        $("#SaveButton_" + iProductID).css("display", strDisplay);
    }

    return;   
}
function saveNewAmount(iProductID, iDefaultAmount)
{
    var strValue =  $("#_amount_" + iProductID).val();

    if(IsNumeric(strValue))
    {
        if(strValue == 0)
        {
            if(confirm("Vil du slette dette produkt fra din indkøbskurv?"))
            {
                // delete
                document.basket.product_id.value = iProductID;
                document.basket.amount.value = strValue;
                document.basket.submit();
            }
            else
            {
                // Return to normal
                // Reset to default amount
                $("#_amount_" + iProductID).val(iDefaultAmount);
                $("#SaveButton_" + iProductID).css("display", "none");
            }
        }
        else
        {
            document.basket.product_id.value = iProductID;
            document.basket.amount.value = strValue;
            document.basket.submit();
        }
    }
    else
    {
        alert("Skriv venligst et helt tal");

        // Reset to default amount
        $("#_amount_" + iProductID).val(iDefaultAmount);
        $("#SaveButton_" + iProductID).css("display", "none");
    }
    return;
}
function removeButton(iProductID)
{
    $("#SaveButton_" + iProductID).css("display", "none");

    return;   
}
function IsNumeric(sText)
{
    var ValidChars = "0123456789";
    var IsNumber=true;
    var Char;

 
    for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
        Char = sText.charAt(i); 
        if (ValidChars.indexOf(Char) == -1) 
        {
            IsNumber = false;
        }
    }

    return IsNumber;   
}
$().ready(function() {

    $(".anythingSlider").anythingSlider({
        easing: "swing",                 // Anything other than "linear" or "swing" requires the easing plugin
        autoPlay: false,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
        delay: 3000,                     // How long between slide transitions in AutoPlay mode
        startStopped: false,             // If autoPlay is on, this can force it to start stopped
        animationTime: 600,              // How long the slide transition takes
        hashTags: false,                 // Should links change the hashtag in the URL?
        buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
        pauseOnHover: true               // If true, and autoPlay is enabled, the show will pause on hover
      });

      return;
});
