	function killDupes(arr)
	{
   		var result=new Array();
    	var lastValue="";

	    for (var i=0; i<arr.length; i++)
	    {
  			var curValue=arr[i];
  			if (curValue != lastValue)
  			{
				result[result.length] = curValue;
  			}
  			lastValue=curValue;
    	}
		
	    return result;
	}
   
	function addContent(str)
	{
		percArray[percCounter]=str;
		percCounter++;
	}
	
	function loadcomposers()
	{
		var tempcomparray = new Array();

		for(i=0;i < percArray.length;i++)
		{
			var temparray = percArray[i].split(seper);
			tempcomparray[i] = temparray[3] + ", " + temparray[4];
		}
			
		tempcomparray.sort();
			
		tempcomparray = killDupes(tempcomparray);

		var mySelect = document.getElementById('composer');
		if(!mySelect){return;}	

		for(i=0;i < tempcomparray.length;i++) 
		{
			mySelect.options[i] = new Option(tempcomparray[i], tempcomparray[i]);
		}							
	}

	function loadworks(o)
	{			
		var temptitlearray = new Array();
		var titlecount = 0;
		idArray = [];

		for(i=0;i < percArray.length;i++)
		{
			var temparray = percArray[i].split(seper);
			
			if(temparray[3] + ", " + temparray[4] == o.options[o.selectedIndex].value)	
			{	
				temptitlearray[titlecount] = temparray[1];
				titlecount++;
				idArray[temparray[1]] = temparray[0];
			}
		}
			
		temptitlearray.sort();	

		var mySelect = document.getElementById('works');
		if(!mySelect){return;}	

		mySelect.options.length = 0;

		for(i=0;i < (temptitlearray.length);i++) 
		{
			mySelect.options[i] = new Option(temptitlearray[i], temptitlearray[i]);
		}							
			
		var mySelect2 = document.getElementById('percdata');
		mySelect2.value = "- Select a work";
		
		idCounter = titlecount;
	}

	function loadpercdata(d)
	{							
		var percID = 0;
		var recordstring = "";
		
		for(i in idArray)
		{
			if(i == d.options[d.selectedIndex].value)
			{	
				percID = idArray[i];
			}
		}				
		
		for(i=0;i < percArray.length;i++)
		{
			var temparray = percArray[i].split(seper);
			
			if(temparray[0] == percID)
			{	
				recordstring = temparray[4] + " " + temparray[3] + ": " + temparray[1] + " (" + temparray[2] + ")\n\n" +
								"Number of percussionist(s): " + temparray[7] + "\nNumber of timpanist(s): " + temparray[8] + "\n\n" +
								"Percussion Orchestration:\n" + temparray[5] + "\n\n" +
								"Percussion Instrumentation:\n" + temparray[6] + "\n\n" +
								"Notes:\n" + temparray[9];
			}
		}
		
		var mySelect2 = document.getElementById('percdata');
		if(!mySelect2){return;}	
			
		mySelect2.value = recordstring;
	}
