// http://mickweb.com/javascript/tutorials/breadcrumbs/explanation.html

function spawn(expr,qty,reversed)
{
   var spawnee=[expr];
   for(s=1;s<qty;s++)
   {
	  spawnee[s]=expr+spawnee[s-1];
   }
   return reversed? spawnee.reverse() : spawnee();
}

function mw_crumbs(divider,default_page,root)
{
   if(!divider) {divider="&raquo;"}
   if(!default_page){default_page="index.php"}
   
   var m=location.toString();
   var h="";
   m=m.substring(m.indexOf("/")+1);
   m=m.split("/");
   var howmany=spawn("../",m.length,true);
   howmany[m.length]=default_page;
   
   for(i=1;i<m.length-1;i++)
   {
	  m[i] = m[i].replace(/_/g, " "); 

	 // alert(m[i]);
	  if( i>1)
	  {
		 m[i] = m[i].replace("cod", "COD"); 
		 m[i] = m[i].replace("state based stats", "State based statistics"); 

		// h+=("<a href="+howmany[i+2]+">"+unescape( m[i].substr(0, 1).toUpperCase() +m[i].substr(1)+"</a>"+divider))
		//alert(("<a href="+howmany[i+2]+">"+unescape( m[i].substr(0, 1).toUpperCase() +m[i].substr(1)+"</a>")));
		 		 h+=("<a href="+howmany[i+2]+">"+unescape( m[i].substr(0, 1).toUpperCase() +m[i].substr(1)+"</a>"+divider))

	  }
	  else
	  {
		  //h+=("<a href="+howmany[i+2]+">"+unescape( m[i]+"</a>"+divider))
		  h+=("<a href="+howmany[i+2]+">"+unescape( m[i]+"</a>"+divider))
	  }
	  
	  //alert(h);
   }
   h += "<span>" + document.title + "</span>";
   if(root)
   {
	  h=h.replace(eval("/"+location.host+"/"),root);
   }
   return "<div class='breadcrumb'>"+h+"</div>";
}// JavaScript Document
