/**getlinks.js (v 1.0) * copyright and purchase enquiries - www.alistairwhiteley.co.uk */

function displayLinks(letter) {

	var searchItem = letter;

	var x= 0;
	var y= linkArray2.length; // length of links array
	var linktext = ""; // variable for new link text
	document.getElementById('linkdiv').innerHTML = ""; // clear existing link div text
	var counter = 0; // counter to check for number of occurrences of letters
	var position = 0;
	
	for (x=0; x<y; x++) 
	{ 	
		if (linkArray2[x].indexOf(searchItem)!=-1) {
			
			
			// find the first occurance of the item to return only names beginning with the name and not multiple words 
			position = linkArray2[x].indexOf('>');
			position = position + 1; // sets the position to be the first letter of the hyperlink name text
			
			if (linkArray2[x].charAt(position) == searchItem)
			
				{
			
				counter = counter+1;
				linktext = linkArray2[x] + "<br/>";
				//document.write(linkArray2[x] + "<br/>");
				document.getElementById('linkdiv').innerHTML = document.getElementById('linkdiv').innerHTML + linktext;
				
				}
			
			}
			

	} 
	
	if (counter == 0) {
					
		document.getElementById('linkdiv').innerHTML = "Recipes (" + letter +") - None found"; 
																						   
	}
}
