/*
  RESERVED WORDS
  */
rw_OBF = "Of, By and For";
rw_Commentary = "Commentary";
rw_About = "About";
rw_Bkgd = "Background";
rw_Topic = "Topic";

/* Project development */
rw_Project = "Project";     /* An advocacy or other project not visible to general users */
rw_Done = "Done";          /* Done, concluded, finalized */
rw_Polish = "Polishing";    /* Polishing, refining, final drafts */
rw_Rough = "Rough";      /* Roughing things out, work in progress */
rw_Idea = "Ideas";          /* Ideas, concepts, brainstorming */
projProgressList = new Array (rw_Done, rw_Polish, rw_Rough, rw_Idea);
scList = new Array(rw_About, rw_Bkgd, rw_Topic, rw_Project, rw_Done, rw_Polish, rw_Rough, rw_Idea);

catSep = ": ";                  /* Category separator, per TypePad (tho they never use it!) */

thisCategory_g = "";

/*
  HIERARCHICAL CATEGORIES
  */

function hasChild(c) {
  return c.indexOf(catSep);  /* Is there a category separator? */
}

function getParent(c) {
  var i = hasChild(c);
  if (i == -1) return "";
  return c.substr(0, i);
}

function isParent(c) {
  if (hasChild(c) == -1) return 1;
  return 0;
}

function stripParent(c) {
  var i = hasChild(c);
  if (i == -1) return "";
  return c.substr(i+2);
}

function getNextChild(c) {
  var s = stripParent(c);
  if (s == "") return "";
  if (hasChild(s) == -1) { return s; } else { return getParent(s); };
}

function getLastChild(c) {
  var last = "";
  do {
  	last = getNextChild(c);
  	c = stripParent(c);
  } while (c != last);
  return last;
}

function showNested(lastc, lastp, c, p, l) {
  if (p == lastp) { // another at this level
  	document.writeln('<li class="module-list-item">' + '<a href="' + l + '">' + (p == "" ? c : stripParent(c)) + '</a></li>');
  } else {  // at new level
  	if (lastp != "") document.writeln('</ul>'); // close previous nest
  	if (p == "") { // popped up to top
  		document.writeln('<li class="module-list-item">' + '<a href="' + l + '">' + c + '</a></li>');
  	} else {
  		if (p != lastc) document.writeln('<li class="module-list-item">'  + p + '</li>'); // built-in parent
  		document.writeln('<ul class="module-list">');
  		document.writeln('<li class="module-list-item">' + '<a href="' + l + '">' + stripParent(c) + '</a></li>');
		};
	};
};

function show(c, lastC, l, top) {
	if (c.length == 0) return;
/* document.writeln("<br>show: " + c + "/" + lastC); */
        var lastT = "";
	if (lastC.length == 0) { /* new root */
/*  document.writeln("<br>new List"); */
		document.writeln('<ul class="module-list' + (top ? ' hierarchy-top' : ' hierarchy') + '">');
		lastT = "";
	} else {
		lastT = lastC.shift();
	};
	var t = c.shift();
	if (t != lastT)  {
		for (var i = 0; i < lastC.length; i++) {
/* document.writeln("<br>End list loop: "); */
			document.writeln("</ul>");
		};
/* document.writeln("<br>Item: " + t); */
                if (c.length == 0) {
		    document.writeln('<li class="module-list-item hierarchy"><a href="' + l + '">' + (top ? '<b>' : '') + t + (top ? '</b>' : '') + '</a></li>');
                } else {
		    document.writeln('<li class="module-list-item hierarchy">' + (top ? '<b>' : '') + t  + (top ? '</b>' : '') + '</li>');
                };
		lastC.length = 0;
	};
	show(c, lastC, l, 0);
/*document.writeln("<br>End list: ");
	document.writeln("</ul>"); 
 */
}

function isIn(a, s) {
    for (var i in a) {
         if (a[i] == s) { return i; };
    };
    return -1;
}

function getPaired(alist, blist, s) {
    for (var i in alist) {
        if (alist[i] == s) return blist[i];
    };
    return "";
}

function startsWith(alist, s) {
    var matches = new Array();
    var j = 0;
    for (var i in alist) {
        if (alist[i].indexOf(s) != -1) {
            matches[j++] = alist[i];
        };
    };
    return matches;
}

/*
  FEEDS
  */
feeds = new Array();

function addFeed(c, f, fb) {
	feeds[c] = new Object();
	feeds[c].file = f;
	feeds[c].fbname = fb;
};

/* 
  MISC
  */

function outputFeedIcon(c) {
    document.writeln('<a href="' + obf_catLinkArray[c] + 'rss.xml" title="Subscribe to ' + c + ' feed" rel="alternate" teyp="application/rss+xml"><img src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="border:0"></a>');
};

function outputFeatured(t) {
    var bc = hasChild(t) > -1 ? getLastChild(t) : t;
    document.writeln('<h2 class="content-header breadcrumb-header">' + bc); // output breadcrumb if featured stuff
    outputFeedIcon(t);
    document.writeln('</h2>');
    document.writeln('<div class="entry entry-feature">');
    document.write('<h3 class="entry-header entry-header-feature">About — ' + bc + ' ');
    document.writeln('</h3>');
    document.writeln('<div class="entry-content">');
    document.writeln('<div class="entry-body entry-body-feature">');
}

function showProject(c) {
  //document.writeln('showProject: ' + isIn(c.split(catSep), rw_Project));
  return isIn(c.split(catSep), rw_Project) > -1;
}

<!-- ph=1 -->

