/**
* JAVASCRIPT - CLIENT
* The following javascript is specifically required by this client on top of the
* core Javascript tools available to all clients
**/

/**
* CMW - SHOW MONEYKINS TV
**/
var cmwTV = new function(){
    this.start = function(){
        var rand = new Date().getTime();
        var movieFrame = "<div id='tvProgram'><img src='/images/tv_front.jpg' width='430' height='320' alt='' style='background-color:green'/></div><img src='/images/tv.png' width='550' height='510' class='tvOverlay' /></div>";
        myPopup.open(movieFrame,'cmwTV',false);
        myFlash.get({
            flashvars:'vidlink='+id,
            width:"430",
            height:"320",
            movie:'/flash/moneykins-tv.swf?rand='+rand
        },'tvProgram');
    },
    this.channel = function(){



    }
    return false;
}

/**
* CMW - PLAY SOUND FILES
*/
var cmwSound = new function(){
    this.lastActive = null;
    this.play       = function(soundfile,destinationId){

        // Just stop if we clicked same item
        if(destinationId == this.lastActive){
            this.stopLast();
        } else {

            // Stop last if active
            this.stopLast();

            // Store active
            this.lastActive = destinationId;

            // Activate play button?
            if($("play_"+destinationId)){
                var pb = $("play_"+destinationId);
                pb.setProperty("src",pb.getProperty("src").replace(".png","_active.png"));
            }
            myFlash.get({
                flashvars:'audio='+soundfile,
                width:1,
                height:1,
                movie:'/core/flash/playmp3_hidden.swf?audio='+soundfile},
                destinationId
            );
        }
        return false;
    }

    this.stopLast = function(){
        if(this.lastActive != null){
            $(this.lastActive).setProperty("html","");
            $(this.lastActive).setProperty("title","");
            if($("play_"+this.lastActive)){
                $("play_"+this.lastActive).setProperty("src",$("play_"+this.lastActive).getProperty("src").replace("_active.","."));
            }
            this.lastActive = null;
        }
    }.bind(this)

}

