﻿/*Pour ajouter des concerts à l'horaire personnalisé*/
function addInMesConcerts(horaireId, loggedIn) {
    if (loggedIn == true) {
        mesConcertsServices.addToMyConcerts(horaireId, addConcertSuccess, addConcertFailed);
    }
    else {
        if (langue == "fr") {
            document.location.href = "/programmation/mes-concerts.aspx";
        }
        else {
            document.location.href = "/program/my-concerts.aspx";            
        }
    }
}

function addConcertSuccess(result, eventArgs) {
    if (!document.getElementById || !document.getElementsByTagName) return;

    var itemsCount = document.getElementById("hpCount");

    if (itemsCount != null)
        itemsCount.value = result;

//    var all_div = document.getElementsByTagName('div');

//    for (var i = 0; i < all_div.length; i++) {

//        var currentDiv = all_div[i];

//        if (currentDiv.className == "hp_status") {
//            if (eval(itemsCount.value) < 2) {
//                if (langue == "fr") {
//                    currentDiv.childNodes[0].innerHTML = "Votre horaire personnalisé <br />contient <strong>" + itemsCount.value + "</strong> item.";
//                }
//                else {
//                    currentDiv.childNodes[0].innerHTML = "There is <strong>" + itemsCount.value + "</strong> show in your personalized schedule.";
//                }
//            }
//            else {
//                if (langue == "fr") {
//                    currentDiv.childNodes[0].innerHTML = "Votre horaire personnalisé <br />contient <strong>" + itemsCount.value + "</strong> items.";
//                }
//                else {
//                    currentDiv.childNodes[0].innerHTML = "There is <strong>" + itemsCount.value + "</strong> shows in your personalized schedule.";
//                }
//            }
//        }
//    }
}

function addConcertFailed(error) {
    var errorMsg;

    if (langue == "fr") {
        errorMsg = "Une erreur s'est produite lors de l'ajout d'un concert dans votre liste personalisé : ";
    }
    else {
        errorMsg = "An error occured while saving a concert in tyour personalized schedule: ";
    }

    alert(errorMsg + error.get_message());
}

//Instruction pour Safari
if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded();
