// XSPF Player JavaScript Control
//
// By Michael Chaney, Michael Chaney Consulting Corporation
// Copyright 2006 Michael Chaney Consulting Corporation
//
// This code is released under the same BSD-style license as the XSPF Player.
// For more info: http://musicplayer.sourceforge.net/

var ie_5_or_6_window_int_timer = null;

function XSPFPlayer(mdiv, width, height, flash_file, title, song_url) {
	if (!flash_file) {
      flash_file='/flash/mp3player.swf';
      this.fixed=true;
   }
   if (!title) {
      title=' ';
   }
   if (!song_url) {
      song_url='/nada.mp3';
   }
	this.obj = new SWFObject(flash_file, "single", width, height, "7");
	this.div = mdiv;
	this.obj.addVariable('autoplay','false');
   this.obj.addParam("wmode","transparent");
   this.obj.addParam("menu","false");
	this.obj.addVariable('song_url', song_url);
	this.obj.addVariable('song_title', title);
	this.obj.write(this.div);
}

XSPFPlayer.prototype.play_song = function(title, song_url) {
	/* minor hack - if they try to play the same song again it'll stop
	 * instead. */
	if (this.obj.getVariable('song_url') == song_url) {
		this.stop();
		this.obj.addVariable('song_url', '');
		this.obj.addVariable('song_title', ' ');
		close_player();
	} else {
		this.obj.addVariable('autoplay','true');
		this.obj.addVariable('song_url', song_url);
		this.obj.addVariable('song_title', title);
		this.obj.write(this.div);
	}
}

XSPFPlayer.prototype.stop = function() {
	this.obj.addVariable('autoplay','');
	this.obj.write(this.div);
}

function close_player() {
  xspfplayer.stop();
}
