// 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) {
	this.obj = new SWFObject("/flash/mp3player.swf", "single", width, height, "7");
	this.div = mdiv;
	this.obj.addVariable('autoplay','');
   this.obj.addParam("wmode","transparent");
   this.obj.addParam("menu","false");
	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', '');
		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);
		if (ie_version>0 && ie_version<7) {
			if (!ie_5_or_6_window_int_timer) {
				function move_box() {
					var offset = 10; // set offset (likely equal to your css top)
					var el= document.getElementById('popup-player');
					if (el) {
						el.style.top = (document.documentElement.scrollTop + offset) + 'px';
					}
				}

				ie_5_or_6_window_int_timer = window.setInterval(move_box, 500);
			}
		}
	}
}

XSPFPlayer.prototype.stop = function() {
	this.obj.addVariable('autoplay','');
	this.obj.write(this.div);
	if (ie_5_or_6_window_int_timer) {
		window.clearInterval(ie_5_or_6_window_int_timer);
		ie_5_or_6_window_int_timer = null;
	}
}
