
var musicPlayerJSObject = new Object();


function musicplayerPlay(url, title, artist)
{
    jQuery("#musicPlayerFlash").get(0).SetVariable("player:jsStop", 1);
    jQuery("#musicPlayerFlash").get(0).SetVariable("player:jsUrl", url);
    jQuery("#musicPlayerFlash").get(0).SetVariable("player:jsArtist", artist);
    jQuery("#musicPlayerFlash").get(0).SetVariable("player:jsTitle",title);
    jQuery("#musicPlayerFlash").get(0).SetVariable("player:jsPlay", 1);
    jQuery('#musicplayerbutton').show();
    jQuery('#musicplayerimage').show();
}

// Function called by Pause Button
function musicplayerPause() 
{
    if (musicPlayerJSObject.isPlaying == "true"){
        jQuery("#musicPlayerFlash").get(0).SetVariable("player:jsPause", 1);
    }else{
        jQuery("#musicPlayerFlash").get(0).SetVariable("player:jsPlay", 1);
    }
}
/**
 * Initialize
 */
musicPlayerJSObject.onInit = function()
{
    //alert("mylist init called");
    this.cPlaying="false";
    this.isStopped=0;
    this.isPaused=0;
};
/**
 * Update
 */
musicPlayerJSObject.onUpdate = function(){
    var isPlaying = this.isPlaying;
    if (isPlaying != this.cPlaying){
        if ((isPlaying == "false") && (this.isPaused=="false")){
            // Player stopped
            playerStopped();
            this.cPlaying="false";
        }else if ((isPlaying == "true") && (this.cPlaying=="false")){
            // Player started
            playerPlaying();
            this.cPlaying="true";
        }
    }
    /**
     * public functions
     */
    function playerPlaying() {
        jQuery('#musicplayerbutton').show();
        jQuery('#musicplayerimage').show();
    }
    function playerStopped() {
        jQuery('#musicplayerbutton').hide();
        jQuery('#musicplayerimage').hide();
    }
};

