function intro(){
	var intro      = document.getElementById('id_intro');
	var intro_link = document.getElementById('id_intro_link');
	if (intro.style.display == 'none'){
		intro.style.display = '';
		intro_link.innerHTML = 'What is the download store? (hide)';
	} else {
		intro.style.display = 'none';
		intro_link.innerHTML = 'What is the download store? (show)';
	}
}
function details(inNID){
	var item = document.getElementById('id_album_' + inNID + '_details');
	
	if (item.style.display == 'none'){
		item.style.display = '';
	} else {
		item.style.display = 'none';
	}
}
function clickit(inNID){
	var item      = document.getElementById('id_song_' + inNID);
	var item_row  = document.getElementById('id_song_row_' + inNID);
	var album     = document.getElementById('id_album_' + item.getAttribute('rel'));
	if (item.checked == true){
		item_row.style.backgroundColor = '#EDEADB';
	} else {
		item_row.style.backgroundColor = '';
	}
	if (album.checked == true){
		album.checked = false;
	}
}
function hover_on(inNID){
	var item     = document.getElementById('id_song_' + inNID);
	var item_row = document.getElementById('id_song_row_' + inNID);
	if (item.checked == false){
		item_row.style.backgroundColor = '#EDEADB';
	}
}
function hover_off(inNID){
	var item     = document.getElementById('id_song_' + inNID);
	var item_row = document.getElementById('id_song_row_' + inNID);
	if (item.checked == false){
		item_row.style.backgroundColor = '';
	}
}
function process_cart(){
	document.getElementById('id_submit').value    = 'Processing...';
	document.getElementById('id_submit').disabled = true;
	
	var cart = Array();
	var form = document.getElementById('cart');
	for ( var i=0; i < form.elements.length; i++ ) {
		if (form.elements[i].checked == true){
			cart.push(form.elements[i].value);
		}
	}
	if (!cart[0]){ alert ('You have not selected any music!'); return false; }
	cart = serialize(cart);
	
	// Make ajax call to process cart
	
	var ajaxURL = '/download/processCart.php?c=' + cart;
	doAjax(ajaxURL, 'processed_cart', true);
}
function processed_cart(inR){
	var info = inR.split('~~');
	document.getElementById('id_pp_custom').value        = info[0];
	document.getElementById('id_pp_amount').value        = info[1];
	document.getElementById('id_order_total').innerHTML  = info[1];
	document.getElementById('id_submit').style.display   = 'none';
	document.getElementById('id_checkout').style.display = '';
}
function buyalbum(inNID){
	var album = document.getElementById('id_album_' + inNID);
	var album_status = document.getElementById('id_album_' + inNID).checked;
	var form  = document.getElementById('cart');
	for ( var i=0; i < form.elements.length; i++ ) {
		if (form.elements[i].getAttribute('rel') == inNID && form.elements[i].checked == true){
			form.elements[i].click();
		}
	}
	
	if (album_status == false){
		album.checked = false;
	} else {
		album.checked = true;
	}
}