
function embedPlayer(pathNum, paths, loop) { 
   // Get Operating System 
   
   //first clear the player of any pre-existing sound
   
   var isWin = navigator.userAgent.toLowerCase().indexOf("windows") != -1;
   if (isWin) { // Use MIME type application/x-mplayer2
      visitorOS="Windows";
   } else { // Use MIME type audio/mpeg, audio/x-wav, etc.
      visitorOS="Other";
   }

   var audioURL= paths[pathNum];
   var objTypeTag = "application/x-mplayer2"; 
   if (visitorOS != "Windows") { objTypeTag = "audio/mpeg"};  
 
 var newDiv;
 var oldDiv;
 var playerParent;
  
theHTML =  "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='245' height='20' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' > <param name='movie' value='mp3playersmall.swf' /> <param name='flashvars' value='file=" + audioURL + "&autostart=false' /> <embed src='mp3playersmall.swf' width='245' height='20' flashvars='file=" + audioURL + "&autostart=false'  type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /> </object>";

  
playerParent = document.getElementById("sndMenuBox");
oldDiv = document.getElementById("player");
playerParent.removeChild(oldDiv);

newDiv = document.createElement('div');
newDiv.setAttribute('id', "player");
newDiv.innerHTML = theHTML;


playerParent.appendChild(newDiv);
 
};


function switchSnd (pathNum, paths, loop) { 

	var audioURL= paths[pathNum];

//	document.getElementById("sndPluginQT").autoplay = true;
//	document.getElementById("sndPluginWin").autostart = 1;



   
};


///the sounds must be stored in a variable called "sndList"

function makeSndMenu(divToWrite, nameArray, pathArray) {
	
	var menuHTML = "<ul id='sndList'>";
	
	for (i=0; i < nameArray.length; i++) {
	
		menuHTML = menuHTML + "<li> <a href='javascript:selectSnd("+ i + ")'>" + nameArray[i] + "</a> </li>";
	
	}
	
	menuHTML = menuHTML + "</ul>";
	
	document.getElementById(divToWrite).innerHTML = menuHTML;
	

};

swapBk = function(index) {

	listIndex=0;
	
	navRoot = document.getElementById("sndList");
	for (i=0; i<navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i];


		if ( node.nodeName=="LI" ) {
			
		
			if (listIndex == index) {
	
				node.style.background = "#666666";
			}
			else {
				node.style.background = "transparent";
			};
			
			listIndex++;
		
		};
	};
	
};

function selectSnd (index) {
	embedPlayer(index, sndPaths, true);
	swapBk(index);


};

function initSnd () {
	embedPlayer(0, sndPaths, true);
	swapBk(0);
	
};