var objSongXML;

function loadSongXMLDoc(url, callbackFunction, desc, QUERY_STRING) 
{
	if(desc) window.status = desc;
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        objSongXML = new XMLHttpRequest();
		objSongXML.onreadystatechange =	function()
									{
										// only if req shows "complete"
										if (objSongXML.readyState == 4) {
											eval(callbackFunction);
										}
									}
		if(QUERY_STRING)
		{
		    objSongXML.open("POST", url, true);
			objSongXML.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			objSongXML.send(QUERY_STRING);
		}
        else
        {
	        objSongXML.open("GET", url, true);
	        objSongXML.send(null);
	    }
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        objSongXML = new ActiveXObject("Microsoft.XMLHTTP");
        if (objSongXML) {
        	objSongXML.onreadystatechange =	function()
										{
											// only if req shows "complete"
											if (objSongXML.readyState == 4) {
												eval(callbackFunction);
											}
										}
			if(QUERY_STRING)
			{
			    objSongXML.open("POST", url, true);
				objSongXML.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				objSongXML.send(QUERY_STRING);
			}
			else
			{
			    objSongXML.open("GET", url, true);
			    objSongXML.send(null);
			}
        }
    }
}

function getSong() 
{
	var c = objSongXML.responseXML.getElementsByTagName('s').length;
	if(c)
	{
		var HTML = '', si, so, at, sn;
		nl = 'http://nhacso.net'
		//Show Album
		HTML += '<Table border=0 cellspacing=1 cellpadding=2 width="100%">';
		for(var i=0; i<c; i++)	
		{
			with(objSongXML.responseXML.getElementsByTagName('s').item(i))
			{
				si = getAttribute('si');	
				so = getAttribute('so');	
				at = getAttribute('at');	
				sn = getAttribute('sn');						
			}

			HTML += '<tr bgcolor="#F1F1F1"><td colspan=2><a href="javascript:openPlayer(\'/user/nhacsolink/songlisten.asp?SongID=' + si + '\', 108, 320)" class="clsAlbumLink"><b>' + so + '</b></a></td></tr>';
			HTML += '<tr><td width="60%" class="clsSinger">Ca s&#297;: <b>' + sn + '</b></td><td width="40%" class="clsSinger" nowrap>S&#225;ng t&#225;c: <b>' + at + '</b></td></tr>';
		}		
		HTML += '</Table>';
		document.getElementById("divSong").innerHTML = HTML;					
	}	
}

function showSong(input)
{
	url  = '/user/NhacsoLink/SongList.Asp?SongID=' + escape(input);
	loadSongXMLDoc(url, 'getSong()', 'Loading all song ...');
}
