$(document).ready(function()
{
    init_lazy_load();
});

//===========================
//- Images
//===========================

function init_lazy_load()
{
    $("img.lazy_load_image").lazyload({ placeholder : "/images/loading_image.gif" });
}

//===========================
//- MP3 player
//===========================

function play_preview(artists, trackName, previewPath)
{
    $('#mp3_player').flashembed(
    {
        src: '/flash/player/preview.swf',
        wMode: 'transparent',
        allowFullScreen: false,
        allowScriptAccess: 'always',
        bgColor: '#fff',
        width: 200,
        height: 40,
        cacheBusting: true
    },
    {
        componentWidth: 200,
        componentHeight: 40,
        pathToFiles: '',
        xmlPath: '/flash/player/settings.xml',
        artistName: artists,
        songName: trackName,
        songURL: previewPath
    });
}

//===========================
//- Cart
//===========================

function add_to_cart(product_id, type)
{
    $.ajax(
    {
        type: "POST",
        url: '/cart/add',
        dataType: 'script',
        data:
        {
            product_id: product_id,
            product_type: type
        },
        success: function(data)
        {

        }
    });
}

function remove_from_cart(product_id, type)
{
    $.ajax(
    {
        type: "POST",
        url: '/cart/remove',
        dataType: 'script',
        data:
        {
            product_id: product_id,
            product_type: type
        },
        success: function(data)
        {

        }
    });
}

function increase_quantity(product_id, type)
{
    $.ajax(
    {
        type: "POST",
        url: '/cart/increase_quantity',
        dataType: 'script',
        data:
        {
            product_id: product_id,
            product_type: type
        },
        success: function(data)
        {

        }
    });
}

function decrease_quantity(product_id, type)
{
    $.ajax(
    {
        type: "POST",
        url: '/cart/decrease_quantity',
        dataType: 'script',
        data:
        {
            product_id: product_id,
            product_type: type
        },
        success: function(data)
        {

        }
    });

}

function change_delivery(delivery_method_id)
{
    $.ajax(
    {
        type: "POST",
        url: '/cart/set_delivery',
        dataType: 'script',
        data:
        {
            delivery_method_id: delivery_method_id
        },
        success: function(data)
        {

        }
    });
}
        function toggle_tracks(id)
        {
            $('#' + id).toggle();
        }