﻿/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Justin Whitford | http://www.whitford.id.au/ */

function breadcrumbs() {
	sURL = new String;
	bits = new Object;
	bitsName = new Object;
	var x = 0;
	var stop = 0;
	var output = "<div class=topnav> ";

	sURL = location.href;
	
	//Remove http:// or https://
	sURL = sURL.slice(8, sURL.length);


	chunkStart = sURL.indexOf("/");

	sURL = sURL.slice(chunkStart + 1, sURL.length)

    //Get the bits of the url (between the single slashes)
	while (!stop) {
		chunkStart = sURL.indexOf("/");
		if (chunkStart != -1) {
		    bits[x] = sURL.slice(0, chunkStart)
		    bitsName[x] = sURL.slice(0, chunkStart)
		    
			sURL = sURL.slice(chunkStart + 1, sURL.length);
		} else {
			stop = 1;
		}
		x++;
	}


	for (var i in bits) {

	    if (bitsName[i] == "BSCF") {
	        output += "";
	    }
    

	    else {
	        output += "<a href=\"";


	        for (y = 1; y < x ; y++) {
	            output += "../";
	        }


	        if (bits[i] == "BSCF") {
	            bits[i] = bits[i] + "/index.aspx";
	        }

	        
	        if (bits[i] == "News") {
	            if (location.href.indexOf("localhost") != -1 ) {
	                bits[i] = "BSCF/News/AllNews.html";
	            }
	            else {bits[i] = "News/AllNews.html";}
	        }
	        if (bits[i] == "Letters") {
	            if (location.href.indexOf("localhost") != -1) {
	                bits[i] = "BSCF/Letters/AllLetters.html";
	            }
	            else { bits[i] = "Letters/AllLetters.html"; }
	        }

	        if (bits[i] == "2011") {
	            if (location.href.indexOf("localhost") != -1) {
	                bits[i] = "BSCF/Letters/AllLetters.html#11";
	            }
	            else { bits[i] = "Letters/AllLetters.html#11"; }
	        }

	        if (bits[i] == "2010") {
	            if (location.href.indexOf("localhost") != -1) {
	                bits[i] = "BSCF/Letters/AllLetters.html#10";
	            }
	            else { bits[i] = "Letters/AllLetters.html#10"; }
	        }

	        if (bits[i] == "2009") {
	            if (location.href.indexOf("localhost") != -1) {
	                bits[i] = "BSCF/Letters/AllLetters.html#09";
	            }
	            else { bits[i] = "Letters/AllLetters.html#09"; }
	        }
	        if (bits[i] == "2008") {
	            if (location.href.indexOf("localhost") != -1) {
	                bits[i] = "BSCF/Letters/AllLetters.html#08";
	            }
	            else { bits[i] = "Letters/AllLetters.html#08"; }
	        }
	        if (bits[i] == "2007") {
	            if (location.href.indexOf("localhost") != -1) {
	                bits[i] = "BSCF/Letters/AllLetters.html#07";
	            }
	            else { bits[i] = "Letters/AllLetters.html#07"; }
	        }
	        if (bits[i] == "2006") {
	            if (location.href.indexOf("localhost") != -1) {
	                bits[i] = "BSCF/Letters/AllLetters.html#06";
	            }
	            else { bits[i] = "Letters/AllLetters.html#06"; }
	        }
	        if (bits[i] == "2005") {
	            if (location.href.indexOf("localhost") != -1) {
	                bits[i] = "BSCF/Letters/AllLetters.html#05";
	            }
	            else { bits[i] = "Letters/AllLetters.html#05"; }
	        }

	        if (bits[i] == "CurreyAward") {
	            
	            bitsName[i] = "The Currey Award";
	            
	            if (location.href.indexOf("localhost") != -1) {
	                bits[i] = "BSCF/News/CurreyAward/curreyAward.html";
	            }
	            else { bits[i] = "News/CurreyAward/curreyAward.html"; }
	        }
	        
	        if (bits[i] == "AboutUs") {
	            if (location.href.indexOf("localhost") != -1) {
	                bits[i] = "BSCF/AboutUs/AboutUs.html";
	            }
	            else { bits[i] = "AboutUs/AboutUs.html";}
	        }

	        if (bits[i] == "ContactUs") {
	            if (location.href.indexOf("localhost") != -1) {
	                bits[i] = "BSCF/ContactUs/AllContacts.html";
	            }
	            else { bits[i] = "ContactUs/AllContacts.html"; }
	        }

	        if (bits[i] == "Calendar") {
	            if (location.href.indexOf("localhost") != -1) {
	                bits[i] = "BSCF/Calendar/calendarMain.html";
	            }
	            else { bits[i] = "Calendar/calendarMain.html"; }
	        }


	        if (bits[i] == "Links") {
	            if (location.href.indexOf("localhost") != -1) {
	                bits[i] = "BSCF/Links/AllLinks.html";
	            }
	            else { bits[i] = "Links/AllLinks.html";}
	        }

	        if (bits[i] == "Maps") {
	            if (location.href.indexOf("localhost") != -1) {
	                bits[i] = "BSCF/Maps/AllMaps.html";
	            }
	            else { bits[i] = "Maps/AllMaps.html";}
	        }

	        if (bits[i] == "Information") {
	            if (location.href.indexOf("localhost") != -1) {
	                bits[i] = "BSCF/Information/AllInfo.html";
	            }
	            else { bits[i] = "Information/AllInfo.html";}
	        }

	        for (y = 1; y < x - i; y++) {
	            output += "../";
	        }

	        if (bits[i] == "AboutUs") {
	            output += "About Us" + "\">" + bitsName[i] + "</a> > ";
	        }
	        else if (bits[i] == "ContactUs") {
	            output += "Contact Us" + "\">" + bitsName[i] + "</a> > ";
	        }

	        else if (bits[i] == "CurreyAward") {
	            output += "The Currey Award" + "\">" + bitsName[i] + "</a> > ";
	        }
	        
	        else {
	            output += bits[i] + "\">" + bitsName[i] + "</a> > ";
	        }

	    }

    }

    var docTitle = document.title;

    if (docTitle.indexOf("BSCF - ") != -1) {
        docTitle = document.title.substr(7);
    }

    if (output.indexOf(">AboutUs") != -1) {
        var newOutput = ">About Us";
        document.write(output.replace(">AboutUs", newOutput) + docTitle);
    }

    else if (output.indexOf(">ContactUs") != -1) {
        var newOutput = ">Contact Us";
        document.write(output.replace(">ContactUs", newOutput) + docTitle);
    }

    else if (output.indexOf("CurreyAward") != -1) {
        var newOutput = "The Currey Award - History and Winnersxxx";
        document.write(output.replace(">Currey Award", newOutput) + docTitle);
    }

    
    else {
        document.write(output + docTitle);
    }
    
	document.write("</div>");
}


