var songAjax = new function(){
	this.ajax = new Ajax();
	this.tim = null;
	this.timeout_time = 300000;
	
	this.getSonginfo = function() {

		var currentTime = new Date();
		currentTime = currentTime.getTime();

		songAjax.ajax.setMimetype="text/xml";
		songAjax.ajax.responseFormat="xml";
		songAjax.ajax.doGet("./getsongxml.php?"+currentTime, songAjax.finishRequest, "xml"); 
		songAjax.tim = setTimeout("songAjax.getSonginfo();", songAjax.timeout_time);

	};
	
	this.finishRequest = function (ajax_xml) {
		
		var xmlDom=ajax_xml;
		var root=xmlDom.documentElement;
		
		var songdiv = document.getElementById("songinfo");
		
		for(var i = 0;  i <root.childNodes.length; i++) {
			if(root.childNodes[i].nodeType == 1) {
				var thisSong = {};
				for(var j = 0; j < root.childNodes[i].childNodes.length; j++) {
					if(root.childNodes[i].childNodes[j].nodeType == 1) {
						if(root.childNodes[i].childNodes[j].childNodes.length > 0) 
							thisSong[root.childNodes[i].childNodes[j].nodeName] = root.childNodes[i].childNodes[j].firstChild.nodeValue;
						else 
							thisSong[root.childNodes[i].childNodes[j].nodeName] = "";;
					}
				}
				if (thisSong['type'] == 'Song')
				{
					songdiv.innerHTML = thisSong['title'] + '<br>' + thisSong['artist'];
				}
				else 
				{
					songdiv.innerHTML = thisSong['type'] + '<br>' + thisSong['title'];
				}
			}
		}

	};
}
