// Initalize vars
var xmlhttp;

// For non-IE
if (window.XMLHttpRequest) {
    xmlhttp = new XMLHttpRequest();
}

// For IE
else if (window.ActiveXObject) {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

// Get tracks for album
function get(url,bit)
{

	// If bit is on, show tracks
	if(bit == 'on')
	{
		// Get traks
		xmlhttp.open("GET", url, true);
		xmlhttp.onreadystatechange = function callback()
		{ 
			if(xmlhttp.readyState == 4)
			{
				// Get the key of the album from the URL
				var cdKey = url.substring(url.indexOf('?')+1,url.length);
				
				// Set the html code of the albums span tag to the tracks
				document.getElementById("album" + cdKey).innerHTML = xmlhttp.responseText;
			}
		};
		xmlhttp.send(null);
	}

	// Remove tracks
	else
	{
		var cdKey = url.substring(url.indexOf('?')+1,url.length);
		document.getElementById("album" + cdKey).innerHTML = "";
	}
}
