var baseURL;
var imgLocation;
var totalFolders;
var theArrow = new Image(5,5)
var thefolders = new Array();
//var startingChunk = 0; //this sets what directory you want the breadcrumbs to start from
var startingChunk; //this sets what directory you want the breadcrumbs to start from
			
function breadcrumbs(base_URL, img_Location, folderTotal, xmlArray, useDefault, startAt)
{	
			startingChunk = startAt
			baseURL = base_URL
			imgLocation = img_Location
			totalFolders = folderTotal
			theArrow.src = baseURL + imgLocation + "bCrumb_arrow.gif";
			theFolders = xmlArray
			sURL = new String;
			bits = new Object;
			var x = 0;
			var stop = 0;
			var output ="";
			sURL = location.href;
			sURL = sURL.slice(8,sURL.length);
			chunkStart = sURL.indexOf("/");
			sURL = sURL.slice(chunkStart+1,sURL.length);
			while(!stop){
				chunkStart = sURL.indexOf("/");
				if (chunkStart != -1){
					bits[x] = sURL.slice(0,chunkStart)
					sURL = sURL.slice(chunkStart+1,sURL.length);		
				}else{
					stop = 1;
				}
				x++;
			}
			var theURL;
			var theFolderTit;
			var theFolderDepth;
			for(var i in bits){	
				if(i > startingChunk){
					output += "<a href=\"";
					for(y=1;y<x-i;y++){//this sets the relative path to go to the folder's level
						output += "../";
						theFolderDepth = y;
					}					
					for(var z=0; z<=totalFolders-1; z++){	 //might need to lose -1 part***
						if(bits[i] == theFolders[z].name){				
							theFolderTit = theFolders[z].title;
							theURL = theFolders[z].theLink;	
						}
					}
					if(theFolderTit !=null){	//if folder is listed in array
						//output += bits[i]+ "/" + theURL + "\">" + theFolderTit + "</a>  >  ";	
						output += bits[i]+ "/" + theURL + "\" class='breadcrumb1'>" + theFolderTit + "</a>&nbsp;&nbsp;<img src='" + theArrow.src +"'>&nbsp;&nbsp;";			
						theFolderTit = null;		
					}
					else if (useDefault == "yes"){// if it isn't just use its folder name for title and link
						var the_substring = output.substring(0, output.length - (theFolderDepth*3)); //need to remove ../ occurances
						//alert("theFolderDepth: " + theFolderDepth + "\n\noutput: " + output + "\n\nsubstring: " + the_substring)
						output = the_substring;						
						output +=  "javascript:void(0)\" class='breadcrumb1'>" + bits[i] + "</a>&nbsp;&nbsp;<img src='" + theArrow.src +"'>&nbsp;&nbsp;";	
						//alert(output);
					}else{//default link
						//output += bits[i] + "/\">" + bits[i] + "</a>  >  ";						
						output += bits[i] + "/\" class='breadcrumb1'>" + bits[i] + "</a>&nbsp;&nbsp;<img src='" + theArrow.src +"'>&nbsp;&nbsp;";	
					}
			 }  
		}
	document.write(output + "<span class='breadcrumb_1'>" + document.title + "</span>");  
}