// trim function to remove white space at front and back of a string.
String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}


function breadcrumb()
	{

		// Get title of current page
		var gtTitle = document.title;
		var gtControl = '/';

		// get absolute URL
		var gtGetUrl = escape(location.pathname.indexOf('?') != -1) ? location.pathname.substring(0, location.pathname.indexOf('?')) : location.pathname;
		gtGetUrl = (location.pathname.charAt(0) == '/') ? location.pathname.substring(1) : location.pathname;
		var gtUrl = gtGetUrl.split('/');
	     
		// indentifying URL and creating it
		if(gtUrl)
		{
			// defining output of breadcrumb
//			var gtOutput = '<ul><li><a href="/" target="_self">Advertising home</a></li> ';
            var gtOutput = '';
            
            
            if (gtGetUrl.indexOf('grantthorntondecisions')>-1)
            {
	            gtOutput = '<ul><li><a href="/grantthorntondecisions/" target="_self">Advertising home</a></li> ';
            }
            else
            {
	            gtOutput = '<ul><li><a href="/" target="_self">Advertising home</a></li> ';
            }
			
			// for controlling sub-sites where the / isn't the root
			

			var gtPath = '' + gtControl;
	
			// looping through folders
			// i = 0 for site root, i= 1 for folder within site
			for(var i = 0; i < gtUrl.length - 1; i++)
			{
				
				if ((gtUrl[i] == "gtiorg") || (gtUrl[i] == "grantthorntondecisions"))
				{
					gtPath += gtUrl[i] + '/';		
					continue;
				}				
				
				gtPath += gtUrl[i] + '/';		
				
				//gtOutput += '<li><a href="' + gtPath + '"';
				var gtVpath = '';
				var gtVurl = '/';
				gtVurl = gtUrl[i].split('-');
				if(gtVurl)
				{
					for(var n= 0; n < gtVurl.length; n++)
					{
						gtVpath += gtVurl[n] + ' ';
					}
				}
			
				var trimmed01 = new String(gtVpath);
				var trimmed02 = new String(gtTitle);
				// trim it!
				trimmed01 = trimmed01.trim();
				trimmed02 = trimmed02.trim();

				//if (trimmed01 == trimmed02) {
				
				//}

				//if (i == gtUrl.length - 2)
				
				var bPath = location.href;
				
			
			/*	if(bPath.indexOf('Who-should-run-my-business')>-1 || bPath.indexOf('Where-can-I-be-somebody')>-1 || bPath.indexOf('Who-shuts-down')>-1) {
				
					gtOutput += '<li>' + gtTitle + '</li></ul>';
					
					} else {
			*/			
				
				if (trimmed01.replace("?","") == trimmed02.replace("?","")) {
					
					gtOutput += '<li>' + gtTitle + '</li></ul>';
				} else if (i == gtUrl.length - 2) {
					
					gtOutput += '<li><a href="' + gtPath + 'index.asp' + '" target="_self">' + gtVpath + '</a></li>' + '<li>' + gtTitle + '</li></ul>';
				} else {
					
					gtOutput += '<li><a href="' + gtPath + 'index.asp' + '" target="_self">' + gtVpath + '</a></li>';
				}
			//}				
			}
			document.write(unescape(gtOutput));
		}
	}





