// JavaScript Document
function loadsong(theTitle) {
 var thePath = "../jukebox/tunes/" + theTitle;
  
  //setting playing info text (theTitle)
  var theG = theTitle.substring(0,theTitle.indexOf('/'));
  var theS = theTitle.substring(theTitle.indexOf('/')+1,theTitle.lastIndexOf('.'));
 document.getElementById("groupinfo").firstChild.replaceData(0, document.getElementById("groupinfo").firstChild.nodeValue.length, theG);
 document.getElementById("songinfo").firstChild.replaceData(0, document.getElementById("songinfo").firstChild.nodeValue.length, theS);

  // object creation
  var myObj = document.getElementById("player");

  // delete object first
  var elems = myObj.childNodes.length;
  for(var cnt=0; cnt<elems; cnt++) {
  	myObj.removeChild(myObj.childNodes[cnt]);
  }
  
  //create new object
	var newObj = document.createElement("object");
	newObj.setAttribute("data","../jukebox/immp3plainbg.swf");
	newObj.setAttribute("width","110");
	newObj.setAttribute("height","36");
	newObj.setAttribute("style","vertical-align: center;");
	newObj.setAttribute("type","application/x-shockwave-flash");

    //create parameters
	var p1 = document.createElement("param");
	p1.setAttribute("name","type");
	p1.setAttribute("value","application/x-shockwave-flash");
	newObj.appendChild(p1);
	
	var p2 = document.createElement("param");
	p2.setAttribute("name","FlashVars");
	p2.setAttribute("value","TheSound="+thePath+"&MyColor=45787A");
	newObj.appendChild(p2);

	var p3 = document.createElement("param");
	p3.setAttribute("name","allowScriptAccess");
	p3.setAttribute("value","sameDomain");
	newObj.appendChild(p3);
	
	var p4 = document.createElement("param");
	p4.setAttribute("name","movie");
	p4.setAttribute("value","immp3.swf");
	newObj.appendChild(p4);

	var p5 = document.createElement("param");
	p5.setAttribute("name","loop");
	p5.setAttribute("value","false");
	newObj.appendChild(p5);
	
	var p6 = document.createElement("param");
	p6.setAttribute("name","quality");
	p6.setAttribute("value","high");
	newObj.appendChild(p6);
	
	var p7 = document.createElement("param");
	p7.setAttribute("name","bgcolor");
	p7.setAttribute("value","#000000");
	newObj.appendChild(p7);
	
	var p8 = document.createElement("a");
	p8.setAttribute("href",theTitle);
	p8text = document.createTextNode(theTitle);
	p8.appendChild(p8text);
	newObj.appendChild(p8);

	myObj.appendChild(newObj);
}

