function CreateBreadcrumbs()
{
	var homeText = 'Home';
	
	var output = '';
	
	//get the url from the browser in lowercase
	var url = (window.location + '').toLowerCase();
	
	//get the root url (to base the links off of. This is also the url of the homeText anchor
	var rootUrl = url.substring(0, url.indexOf('pages/') + 6);
	//output the home link
	if (url.indexOf('franchise') != -1)
	{
		output = '<a href=\'' + rootUrl + 'franchise/default.aspx\'>' + Capitalize(homeText) + '</a>';

	}
	else
	{
		output = '<a href=\'' + rootUrl + 'default.aspx\'>' + Capitalize(homeText) + '</a>';

	}

	//get rid of everything after the .aspx and rootUrl from the original url giving us a clean pathSegment after the root
	var pathSegment = url.replace(url.substring(url.indexOf('.aspx')), '');
	var pathSegment = pathSegment.replace(rootUrl, '');
	
	//break up the remaining pieces of the url into an array
	var pathSegments = pathSegment.split('/');
	for (var i = 0; i < pathSegments.length; i++)
	{
		//if the pathSegment is not the last pathSegment, add an anchor tag. If the next pathSegment is 'default', we will automatically make this pathSegment last (we do not include default pathSegments as this is just the default page in a folder).
		if (i != pathSegments.length - 1 && pathSegments[i + 1] != 'default' && pathSegments[i] != 'franchise')
		{
			output = output + ' <span>\\</span> <a href=\'' + GetUrl(rootUrl, pathSegments[i]) + '\'>' + Capitalize(ReplaceDashesWithSpaces(pathSegments[i])) + '</a>';
		}
		//if the pathSegment IS the last pathSegment, just output the text with no anchor
    	else
    	{
    		if (pathSegments[i] != 'default' && pathSegments[i] != 'franchise')
    		{
    			output = output + ' <span>\\</span> ' + Capitalize(ReplaceDashesWithSpaces(pathSegments[i]));
    		}
    	}
    }
    
    return output;
}

function Capitalize(words)
{
    var newValue = '';
    value = words.split(' ');
    
    for(var c=0; c < value.length; c++)
    {
		newValue += value[c].substring(0, 1).toUpperCase() + value[c].substring(1, value[c].length) + ' ';
    }
    
   	return newValue ;
}

function ReplaceDashesWithSpaces(value)
{
	//replace all dashes in the value with spaces
	return value.replace(/-/g, ' ');
}

function GetUrl(rootUrl, pathSegment)
{
	//here we can add exceptions for redirecting certain pathSegments. Otherwise, go to default.aspx.

	return rootUrl + pathSegment + '/default.aspx';
}
