var start, stop, ch, i, endChar;
var wholeLocation = location.href.toLowerCase();
var breadCrumb = "";
var oldSite = 0;

if ( wholeLocation.substring(wholeLocation.length-1) == "/" )
    wholeLocation += "index.shtml";

if (wholeLocation.indexOf("hh.html") != -1 ||
    wholeLocation.indexOf("intro.html") != -1)
{
    oldSite = 1;
}

start = wholeLocation.indexOf("heroinhelper.com") + 17;
stop = wholeLocation.indexOf("index.shtml");

if ( stop == -1 )
    stop = wholeLocation.indexOf(".shtml");
else
    stop -= 1;

var currentWord = "";
var currentLink = "/";

if ( wholeLocation.indexOf("heroinhelper.com/index.shtml") != -1 )
{
    breadCrumb = "home";
}
else if ( wholeLocation.indexOf("alachat") != -1 )
{
    breadCrumb = "<a href=\"/index.shtml\">home</a> | chat";
}
else
{
    breadCrumb = "<a href='" + currentLink + "index.shtml'>home</a>";
    for (i=start;i<stop;i++)
    {
        ch = wholeLocation.charAt(i);
        if ( ch == "\\" || ch == "/" )
        {
            breadCrumb += " | <a href='" + currentLink + "/index.shtml'>" +
                          currentWord + "</a>";
            currentWord = "";
            currentLink += "/";
        }
        else if ( ch == "_" )
        {
            currentLink += ch;
            currentWord += " ";
        }
        else
        {
            currentLink += ch;
            currentWord += ch;
        }
    }

    breadCrumb += " | " + currentWord;
    if ( oldSite == 1 )
        breadCrumb = "home";
}

function outputBC()
{
    document.writeln(breadCrumb);
}


function openInWin(pageToLoad)
{
    window.open(pageToLoad,"","menubar=no,status=no,toolbar=no");
}

function fillGlossary(checkWord)
{
var wordDef = "http://www.heroinhelper.com/curious/little_glossary.shtml#" + checkWord;
open(wordDef,"GlossaryWin","height=400,width=340,menubar=no,status=no,toolbar=no,scrollbars=yes").focus();
}
function fillWin(pageURL)
{
open(pageURL,"FriendsWin", "menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes");
}
function openForum(pageURL)
{
open(pageURL,"HeroinHelperForum", "menubar=no,status=no,toolbar=no,resizable=yes,width=620,scrollbars=yes");
}
