/* This library works in conjunction with the following
    ASPNETMediaPlayer needs to be added to the aspx page
    Use ClientScript.RegisterArrayDeclaration(AllAdditionalPlayersOnPage);
    Include on the players the function onclick='PlayPause(clientId, filePath);'
    Add to player (the image tag) the attribute playpause="play"
*/

    var ap;
    
    function pageLoad(){
        ap = new ASPNetMedia.Audio("mp");
    }
 
    function PlayPause(elemId, filePath){
        var btnplaypause = document.getElementById(elemId);
        if(btnplaypause != null){
            if (btnplaypause.attributes.playpause.value == 'play')
            {
                Play(btnplaypause, filePath);
            }
            else
            {
                Pause(btnplaypause);
            }
        }
    }
    
    function Play(btnplaypause, filePath){
        ResetPlayers();
        btnplaypause.src = "../graphics/2.0/btn-pause-text.png";
        btnplaypause.attributes.playpause.value = 'pause';
        ap.PlayMedia(filePath);
    }
    
    function Pause(btnplaypause){
        btnplaypause.src = "../graphics/2.0/btn-play-text.png";
        btnplaypause.attributes.playpause.value = 'play';
        ap.PauseMedia();
    }
    
    function ResetPlayers(){
        for(i=0;i<players.length;i++)
        {
            var player = document.getElementById(players[i]);
            if(player != null){
                Pause(player);
            }
        }
    }

