function downloadMp3(url) {
	window.open(url, 'mp3dl');
	return true;
}

function showItem(item) {
	$("div.item").hide();
	$("div#" + item).show();
}

function viewCart() {
	$("form#viewCart").submit();
}

function addToCart(formId) {
	$("form#"+formId)
}

function showSnocap() {
	window.open('snocap.cfm','snocap','height=305,width=430');
}

function donateSong(song, url) {
	window.open(url, 'mp3'+song);
	if (document.getElementById != null) {
		document.getElementById("itemNumber").value=song;
		document.donationForm.submit();
	}
	else {
		for (i=0; i < document.donationForm.elements.length; i++) {
			if (document.donationForm.elements[i].name == "item_number") {
				document.donationForm.elements[i].value = song;
				document.donationForm.submit();
			}
		}
	}
}

var scrollTimeout;

function scrollItems(amount) {
	var scrollHeight = $("div#scroll").height();
	var listHeight = $("ul#itemList").height();
	var maxScroll = scrollHeight - listHeight;
	if (maxScroll > 0) { maxScroll = 0; }
	var y = parseInt($("ul#itemList").css("top")) + amount;
	if (y < maxScroll) { y = maxScroll; }
	if (y > 0) { y = 0; }
	$("ul#itemList").css("top", y+'px');
	callback = 'scrollItems(' + amount + ')';
	scrollTimeout = setTimeout(callback, 60);
}

function stopScroll() {
	if (scrollTimeout) {
		clearTimeout(scrollTimeout);
		scrollTimeout = null;
	}
}
