/*
	Original code found @ http://www.evolt.org/article/Breadcrumbs_in_Javascript/17/15480 by Justin Whitford
	Modified to make it Web Accessible and meet UW Standards by Affan Javed
*/

function breadcrumbs() {
	URL = new String;
	docTitle = new String;
    section = new Object;
    var x = 0;
    var stop = false;
    var output = "<a href=\"/\">ZOMEL-Home</a> > ";

    URL = location.href;
    URL = URL.substring(8,URL.length); 				// gets rid of http:// or https://
    slash = URL.indexOf("/");						// gets rid of www.___.com/
    URL = URL.substring(slash+1,URL.length);		// saves the actual path

    while (!stop) {
    	slash = URL.indexOf("/");					// finds next '/'
      	if (slash != -1) {
        	section[x] = URL.substring(0,slash);	// stores the directory name in a array
	        URL = URL.substring(slash+1,URL.length);// finds next '/'
    	} else {
        	stop = true;
        }
      	x++;
    }
	
    for (var i in section) {
    	output += "<a href=\"";						// makes link of each directory
      	
		for (y=1;y<x-i;y++) {
        	output += "../";						// makes first one jump the least and the last one the most up the directory
      	}

	  	theWord = new String;						// to capitalize the first letter [of directories]
		firstLetter = new String;
	    theWord = section[i];
		firstLetter = theWord.substring(0,1).toUpperCase();
		theWord = theWord.substring(1);
		
		output += section[i] + "/\">" + firstLetter + theWord + "</a> > ";
    }
	
	docTitle = document.title;						// crops the title and saves the part before the first pipe if exists
	if (docTitle.indexOf(">") != -1) {
		docTitle = docTitle.substring(0,docTitle.indexOf(">"));
	}
	
	
    document.write(output + docTitle);				// print on document where the function is called
}

