var cookie_information = new Array();
var currloc = location.toString();
var subloc = currloc.substring(currloc.indexOf("/")+2);
var firstone = "no";


function navarray(){
    if (document.cookie == '') { 
    
	var  x = location.toString();
	x = x.substring(x.indexOf("/")+2);
	var cookiedough = "location0:"+x+":title0:"+crumbTitle; 
	document.cookie= "navCookie=" + escape(cookiedough);
	firstone = "yes";
	} else {
	return false;		
  }
}


navarray();

var arraycount = 0;

function readTheCookie(the_info){

	var the_cookie = document.cookie;
	var the_cookie = unescape(the_cookie);

	var broken_cookie = the_cookie.split("=");
	var the_values = broken_cookie[1];

	var separated_values = the_values.split(",");

	var property_value = "";
	for (var loop = 0; loop < separated_values.length; loop++){
		property_value = separated_values[loop];
		var broken_info = property_value.split(":");
		var the_property = broken_info[0];
		var the_value = broken_info[1];
		var  the_property2 = broken_info[2];
		var  the_value2 = broken_info[3];
		if (firstone == "yes"){
		     the_info[the_property] = the_value;
		     the_info[the_property2] = the_value2;
		     arraycount = arraycount + 1;
		}else{

		     if (subloc != the_value){
		         the_info[the_property] = the_value;
		         the_info[the_property2] = the_value2;
		         arraycount = arraycount + 1;

		      }else{
			     if (loop == 0){
				 the_info["location0"] = subloc;
		         the_info["title0"] = crumbTitle;
				 arraycount = arraycount + 1;
		         return;
				 }else{

				 the_info[("location" + arraycount)] = (the_info[("location" + (arraycount - 1))]);
				 the_info[("title" + arraycount)] = (the_info[("title" + (arraycount - 1))]);
				 
				 if (arraycount > 2){
				 for (var subloop = (arraycount -1); subloop > 1; subloop--){
				 the_info[("location" + subloop)] = (the_info[("location" + (subloop - 1))]);
				 the_info[("title" + subloop)] = (the_info[("title" + (subloop - 1))]);
				 }
				 }
				 
				 the_info["location1"] = (the_info["location0"]);
				 the_info["title1"] = (the_info["title0"]);
				 arraycount = arraycount + 1;				 
				 
				 
				 return;
				 }
		      }
	     }
	 }
	
}

function breadmaker(){
  for (var loop = 0; loop <= (arraycount - 1); loop++){

          if(firstone == "yes"){
		  return;
		  }

		  if(firstone == "no"){
		  if (arraycount < 2){
		  return;
		  }
		  }

		  if (arraycount >= 2){

		        if (loop == 0){
				document.write("<a class='bclink' href=http://"+(cookie_information[("location" + (loop + 1))])+">"+(cookie_information[("title" + (loop + 1))])+"</a> ");
				}else{

				   if (loop != (arraycount - 1)){
		              if ((cookie_information[("location" + (loop + 1))]) != (cookie_information[("location" + loop)])){
	                  document.write("<a class='bclink' href=http://"+(cookie_information[("location" + (loop + 1))])+">"+(cookie_information[("title" + (loop + 1))])+"</a> ");
				      }
				   }
		        }
		    } 

  }
}



readTheCookie(cookie_information);
breadmaker();



var new_cookie="";
function newNavCookie(){

    if (arraycount < 6) { 
    for (var loop = 0; loop <= (arraycount - 1); loop++){  

	new_cookie = new_cookie + "location" + loop + ":" + cookie_information[("location" + loop)] + ":" + "title" + loop + ":" + cookie_information[("title" + loop)] + ",";

	}
	
	}else{
	 for (var loop = 0; loop < (arraycount -  1); loop++){   
	
	 new_cookie = new_cookie + "location" + loop + ":" + cookie_information[("location" + (loop + 1))] + ":" + "title" + loop + ":" + cookie_information[("title" + (loop + 1))] + ",";
	 }
	}
	
	var  x = location.toString();
	x = x.substring(x.indexOf("/")+2);

	
	if (arraycount < 6){
	new_cookie = new_cookie + "location" + arraycount + ":" + x + ":" + "title" + arraycount + ":" + crumbTitle;
	document.cookie= "navCookie=" + escape(new_cookie);
	
	}else{
	new_cookie = new_cookie + "location" + (arraycount - 1) + ":" + x  + ":" + "title" + (arraycount - 1) + ":" + crumbTitle;
	document.cookie= "navCookie=" + escape(new_cookie);
	}
}

newNavCookie();
