﻿
function validation(obj) {
    if (obj.checked)
        hasProduct = hasProduct + 1;
    else
        hasProduct = hasProduct - 1;
}

function check() {
    if (hasProduct <= 0)
        alert('Vous devez sélectionner au moins un DVD');
}

function ManageBasket(theCheckBox, displayName, price) {
    var theString;
    if (hasProduct > 1)
        theString = 'Vous avez sélectionné ' + hasProduct + ' DVDs';
    else
        theString = 'Vous avez sélectionné ' + hasProduct + ' DVD';
    
    if (theCheckBox != null && theCheckBox.checked) {
        listDvd = listDvd + '<br/> - ' + displayName;
        totalPrice = totalPrice + price;
    }
    else {
        listDvd = listDvd.replace('<br/> - ' + displayName, '');
        totalPrice = totalPrice - price;
    }
    if (hasProduct > 0) {
        totalString = 'Pour un total de : ' + Math.round(totalPrice * 100.0) / 100.0 + ' €';
    }
    else {
        totalString = '';
        totalPrice = 0.0;
    }
    if (document.getElementById) {
        document.getElementById('selection').innerHTML = theString;
        document.getElementById('Total').innerHTML = totalString;
        document.getElementById('dvds').innerHTML = listDvd;
    }
    else if (document.all) {
        document.all['selection'].innerHTML = theString;
        document.all['Total'].innerHTML = totalString;
        document.all['dvds'].innerHTML = listDvd;
    }
    if (totalString.length > 0)
        setVisibility('Total', true);
    else
        setVisibility('Total', false);
    
    if (listDvd.length > 0)
        setVisibility('dvds', true);
    else
        setVisibility('dvds', false);
}
