// JavaScript Document
Array.prototype.contains = function(obj) {
  var i = this.length;
  while (i--) {
    if (this[i] === obj) {
      return true;
    }
  }
  return false;
}

function breadcrumbs(){
	//Define the list of parts of the url you don't want to see in the breadcrumb
	var optionalParts = new Array("soth","m.soth");
    sURL = new String;
    bits = new Object;
    bits_stripped = new Object;
	bitsreplaced = new Object;
    var x = 0;
    var stop = 0;
    var output = "<div class=table_yah>&nbsp;&nbsp;You are here: <A HREF=../indexfront.html>Home</A> &raquo; ";

    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)
			/*UNDER SCORE REPLACED WITH  A SPACE*/
			bits_stripped[x] = bits[x].replace("_"," ")
			/*DIRECTORY NAME REPLACED WITH SOMETHING ELSE, NEED TO DEFINE ALL THE POSSIBLE OPTIONS*/
			if(bits[x] == '1ip')
				bitsreplaced[x] = "Individual Counselling & Psychotherapy";
			else if(bits[x] == '2sv')
				bitsreplaced[x] = "Supervision for Practitioners";
			else if(bits[x] == '3tr')
				bitsreplaced[x] = "Training for Practitioners";				
			else if(bits[x] == '4fa')
				bitsreplaced[x] = "Group Facilitation &amp; Facilitation Training";			
			else if(bits[x] == '5or')
				bitsreplaced[x] = "Organisational Development &amp; Consultancy";			
			else if(bits[x] == '6wr')
				bitsreplaced[x] = "Writing, Presentations &amp; Publications";
			else
				bitsreplaced[x] = bits[x];
				
			/*bitsreplaced can now be used when creating the breadcrum link*/	
			
			sURL = sURL.slice(chunkStart+1,sURL.length);
		 
      }else{
        stop = 1;
      }
      x++;
    }

    for(var i in bits){
		//check if the part should be added to the breadcrumb
		if(optionalParts.contains(bits[i])) continue;
      output += "<A HREF=\"";
      for(y=1;y<x-i;y++){
        output += "../";
      }
	  /*IF YOU NEED A REPLACEABLE TITLE, THEN USE bitsreaplced[i], 
	  IF YOU NEED TITLE WITH UNDERSCORE REAPLCED, USE bits_stripped[i] 
	  IF YOU NEED TITLE WITH SAME NAME AS THE DIRECTORY THEN USE bits[i]*/
      output += bits[i] + "/\">" + bitsreplaced[i] + "</A> &raquo; ";
    }
    document.write(output + document.title);
	document.write("</div>");
  }
