//swf informs FlashMusicCtrl user music on/off through these 2 functions
//FlashMusicCtrl user *MUST* define swfMusicOn() and swfMusicOff() functions
function FlashMusicCtrl(imghost, musicPath, music) {
  this.imghost = imghost;
  this.musicPath = musicPath;
  this.music = music 
  return this;
}
FlashMusicCtrl.prototype.setImghost = function(imghost) {
  this.imghost = imghost;
}
FlashMusicCtrl.prototype.setMusicPath = function(musicPath) {
  this.musicPath = musicPath;
}
FlashMusicCtrl.prototype.setMusic = function(music) {
  this.music = music;
}
FlashMusicCtrl.prototype.turnOnMusic = function() {
  this._talkToSwf('turnonmusic');
}
FlashMusicCtrl.prototype.turnOffMusic = function() {
  this._talkToSwf('turnoffmusic');
}
FlashMusicCtrl.prototype.noMusic = function() {
  this.music = 'nomusic';
  this._talkToSwf('nomusic');
}
FlashMusicCtrl.prototype.changeMusic = function(newMusic) {
  this.music = newMusic;
  if (newMusic == 'nomusic') {
    this.noMusic();
  } else {
    this._talkToSwf(this.imghost+this.musicPath+this.music);
  }
}
FlashMusicCtrl.prototype._talkToSwf = function(what) {
  //musicName: nomusic, turnonmusic, turnoffmusic or path to music
  //alert("what is " + what);
  theFlashShow = document.musicCtrl;
  theFlashShow.SetVariable("musicName", what);  
}
FlashMusicCtrl.prototype.getFlashHtml = function(khost, musicOn, ctrlColor) {
   var musicFullPath = this.music;
   if (this.music != 'nomusic') {
     musicFullPath = this.imghost + this.musicPath + this.music;
   }
   var musicCtrlColor = '';
   if ((typeof ctrlColor != "undefined") && (ctrlColor)) {
     musicCtrlColor = '&ctrlColor=' + ctrlColor; 
   }
   var showPath = this.imghost + '/product/swf/mp3Player.swf?DOMAINS=' + khost + '&musicOn=' + musicOn + '&MP3URL=' + musicFullPath + musicCtrlColor; 
   var strReturn = '<OBJECT ID="musicCtrl" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH=70 HEIGHT=21> <PARAM NAME="movie" VALUE="' + showPath + '"><PARAM NAME="wmode" VALUE="transparent"> <PARAM NAME="LOOP" VALUE="false"> <PARAM NAME="QUALITY" VALUE=high><EMBED name="musicCtrl" src="'+ showPath + '" quality=high swLiveConnect=true WIDTH=70 HEIGHT=21 SCALE="NOBORDER" WMODE="transparent" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED> </OBJECT>'
   return strReturn 
}
FlashMusicCtrl.prototype.createControl = function(divID, khost, musicOn, ctrlColor) {
  var e = document.getElementById(divID);
  e.innerHTML = this.getFlashHtml(khost, musicOn, ctrlColor);
}
