// Functions to support the JS external interface to the tinyplayer Flash app

function getMovieObject(movieName)
{
    var movieObj;
    if (navigator.appName.indexOf("Internet Explorer") != -1)
    {
        movieObj = window[movieName];
    }
    else if (navigator.vendor.indexOf("Apple") != -1)
    {
        movieObj = document[movieName];
    }
    else
    {
        movieObj = document.embeds[movieName];
    }
    return movieObj;
}
 
function soundPause()
{
    getMovieObject("tinyplayer").tinyplayerSoundPause();
    writeMuteCookie();
}

function soundResume()
{
    getMovieObject("tinyplayer").tinyplayerSoundResume();
    deleteMuteCookie();
}

function soundToggle()
{
    getMovieObject("tinyplayer").tinyplayerSoundToggle();
    if (readMuteCookie())
    {
        deleteMuteCookie();
    }
    else
    {
        writeMuteCookie();
    }
}

function soundStop()
{
    getMovieObject("tinyplayer").tinyplayerSoundStop();
    writeMuteCookie();
}

function soundStart()
{
    getMovieObject("tinyplayer").tinyplayerSoundStart();
    deleteMuteCookie();
}

function soundPlayItem(num)
{
    getMovieObject("tinyplayer").tinyplayerSoundPlayItem(num);
    deleteMuteCookie();
}

function soundPlayNext()
{
    getMovieObject("tinyplayer").tinyplayerSoundPlayNext();
    deleteMuteCookie();
}

function soundPlayPrev()
{
    getMovieObject("tinyplayer").tinyplayerSoundPlayPrev();
    deleteMuteCookie();
}

function soundSetVolume(num)
{
    getMovieObject("tinyplayer").tinyplayerSoundSetVolume(num);
}

function soundRaiseVolume()
{
    getMovieObject("tinyplayer").tinyplayerSoundRaiseVolume();
}

function soundLowerVolume()
{
    getMovieObject("tinyplayer").tinyplayerSoundLowerVolume();
}

function soundStarting()
{
    if (readMuteCookie())
    {
        soundStop();
    }
}
