$(document).ready(function () {
	var song_list = jQuery("#the_song_list");
	if(song_list.length > 0) {
		var isDown = false;

		var progressBar = function (posX, posY, maxX, maxY) {
			var perc = (posX / maxX) * 100;

			if (posX >= 0 && posX <= maxX) {
				if (jQuery.soundManager.currentSound.playState !== 0) {
					jQuery.soundManager.setPosition(jQuery.soundManager.currentSound.sID, Math.round(jQuery.soundManager.current.endPosition * (perc / 100)));
				}
			}
		};

		$('#progress-bar').mousedown(function (e) {
			isDown = true;
			progressBar(e.pageX - this.offsetLeft, e.pageY - this.offsetTop, this.offsetWidth, this.offsetHeight);
		});

		$('#progress-bar').mouseup(function () {
			isDown = false;
		});

		$('#progress-bar').mousemove(function (e) {
			if (isDown) {
				progressBar(e.pageX - this.offsetLeft, e.pageY - this.offsetTop, this.offsetWidth, this.offsetHeight);
			}
		});


	}
});
