

function createMenu(ItemSelected)
{

	var ItemSelectedTrimmed = '';
	
	var EndofArray;
    var EndofArray = UseArray.length;


   // FOR CHILD TESTING
	var HasChildren = 0;
	var IsTopParent = 0;
	var IsSubParent = 0;
	
	var LASTCHILD = '';
	var LASTTOPPARENT = '';
	var LASTSUBPARENT = '';
	
	var ItemSelectedString = ItemSelected + '.';
	
	var ItemSelectedLength = ItemSelectedString.length;

    var slimending = '';
	var healthyending = '';
		
	
	// FOR SIBLING TESTING
	if (ItemSelected.length > 2) {
		ItemSelectedTrimmed = String(ItemSelected).substring(0,(ItemSelected.length-2));
	}

  if (EndofArray > 0) {
  // There is Array Data
  
		// ITERATION #1 OF ARRAY - DIRECT CHILD TEST
		for(fa=0;fa<EndofArray;fa++)
		{

			//IF TOP LEVEL
				if ((ItemSelected.length <= 2) && (UseArray[fa][1].length <= 2 )) {
				IsTopParent = 1;
				LASTTOPPARENT = UseArray[fa][1];
				}
				
				// IF A PARENT WITH CHILDREN
				if ((UseArray[fa][1].indexOf(ItemSelectedString) != -1) && ( (ItemSelectedLength+2) == UseArray[fa][1].length ) ) {
				HasChildren = 1;
				LASTCHILD = UseArray[fa][1];
				}
				
				// EVERYTHING ON THE SAME LEVEL IN CASE IT DOESNT HAVE CHILDREN
				if ((ItemSelected.length > 2) &&  ((ItemSelected.length) == UseArray[fa][1].length) &&  (UseArray[fa][1].indexOf(ItemSelectedTrimmed) != -1) ) {
				LASTSUBPARENT = UseArray[fa][1];
				}
			
				
		}
		// BACK #1

        if ((IsTopParent != 1) || (HasChildren != 1)) {
			IsSubParent = 1;
		}

        document.write('<table width="180" border="0" cellspacing="0" cellpadding="0">',
					   '<tr>',
					   '<td colspan="4" class="BlubxBluLnref"><a href="/education/"><span class="whiteBxTitle">Lean Education</span></a></td>',
					   '</tr>');

        // ITERATION #2 OF ARRAY - PAINT SELECTED PORTIONS OF ARRAY
		for(x=0;x<EndofArray;x++)
		{



		targetstring = '';
		stringToDraw = '';
		nwtoDraw = '';
		dopaint = 0;


            // STRING PROCESSING -----------

			if (UseArray[x][3] != '') {
				//Has a Target
				targetstring = ' target="'+UseArray[x][3]+'"';
			}
		
			if (ItemSelected == UseArray[x][1]) {
				// HIGHLIGHT THE SELECTED LEVEL
				stringToDraw = '<span class="GryText"><b>'+UseArray[x][0]+'</b></span>';
			} else {
				if (UseArray[x][3] == '_blank') {
				nwtoDraw = ' onclick="nw(\''+ UseArray[x][2]+'\');return false;"';
				} else if (UseArray[x][3] == '_support') {
				nwtoDraw = ' onclick="sw(\''+ UseArray[x][2]+'\');return false;"';
				}
				
				stringToDraw = '<a class="Link"' + nwtoDraw + ' href="'+ UseArray[x][2]+'"'+targetstring+'>'+UseArray[x][0]+'</a>';
			}

			// END STRING PROCESSING -----------

			if (HasChildren == 1) {
				
  				// Paint Just the Children if the item has children
				if ((UseArray[x][1].indexOf(ItemSelectedString) != -1) && ( (ItemSelectedLength+2) == UseArray[x][1].length ) ) 
				{
				  dopaint = 1;
				}

			} else {
				
				if ((ItemSelected.length <= 2) && (UseArray[x][1].length <= 2 )) {
				// A TRUE TOP LEVEL PARENT
				   dopaint = 1;
				} else if ((ItemSelected.length > 2) &&  ((ItemSelected.length) == UseArray[x][1].length) &&  (UseArray[x][1].indexOf(ItemSelectedTrimmed) != -1) ) {
				// SUB LEVEL, NO CHILDREN, PAINT SIBLINGS
				   dopaint = 1;
				}
				
			}

			    if (UseArray[x][4] != '') {
					sectionarrowString = '<img src="/images/arrow' + UseArray[x][4] + '.gif" width="7" height="11">';
				} else {
					sectionarrowString = '<img src="/images/blank.gif" width="7" height="11">';
				}
			

			    if (dopaint == 1) {
					
					document.write('<tr>');
					document.write('<td align="left" valign="top" class="WhtbxGry">');
					document.write(sectionarrowString);
					document.write('&#160;');
					document.write(stringToDraw);		
					document.write('</td>');
					document.write('</tr>');				
		
		      	  ////////// DRAW THE END SPACING
                   if ((IsTopParent == 1)  && (UseArray[x][1] == LASTTOPPARENT)) {
						// Slim ending for the last top parent that occurs anywhere in the array
						document.write(slimending);
				   } else if ((IsSubParent == 1)  && (UseArray[x][1] == LASTSUBPARENT)) {
						// Slim ending for the last subparent anywhere in the array
						document.write(slimending);
				   } else if ((HasChildren == 1)  && (UseArray[x][1] == LASTCHILD)) {
						// Slim ending for the last child anywhere in the array
						document.write(slimending);
				   } else { 
					    document.write(healthyending);
				   }
				   // END CHILDREN ENDING

				}
				// END DOPAINT IF
	
		}
		// BACK #2
		
	document.write('</table>');
   
   } 
   // END IF THERE IS ARRAY DATA
   
}
// END FUNCTION