// FOR SITES WITH LANGUAGE SELECTIONS //


// 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()
	{
	// for working out language subfolder
	var langPath = location.href;
	var langFolder = "de";
	var langWords = langPath.split("/");
	
	if (langWords[3] !="de") {
		
		
			z = 0;
		}
	else {
		
	
		z = 1;
		
		}

		// 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('/');
		
		if (z==1) {
					
					urlSwap = "/de"
					homeSwap = "/de"
					}
				if (z==0) {
					
					urlSwap = ""
					homeSwap = "/"
					}
				
	

		// indentifying URL and creating it
		if(gtUrl)
		{
			// defining output of breadcrumb
			var gtOutput = '<ul><li><a href="' + homeSwap + '" target="_self">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 working out language subfolder
		
				
				
			
				
				
			
			for(var i = z; i < gtUrl.length - 1; i++)
			{
				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)
				
			
				if (trimmed01 == trimmed02) {
					gtOutput += '<li>' + gtTitle + '</li></ul>';
				} else if (i == gtUrl.length - 2) {
					gtOutput += '<li><a href="' + urlSwap + gtPath + 'index.asp' + '" target="_self">' + gtVpath + '</a></li>' + '<li>' + gtTitle + '</li></ul>';
				} else {
					gtOutput += '<li><a href="' + urlSwap + gtPath + 'index.asp' + '" target="_self">' + gtVpath + '</a></li>';
				}
			}								
			document.write(unescape(gtOutput));
		}
		
		
		
		
	}





