﻿/// <reference path="../../../../../../Skin/jquery-1.3.1-vsdoc.js" />


function cesvi_basket_add(item_ref, type, title, url) {    
    $.post(cesvi_modules_path + 'Services/Basket.aspx',
            { 'action': 'add', 'ref': item_ref, 'type': type, 'title': title, 'url': url },
            function(datas) {
                if (datas == "ok")
                    showBasketConfirm(title);
                else
                    alert('Une erreur est survenue lors de l\'ajout dans la ' + basketLabel + '.');
            });
}

$(function() {
    // fancybox    
    $('#cesvi_dialog_helper').fancybox(
        {
            overlayOpacity: 0.7,
            frameWidth: 300,
            frameHeight: 150,
            hideOnContentClick: false,
            zoomOpacity: false,
            zoomSpeedIn : 0,
            zoomSpeedOut: 0,
            zoomSpeedChange: 0
        }
    );
     
    // liens basket_add_dossier
    $('.basket_add_dossier')
              .each(function() {
                    var href = $(this).attr('href');
                    var title = $(this).attr('title');
                    $(this)
                    .click(function() { cesvi_basket_add('dossier_' + href + '_' + title , 4, title , href); })
                    .attr('href', 'javascript:void(0);')
                    .removeAttr('target');
              });
});

function showBasketConfirm(title) {

    $('#cesvi_dialog_container').html(
                      "<div class='cesvi_basket_dialog'>"
                    + "<h2><a href='" + basketUrl + "'>&raquo; Ma " + basketLabel + "</a></h2>"
                    + "<div class='content'>'<b>" + title + "</b>'<br/>a été ajouté dans votre " + basketLabel + "</div>"
                    + "<div class='footer'>"
                    +   "<a href='" + basketUrl + "'>Voir ma " + basketLabel + "</a> | "
                    +   "<a href='javascript:void(0);' onclick='$.fn.fancybox.close()'>Fermer cette fenêtre</a>"
                    + "</div></div>");
    $('#cesvi_dialog_helper').click();

}