
window.defaultStatus = "TagTooga.com - The Web Wiki";

// Javascript cache.
var gCache = new Object(); 
var gVisited = new Object(); 	// URLs already visited.

var akListCats = new Array();  // Keys cached for listCat commands.
var akSearch = new Array();    // search commands
var akShowTags = new Array();  // Keys cached for showTag commands.
var akVotes = new Array();  // Votes
	
// Entries on current page...
var gUrls = new Object();  // URLs on the current page.
var aUrls = new Array();  // URLs on the current page, by index.
var gNumManualSorted = 0;	// Number of URLs manually sorted (pinned).
var gNumAutoSorted = 0;	// Number of URLs auto-sorted (unpinned).
var aDesc = new Array();  // Descriptions on the current page.
var aBot = new Array();  // Bottom rows of entries on the current page.

var gUniqueId = 1;

var gNewTagCat = "";

// Last category letter.
var gLastCat = '1';
// Last tag letter -- indexed by category name.
var gTagLet = new Object(); 

// Keep track of what is showing in the mainWrap.
// Track the screen contents, category, and tag.
var gMwScr = "default";
var gMwCat = "";
var gMwTag = "";

// Save the cached key in one of the arrays.
function cacheResults(key,aList,results){
  if (!gCache[key]) {
  	    aList.push(key);
  }
  gCache[key] = results;
}
// Cache key creation functions
function cKeySearch(str) {
	return "s_" + encodeURIComponent(str);
}
function cKeyListCat(str) {
	return "lc_" + encodeURIComponent(str);
}
function cKeyShowTag(cat,tag) {
	return "tg_" + encodeURIComponent(cat) + "/" + encodeURIComponent(tag);
}
function cKeyVote(str) {
	return "v_" + encodeURIComponent(str);
}
// Clear a set of keys from the cache.
function clearCache(aList) {
	var n = aList.length;
	for (var i = 0; i < n; i++) {
		gCache[aList[i]] = null;
	}
	aList.length = 0;
}
function clearCacheAll() {
	clearCache(akSearch);
	clearCache(akListCats);
	clearCache(akShowTags);
	clearCache(akVotes);
}

function fieldSelect(field)
{
	field.focus();
	field.select();
	
	return true;	
}

String.prototype.trim=function(){
    return this.replace(/^\s*|\s*$/g,'');
}

function limits(limit,opt)
{
	var dlen;
	var rem;
	var frm = document.forms.addEntry;
	dlen = frm.etx.value.length;
	rem = limit - dlen;

	if( rem > 0)
	{
		frm.remlen.value= rem;
		return true;
	}
	else if( rem == 0)
	{
		frm.remlen.value= rem;
		return false;
	}
	else
	{
		frm.remlen.value=0;
		frm.etx.value = frm.etx.value.substr(0,limit);
		return false;
	}
}

function clearNonVal(name)
{
	xpDivN("c=clearNonVal");
}
function showLog(name)
{
	xpDivN("c=showLog&n="+name);
}
function delLog(name)
{
	xpDivN("c=delLog&n="+name);
}

function listCats(let,pg)
{
	if (let == ".") let = gLastCat;
	gLastCat = let;
	
	xpDivN("c=listCats&let="+let+"&pg="+pg);
	
	gMwScr = "listCats";
	gMwCat = "";
	gMwTag = "";
}


// cmd is "vf" or "va"
function voteUrl(cmd,cat,tag,url,div)
{
	var key = cKeyVote(url);
	var c = gCache[key];
	if (!c) {
		cacheResults(key,akVotes,"1");
		xpDivN("c=" + cmd+ "&bt=" + encodeURIComponent(cat) + "&t=" + encodeURIComponent(tag) + "&url=" + encodeURIComponent(url));
	}
    document.getElementById(div).innerHTML = "<b>Thank You!</b>";
	
}
// cmd is "vfd" or "vad"
function voteDomain(cmd,dom,div)
{
	var key = cKeyVote(dom);
	var c = gCache[key];
	if (!c) {
		// Did not yet vote.	
		cacheResults(key,akVotes,"1");
		xpDivN("c="+cmd+"&d="+encodeURIComponent(dom));
	}
    document.getElementById(div).innerHTML = "&nbsp;&nbsp;&nbsp;<b>Thank You!</b>";
}
function visit(url)
{
	var c = gVisited[url];
	if (!c) {
  		gVisited[url] = url;
		xpDivN("c=visit&newWin=0&url="+encodeURIComponent(url));
	}
	else
	{
		window.location = url;
	}
}

function visit2(url)
{
	var c = gVisited[url];
	if (!c) {
  		gVisited[url] = url;
		xpDivN("c=visit&newWin=1&url="+encodeURIComponent(url));
	}
	else
	{
		var pLeft = screen.width - 600;
		//var ua = navigator.userAgent;
		//if (ua.indexOf('Firefox') != -1) {
		var w = window.open(url,"v2");
		//} else {
		//	var w = window.open(url,"v2");
		//}
		w.focus();
	}
}

function selQ(let)
{
	xpDivN("c=selQ&let="+let);
}
function xQuick(url)
{
	xpDivN("c=xQuick&url="+encodeURIComponent(url));
}
function importFriends()
{
	xpDivN("c=importFriends");
}
function addQuick(url)
{
	xpDivN("c=addQuick&url="+encodeURIComponent(url));
}

function rfIntel(url)
{
	xpDivN("c=rfIntel&url="+encodeURIComponent(url));
}
function addFriendForm(cat,tag)
{
xpDivN("c=addFriendForm&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag));
}

function urlXml(url)
{
	window.location = "http://www.tagtooga.com/tapp/db.exe?c=urlXml&url="+encodeURIComponent(url);
}

function removeFriend(cat,tag,url)
{
xpDivN("c=removeFriend&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag)+"&url="+encodeURIComponent(url));
}
function friendSpaceForm(cat,tag)
{
xpDivN("c=friendSpaceForm&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag));
}
function blogSpaceForm(cat,tag)
{
xpDivN("c=blogSpaceForm&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag));
}

function addQ(url,cat,tag)
{
	xpDivN("c=addQ&url="+encodeURIComponent(url)+"&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag));
}
function addCat(cat,let)
{
	xpDivN('c=addCat&bt='+encodeURIComponent(cat)+"&let="+let);
}
function removeCat(cat,let)
{
	xpDivN('c=removeCat&bt='+encodeURIComponent(cat)+"&let="+let);
}

function showHot(cat)
{
	xpDivN('c=hot&bt='+encodeURIComponent(cat));
}

function delMsg(msgId)
{
	xpDivN("c=delMsg&id="+encodeURIComponent(msgId));
}
function delAllMsgs()
{
	xpDivN("c=delAllMsgs");
}

function debugPage()
{
	var s = "";
	s = s + "<p>gNumManualSorted = " + gNumManualSorted + ", gNumAutoSorted = " + gNumAutoSorted + "</p>";
	
	var n = gNumManualSorted + gNumAutoSorted;
	var d = null;
	for (var i = 0; i < n; i++) {
		s = s + "<p>aUrls[" + i + "] = " + aUrls[i] + "</p>";
		s = s + "<p>&nbsp;&nbsp;gUrls[] = " + gUrls[aUrls[i]] + "</p>";
		
		d = document.getElementById("bot" + i);
		if (d != null) {
			s = s + "<p>&nbsp;&nbsp;bot[] is not null</p>";
		} else {
			s = s + "<p>&nbsp;&nbsp;bot[] is null</p>";
		}
		d = document.getElementById("desc" + i);
		if (d != null) {
			s = s + "<p>&nbsp;&nbsp;desc[] is not null</p>";
		} else {
			s = s + "<p>&nbsp;&nbsp;desc[] is null</p>";
		}
		d = document.getElementById("ee" + i);
		if (d != null) {
			s = s + "<p>&nbsp;&nbsp;ee[] is not null</p>";
		} else {
			s = s + "<p>&nbsp;&nbsp;ee[] is null</p>";
		}
		d = document.getElementById("eup" + i);
		if (d != null) {
			s = s + "<p>&nbsp;&nbsp;eup[] is not null</p>";
		} else {
			s = s + "<p>&nbsp;&nbsp;eup[] is null</p>";
		}
		d = document.getElementById("edn" + i);
		if (d != null) {
			s = s + "<p>&nbsp;&nbsp;edn[] is not null</p>";
		} else {
			s = s + "<p>&nbsp;&nbsp;edn[] is null</p>";
		}
		d = document.getElementById("eau" + i);
		if (d != null) {
			s = s + "<p>&nbsp;&nbsp;eau[] is not null</p>";
		} else {
			s = s + "<p>&nbsp;&nbsp;eau[] is null</p>";
		}
	}
	
	return s;
}
function rmAllQ()
{
	xpDivN('c=rmAllQ');
}
function rmMyCat(cat)
{
	xpDivN('c=rmMyCat&bt='+encodeURIComponent(cat));
}

function qImport(cat,tag,perma,img)
{
	xpDivN('c=qImport&t='+encodeURIComponent(tag)+"&bt="+encodeURIComponent(cat)+"&perma="+perma+"&img="+img);
}

function delFromPgi(cat,tag,url,elemId)
{
	var dElem = document.getElementById(elemId);
	if (dElem) { dElem.innerHTML = "&nbsp;";	}
	
	xpDivN('c=delFromPage&t='+encodeURIComponent(tag)+"&bt="+encodeURIComponent(cat)+"&url="+encodeURIComponent(url));
}

function delFromPage(cat,tag,url)
{
	var idx = gUrls[url];
	var spanId = "ee" + idx;
	var dElem = document.getElementById(spanId);
	if (!dElem)
	{ xpDivN('c=delFromPage&t='+encodeURIComponent(tag)+"&bt="+encodeURIComponent(cat)+"&url="+encodeURIComponent(url));
		return;
	}
	dElem.innerHTML = "";
	dElem.id = "xxx" + gUniqueId;
	gUniqueId++;
		
	var n = gNumManualSorted + gNumAutoSorted;
	for (var i = idx+1; i < n; i++) {
		gUrls[aUrls[i]] = i-1;
		
		// Update the HTML IDs
		var botId = "bot" + (i-1);
		var elem = document.getElementById("bot" + i);
		if (elem) { elem.id = botId; }
		
		var descId = "desc" + (i-1);
		elem = document.getElementById("desc" + i);
		if (elem) { elem.id = descId; }
		
		var eeId = "ee" + (i-1);
		elem = document.getElementById("ee" + i);
		if (elem) { elem.id = eeId; }
		
		var ednId = "edn" + (i-1);
		elem = document.getElementById("edn" + i);
		if (elem) { elem.id = ednId; }
		
		var eupId = "eup" + (i-1);
		elem = document.getElementById("eup" + i);
		if (elem) { elem.id = eupId; }
		
		var eauId = "eau" + (i-1);
		elem = document.getElementById("eau" + i);
		if (elem) { elem.id = eauId; }
	}
	
	aUrls.splice(idx,1);
	aDesc.splice(idx,1);
	aBot.splice(idx,1);
	if (idx >= gNumManualSorted) {
		gNumAutoSorted--;
	} else {
		gNumManualSorted--;
		
		if ((idx == 0) && (gNumManualSorted > 0)) {
			// Deleted the top manual-sorted item, and there are more manual sorted items..
			var upElem = document.getElementById("eup0");
			if (upElem != null) {
				upElem.innerHTML = "";
			}
		}
		if ((idx == gNumManualSorted) && (gNumManualSorted > 0)) {
			// Deleted the bottom manual-sorted item, and there are more manual sorted items..
			var dElem = document.getElementById("edn"+(gNumManualSorted-1));
			if (dElem != null) {
				dElem.innerHTML = "";
			}
		}	
	}
	
	n = gNumManualSorted + gNumAutoSorted;
	if (n == 1) {
		var elem = document.getElementById("eau0");
		if (elem) { elem.innerHTML = ""; }
	}

	xpDivN('c=delFromPage&t='+encodeURIComponent(tag)+"&bt="+encodeURIComponent(cat)+"&url="+encodeURIComponent(url));
}

function xform(url, div, cat, tag)
{
	xpDivN("c=xform&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag)+"&url="+encodeURIComponent(url)+"&div="+div);
}

function editUrl(cat,tag,url,divId)
{
	xpDivN("c=editUrl&t="+encodeURIComponent(tag)+"&bt="+encodeURIComponent(cat)+"&url="+encodeURIComponent(url)+"&div="+divId);
}
function comments(cat,tag,url,divId)
{
	xpDivN("c=comments&t="+encodeURIComponent(tag)+"&bt="+encodeURIComponent(cat)+"&url="+encodeURIComponent(url)+"&div="+divId);
}
function editUrlDom(url,divId,dom)
{
	xpDivN("c=editUrl&url="+encodeURIComponent(url)+"&div="+divId+"&d="+encodeURIComponent(dom));
}
	
function delTag(cat,tag)
{
	xpDivN("c=delTag&t="+encodeURIComponent(tag)+"&bt="+encodeURIComponent(cat));
	//alert("deleted " + cat + " / " + tag);
}
function delTag2(cat,tag)
{
	xpDivN("c=delTag2&t="+encodeURIComponent(tag)+"&bt="+encodeURIComponent(cat));
}

function redoImg(cat,tag)
{
	xpDivN("c=redoImg&t="+encodeURIComponent(tag)+"&bt="+encodeURIComponent(cat));
	alert("submitted " + cat + " / " + tag);
}

function delUrl(url)
{
	xpDivN("c=delUrl&url="+encodeURIComponent(url));
	alert("deleted " + url);
}
function urlOk(url)
{
	xpDivN("c=urlOk&url="+encodeURIComponent(url));
}

function delCat(cat)
{
	xpDivN("c=delCat&bt="+encodeURIComponent(cat));
	alert("deleted " + cat);
}

function defaultPage()
{
	gMwScr = "default";
	gMwCat = "";
	gMwTag = "";
	
	//window.location = "/tapp/db.exe?c=default";
	window.location = "/db.tag";
}

function selectCat(cat)
{
	xpDivN("c=selectCat&bt="+encodeURIComponent(cat));
}

function listTags(cat,let)
{
	if (let == ".") let = gTagLet[cat];
	gTagLet[cat] = let;
	xpDivN("c=listBt&bt="+encodeURIComponent(cat)+"&let="+let);
	
	gMwScr = "listTags";
	gMwCat = cat;
	gMwTag = "";
}
function listTags2(cat,let,pg)
{
	if (let == ".") let = gTagLet[cat];
	gTagLet[cat] = let;
	xpDivN("c=listBt2&bt="+encodeURIComponent(cat)+"&let="+let+"&pg="+pg);
	
	gMwScr = "listTags";
	gMwCat = cat;
	gMwTag = "";
}

function addTagS(cat,tag,idx)
{
	var let = ".";
	if (gMwScr == "listTags") let = gTagLet[cat];
	xpDivN("c=addTag&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag)+"&from=search&idx="+idx+"&scr="+gMwScr+"&let="+let);
}

function addTag(cat,tag,let)
{
	//if (let == ".") let = gTagLet[cat];
	xpDivN("c=addTag&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag)+"&let="+let+"&scr="+gMwScr);
}

// Remove a tag from an account.
function rmTag(cat,tag,let)
{
	if (let == ".") let = gTagLet[cat];
	xpDivN("c=rmTag&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag)+"&let="+let+"&scr="+gMwScr);
}
function addTagIdx(cat,tag,let,idx)
{
	//if (let == ".") let = gTagLet[cat];
	xpDivN("c=addTagIdx&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag)+"&let="+let+"&idx="+idx+"&scr="+gMwScr);
}

// Remove a tag from an account.
function rmTagIdx(cat,tag,let,idx)
{
	if (let == ".") let = gTagLet[cat];
	xpDivN("c=rmTagIdx&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag)+"&let="+let+"&idx="+idx+"&scr="+gMwScr);
}
function delComment(url,id,divId)
{
	xpDivN("c=delComment&url="+encodeURIComponent(url)+"&id="+id+"&div="+divId);
}
function edComment(url,id,divId)
{
	xpDivN("c=edComment&url="+encodeURIComponent(url)+"&id="+id+"&div="+divId);
}


function rmTagS(cat,tag,idx)
{
	var let = ".";
	if (gMwScr == "listTags") let = gTagLet[cat];
	xpDivN("c=rmTag&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag)+"&from=search&idx="+idx+"&scr="+gMwScr+"&let="+let);
}

function newTagForm(cat,divId)
{
	gNewTagCat = cat;  // Save this just in case the cancel button is pressed.
	xpDivN("c=newTagForm&bt="+encodeURIComponent(cat)+"&div="+divId);
}
function showUserT(login,divId,task)
{
	xpDivN("c=showUser&l="+encodeURIComponent(login)+"&div="+divId+"&task="+task);
}
function showUser(login,divId)
{
	xpDivN("c=showUser&l="+encodeURIComponent(login)+"&div="+divId);
}
function showDomain(dom,divId)
{
	xpDivN("c=showDomain&d="+encodeURIComponent(dom)+"&div="+divId);
}
function rfImg(url) { xpDivN("c=rfImg&url="+encodeURIComponent(url)); }

function showDesc(cat,tag,bSend)
{
	var n = gNumManualSorted + gNumAutoSorted;
	var i;
	for (var i = 0; i < n; i++)
		{
			document.getElementById("desc"+i).innerHTML = aDesc[i];
		}
	document.getElementById("dOnOff").innerHTML = '<a class="lim" title="Hide Descriptions" href="javascript:hideDesc(\'' + gMwCat + '\',\'' + gMwTag + '\')"><img src="/images/dminus.gif" border=0 /></a>';
	
	if (bSend == 1) {
		xpDivN("c=showDesc&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag));
	}

}
function hideDesc(cat,tag,bSend)
{
	var n = gNumManualSorted + gNumAutoSorted;
	var i;
	for (var i = 0; i < n; i++)
		{
			var elem = document.getElementById("desc"+i);
			aDesc[i] = elem.innerHTML;
			elem.innerHTML = "";
		}
	document.getElementById("dOnOff").innerHTML = '<a class="lim" title="Show Descriptions" href="javascript:showDesc(\'' + gMwCat + '\',\'' + gMwTag + '\')"><img src="/images/dplus.gif" border=0 /></a>';

	if (bSend == 1) {
		xpDivN("c=hideDesc&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag));
	}
}
function fxSteps()
{
			url = "javascript:d=document;desc = '';var ma = d.getElementsByName('description'); if (ma.length > 0) { desc = ma[0].content; }  w = window.open('http://www.tagtooga.com/tapp/db.exe?c=jsEntryForm&b=fx&popup=1&desc='+encodeURIComponent(desc)+'&title='+encodeURIComponent(d.title)+'&url='+encodeURIComponent(d.location.href),'_blank','width=590,height=460,status=no,resizable=yes,scrollbars=auto');void(window.setTimeout('w.focus()',200));";
		
	document.getElementById("gStarted").innerHTML = '<h2>Adding a Button to the FireFox Toolbar</h2><h3><a title="Save the Current Browser Web Page" href="'+url+'">&lt;&lt;TagTooga&gt;&gt;</a><br /></h3><p><b>1.</b> Left-click on the "TagTooga" link (above) and hold down the mouse button</p><p><b>2.</b> Drag the link to the FireFox toolbar.  While dragging the link, a <img src="/images/cno.gif" /> may be displayed.  This is OK.</p><p><b>3.</b> When the cursor is over the toolbar the cursor image will change (as shown below).  Release the left mouse button.<br /><br /><center><img style="border: 1px dashed" src="/images/fxStep3.gif" /></center></p><p><center><b><a href="http://www.tagtooga.com/tapp/db.exe?c=default">Back</a></b></center></p>';
}

function ieSteps()
{
		var url = "javascript:window.location='http://www.tagtooga.com/tapp/db.exe?c=jsEntryForm&b=ie&url='+encodeURIComponent(document.location.href)";

	var url2 = "javascript:d=document;rl=d.location.href.length+70;ln='';for(i=0;i<d.links.length;i++){var u=d.links[i].href;if(((ln.length+rl+u.length)<1000)&&(u.indexOf('.google.com')==-1)&&(u.indexOf('search?q')==-1)){ln=ln+d.links[i].href+'|';}}window.location='http://www.tagtooga.com/tapp/db.exe?c=jsLinksForm&b=ie&url='+encodeURIComponent(ln)+'&ref='+encodeURIComponent(d.location.href);";
		
	document.getElementById("gStarted").innerHTML = '<h2>Adding a Link to the Internet Explorer Toolbar</h2><p><b>1.</b> In the Internet Explorer menu, click "View" and hover over "Toolbars". Make sure "Links" is checked:<br /><br /><center><img style="border: 1px dashed" src="/images/ieStep0.gif" /></center></p><p><b>2.</b> Right-click on the "TagTooga" link and select "Add to Favorites...":</p><h3><center><a title="<<TagTooga>>" href="'+url+'">&lt;&lt;TagTooga&gt;&gt;</a><br /></center></h3><p><b>3.</b> You will see a warning, click Yes:<br /><br /><center><img src="/images/ieStep2.gif" /></center></p><p><b>4.</b> Make sure the "Create-in" window is open.  Click "Links" and then click "OK".<br /><br /><center><img src="/images/ieStep3.gif" /></center></p><p><b>5.</b> You are finished. The TagTooga link will appear in the Internet Explorer toolbar.  When you are browsing a site, you may click on the TagTooga toolbar link to save the page to your bookmarks in TagTooga.</p><p><center><b><a href="http://www.tagtooga.com/tapp/db.exe?c=default">Back</a></b></center></p>';
}

function showBottom(cat,tag,bSend)
{
	var n = gNumManualSorted + gNumAutoSorted;
	var i;
	for (var i = 0; i < n; i++)
		{
			document.getElementById("bot"+i).innerHTML = aBot[i];
		}
	document.getElementById("bOnOff").innerHTML = '<a class="lim" title="Hide Icons" href="javascript:hideBottom(\'' + gMwCat + '\',\'' + gMwTag + '\')"><img src="/images/c2.gif" border=0 /></a>';

	if (bSend == 1) {
		xpDivN("c=showBottom&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag));
	}
}
function hideBottom(cat,tag,bSend)
{
	var n = gNumManualSorted + gNumAutoSorted;
	var i;
	for (var i = 0; i < n; i++)
		{
			var elem = document.getElementById("bot"+i);
			aBot[i] = elem.innerHTML;
			elem.innerHTML = "";
		}
	document.getElementById("bOnOff").innerHTML = '<a class="lim" title="Show Icons" href="javascript:showBottom(\'' + gMwCat + '\',\'' + gMwTag + '\')"><img src="/images/c3.gif" border=0 /></a>';
	
	if (bSend == 1) {
		xpDivN("c=hideBottom&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag));
	}
}

function swapEntries(idx0,idx1)
{
	var id0 = "ee" + idx0;
	var id1 = "ee" + idx1;
	var elem0 = document.getElementById(id0);
	var elem1 = document.getElementById(id1);
	var html1 = elem1.innerHTML;
	elem1.innerHTML = elem0.innerHTML;
	elem0.innerHTML = html1;
}

// In this case, idx1 = idx0-1
function clMoveUp(cat,tag,url)
{
	var idx0 = gUrls[url];
	var idx1 = idx0 - 1;
	var url1 = aUrls[idx1];
	
	var downId0 = "edn" + idx0;
	var downId1 = "edn" + idx1;
	var upId0 = "eup" + idx0;
	var upId1 = "eup" + idx1;
	var autoId0 = "eau" + idx0;
	var autoId1 = "eau" + idx1;
	var descId0 = "desc" + idx0;
	var descId1 = "desc" + idx1;
	var botId0 = "bot" + idx0;
	var botId1 = "bot" + idx1;
	var descElem0 = document.getElementById(descId0);
	var descElem1 = document.getElementById(descId1);
	var botElem0 = document.getElementById(botId0);
	var botElem1 = document.getElementById(botId1);
	var downElem0 = document.getElementById(downId0);
	var downElem1 = document.getElementById(downId1);
	var upElem0 = document.getElementById(upId0);
	var upElem1 = document.getElementById(upId1);
	var autoElem0 = document.getElementById(autoId0);
	var autoElem1 = document.getElementById(autoId1);
	
	if (upElem1.innerHTML.length == 0) 
	{
		// Moving up to the top position.
		upElem0.innerHTML = "";

		upElem1.innerHTML = '<a class="lim" title="Move Up" href="javascript:moveUp(\'' + 
			gMwCat + "','" + gMwTag + "','" + url1 + "')\"><img src=\"/images/upb.gif\" border=0 /></a>";
	}
		
	// Swap the ids.
	upElem0.id = "temp";
	upElem1.id = upId0;
	upElem0.id = upId1;
	
	if (downElem0.innerHTML.length == 0)
	{
		// Moving up from the bottom position.
		downElem1.innerHTML = "";

		downElem0.innerHTML = '<a class="lim" title="Move Down" href="javascript:moveDown(\'' + 
			gMwCat + "','" + gMwTag + "','" + url + "')\"><img src=\"/images/db.gif\" border=0 /></a>";
	}
		
	// Swap the ids.
	downElem0.id = "temp";
	downElem1.id = downId0;
	downElem0.id = downId1;
		
	autoElem0.id = "temp";
	autoElem1.id = autoId0;
	autoElem0.id = autoId1;
	
	descElem0.id = "temp";
	descElem1.id = descId0;
	descElem0.id = descId1;
	
	botElem0.id = "temp";
	botElem1.id = botId0;
	botElem0.id = botId1;
	
	swapEntries(idx0,idx1);
	
	gUrls[url] = idx1;
	gUrls[url1] = idx0;
	aUrls[idx1] = url;
	aUrls[idx0] = url1;
}
function moveUp(cat,tag,url)
{
	clMoveUp(cat,tag,url);
	xpDivN("c=moveUp&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag)+"&url="+encodeURIComponent(url));
}

// This must update gUrls and aUrls.
function clMoveDown(cat,tag,url)
{
	var idx0 = gUrls[url];
	
	var idx1 = idx0 + 1;
	var url1 = aUrls[idx1];
	var downId0 = "edn" + idx0;
	var downId1 = "edn" + idx1;
	var upId0 = "eup" + idx0;
	var upId1 = "eup" + idx1;
	var autoId0 = "eau" + idx0;
	var autoId1 = "eau" + idx1;
	var descId0 = "desc" + idx0;
	var descId1 = "desc" + idx1;
	var botId0 = "bot" + idx0;
	var botId1 = "bot" + idx1;
	var descElem0 = document.getElementById(descId0);
	var descElem1 = document.getElementById(descId1);
	var botElem0 = document.getElementById(botId0);
	var botElem1 = document.getElementById(botId1);
	var downElem0 = document.getElementById(downId0);
	var downElem1 = document.getElementById(downId1);
	var upElem0 = document.getElementById(upId0);
	var upElem1 = document.getElementById(upId1);
	var autoElem0 = document.getElementById(autoId0);
	var autoElem1 = document.getElementById(autoId1);
	
	if (upElem0.innerHTML.length == 0) 
	{
		// Moving down from the top position.
		// elem1 is the new top element.
		upElem1.innerHTML = "";
		
		upElem0.innerHTML = '<a class="lim" title="Move Up" href="javascript:moveUp(\'' + 
			gMwCat + "','" + gMwTag + "','" + url + "')\"><img src=\"/images/upb.gif\" border=0 /></a>";
	}
	
	// Swap the ids.
	upElem0.id = "temp";
	upElem1.id = upId0;
	upElem0.id = upId1;
	
	if (downElem1.innerHTML.length == 0)
	{
		// Moving down to the bottom position.
		downElem0.innerHTML = "";
		
		downElem1.innerHTML = '<a class="lim" title="Move Down" href="javascript:moveDown(\'' + 
			gMwCat + "','" + gMwTag + "','" + url1 + "')\"><img src=\"/images/db.gif\" border=0 /></a>";
	}
		
	// Swap the ids.
	downElem0.id = "temp";
	downElem1.id = downId0;
	downElem0.id = downId1;
		
	autoElem0.id = "temp";
	autoElem1.id = autoId0;
	autoElem0.id = autoId1;
	
	descElem0.id = "temp";
	descElem1.id = descId0;
	descElem0.id = descId1;
	
	botElem0.id = "temp";
	botElem1.id = botId0;
	botElem0.id = botId1;

	swapEntries(idx0,idx1);
	
	gUrls[url] = idx1;
	gUrls[url1] = idx0;
	aUrls[idx1] = url;
	aUrls[idx0] = url1;
}

function moveDown(cat,tag,url)
{
	clMoveDown(cat,tag,url);
	xpDivN("c=moveDown&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag)+"&url="+encodeURIComponent(url));
}

function ttInit() {}

// An entry has changed ids from idx0 to idx1
function setNewEntryId(idx0,idx1)
{
	var elem = document.getElementById("eup"+idx0);
	elem.id = "eup"+idx1;
	
	elem = document.getElementById("edn"+idx0);
	elem.id = "edn"+idx1;
	
	elem = document.getElementById("eau"+idx0);
	elem.id = "eau"+idx1;
	
	elem = document.getElementById("bot"+idx0);
	elem.id = "bot"+idx1;
	
	elem = document.getElementById("desc"+idx0);
	elem.id = "desc"+idx1;
}

// idx0 = index of the entry to unpin.
function toManualSort(cat,tag,url)
{
	var idx0 = gUrls[url];
	
	// Everything needs to move down one position to make room at the top.
	if (idx0 > 0)
	{
		setNewEntryId(idx0,"temp");
		var html0 = document.getElementById("ee"+idx0).innerHTML;
	
		for (var i = idx0; i>=1; i--)
			{
				var elem = document.getElementById("ee"+(i-1));
				document.getElementById("ee"+i).innerHTML = elem.innerHTML;
				elem.innerHTML = "";
				
				setNewEntryId(i-1,i);
				
				var urlTemp = aUrls[i-1];
				gUrls[urlTemp] = i;
				aUrls[i] = urlTemp;
			}
		document.getElementById("ee0").innerHTML = html0;
		setNewEntryId("temp",0);
		
		aUrls[0] = url;
		gUrls[url] = 0;			
	}
	
	document.getElementById("eau0").innerHTML = '<a class="lim" title="Move Down to Auto Sorted Listings" href="javascript:toAutoSort(\'' + gMwCat + "','" + gMwTag + "','" + url + "')\"><img src=\"/images/dr.gif\" border=0 /></a>";
	
	if (gNumAutoSorted > 0) gNumAutoSorted--;
	gNumManualSorted++;
	
	if (gNumManualSorted > 1)
	{
		document.getElementById("edn0").innerHTML = '<a class="lim" title="Move Down" href="javascript:moveDown(\'' + gMwCat + "','" + gMwTag + "','" + url + "')\"><img src=\"/images/db.gif\" border=0 /></a>";
		
		document.getElementById("eup1").innerHTML = '<a class="lim" title="Move Up" href="javascript:moveUp(\'' + gMwCat + "','" + gMwTag + "','" + aUrls[1] + "')\"><img src=\"/images/upb.gif\" border=0 /></a>";

	}
	
	xpDivN("c=manualSort&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag)+"&url="+encodeURIComponent(url));
}
// idx0 = index of the entry to pin.
function toAutoSort(cat,tag,url)
{
	var idx0 = gUrls[url];
	
	// First, bubble-down the entry to be auto-sorted to the last manual-sorted entry.
	if (gNumManualSorted > 1)
	{
		if (idx0 < (gNumManualSorted - 1))
		{
			// The entry is not already in the last manual-sorted position...
			var idxStop = gNumManualSorted - 1;
			for (var i = idx0; i < idxStop; i++)
				{
					clMoveDown(cat,tag,url);
				}
		}
	}
	
	idx0 = gUrls[url];
	var downId = "edn" + idx0;
	var upId = "eup" + idx0;
	var autoId = "eau" + idx0;
	var downElem = document.getElementById(downId);
	var upElem = document.getElementById(upId);
	var autoElem = document.getElementById(autoId);
	upElem.innerHTML = "";
	downElem.innerHTML = "";
	autoElem.innerHTML = '<a class="lim" title="Send to Top for Manual Sorting" href="javascript:toManualSort(\'' + 
		gMwCat + "','" + gMwTag + "','" + url + "')\"><img src=\"/images/upg.gif\" border=0 /></a>";
	
	if (gNumManualSorted > 0) gNumManualSorted--;
	gNumAutoSorted++;
	
	if (gNumManualSorted > 0)
	{
		// The last entry should not have a green down arrow
		var idx1 = gNumManualSorted-1;
		downId = "edn" + idx1;
		downElem = document.getElementById(downId);
		downElem.innerHTML = "";
			
		if (gNumManualSorted == 1)
		{
			// Should not have a green up-arrow either.
			upId = "eup" + idx1;
			upElem = document.getElementById(upId);
			upElem.innerHTML = "";
		}
	}
	
	xpDivN("c=autoSort&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag)+"&url="+encodeURIComponent(url));
}

function banDom(dom,divId,bType,value)
{
	xpDivN("c=banDom&d="+encodeURIComponent(dom)+"&div="+divId+"&banType="+bType+"&v="+value);
}
function findDomain()
{
	showDomain(document.findDom.dom.value,'dig');
}
function showUrlDom(url,divId,dom)
{
	xpDivN("c=showUrl&url="+encodeURIComponent(url)+"&d="+encodeURIComponent(dom)+"&div="+divId);
}
function showUrlTag(url,divId,cat,tag)
{
	xpDivN("c=showUrl&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag)+"&url="+encodeURIComponent(url)+"&div="+divId);
}

function showGoog(gid,divId)
{
	xpDivN("c=showGoog&gid="+encodeURIComponent(gid)+"&div="+divId);
}

function banGoog(gid,divId,v)
{
	xpDivN("c=banGoog&gid="+encodeURIComponent(gid)+"&div="+divId+"&v="+v);
}
function banGoogDom(gid,divId,dom)
{
	xpDivN("c=banGoogDom&gid="+encodeURIComponent(gid)+"&div="+divId+"&d="+dom);
}

function showRelTag(cat,tag,cat0,tag0)
{
	xpDivN("c=showRelTag&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag)+"&bt0="+encodeURIComponent(cat0)+"&t0="+encodeURIComponent(tag0));
}
function showRelNew(cat,tag,cat0,tag0)
{
	xpDivN("c=showRelNew&bt="+encodeURIComponent(cat)+"&t="+encodeURIComponent(tag)+"&bt0="+encodeURIComponent(cat0)+"&t0="+encodeURIComponent(tag0));
}
function showTag(cat,tag)
{
	// Clear the array of URLs for this page.
	aUrls.length = 0;
	
	xpDivN("c=showTag&bt="+encodeURIComponent(cat)+"&t="
		+encodeURIComponent(tag));
	
	gMwScr = "showTag";
	gMwCat = cat;
	gMwTag = tag;
}
function showTagBt(cat,tag,let,clet)
{
	// Clear the array of URLs for this page.
	aUrls.length = 0;
	
	xpDivN("c=showTag&from=listBt&bt="+encodeURIComponent(cat)+"&t="
		+encodeURIComponent(tag)+"&let="+let+"&clet="+clet);
	
	gMwScr = "showTag";
	gMwCat = cat;
	gMwTag = tag;
}
function showTagUser(cat,tag,login,divId)
{
	// Clear the array of URLs for this page.
	aUrls.length = 0;
	
	xpDivN("c=showTag&bt="+encodeURIComponent(cat)+"&t="
		+encodeURIComponent(tag)+"&l="+encodeURIComponent(login)+"&div="+divId);
	
	gMwScr = "showTag";
	gMwCat = cat;
	gMwTag = tag;
}
function showTagUrl(cat,tag,url,divId)
{
	// Clear the array of URLs for this page.
	aUrls.length = 0;
	
	xpDivN("c=showTag&bt="+encodeURIComponent(cat)+"&t="
		+encodeURIComponent(tag)+"&url="+encodeURIComponent(url)+"&div="+divId);
	
	gMwScr = "showTag";
	gMwCat = cat;
	gMwTag = tag;
}
function showEditTagForm(cat,tag,divId)
{
	xpDivN("c=editTagForm&bt="+encodeURIComponent(cat)+"&t="
		+encodeURIComponent(tag)+"&div="+divId);
}	
	
function cancelNewTag(div) {
  	document.getElementById(div).innerHTML = "<p><a href=\"javascript:newTagForm('" + gNewTagCat + "','" + div + "')\">New Tag</a></p>";
}

function shDomForm()
{
	var digDiv = document.getElementById('dig');
	
	digDiv.innerHTML = '<div id="popIn" style="margin:10px;"><p id="xBut"><a id="xBut" href="javascript:clearDiv(\'dig\')"><img border=0 src="/images/trans1.gif" /></a></p><h4>&nbsp;Find a Domain</h4><div style="margin: 5px;" clear:"left";><p style="margin: 5px;">Enter a domain name, such as <em>microsoft.com</em></p>' + 
	'<form name="findDom" id="findDom" action="javascript:findDomain()" method="post">' +
	'<p style="margin: 5px;">Domain: <input name="dom" id="textbox" type="text" value="" size="40" /></p>' +
	'<p style="margin: 5px;"><input id="cancel" type="button" name="cancel" value="Cancel" onclick="javascript:clearDiv(\'dig\')" />&nbsp;<input id="submit" type="submit" name="submit" value="Find" /></p>' +
	'</form></div></div>';
	/*digDiv.innerHTML = '<div id="popIn" style="margin:10px;"><p id="xBut"><a id="xBut" href="javascript:clearDiv(\'dig\')"><img border=0 src="/images/trans1.gif" /></a></p>' + debugPage() + '</div>';*/
}

function shAddUrlForm1(cat, tag)
{
	var eDiv = document.getElementById('etag');
	
	eDiv.innerHTML = '<div id="popIn">' +
'<p id="xBut"><a id="xBut" href="javascript:clearDiv(\'etag\')"><img border=0 src="/images/trans1.gif" /></a></p>' +
'<h4 style="margin-top: 3px;">&nbsp;Add URL</h4>' +
'<div style="margin: 10px;">' +
'<form id="frmetag" action="javascript:submitAddUrl1(\'etag\')" method="post">' +
'<input type="hidden" value="' + cat + '" name="bt" />' +
'<input type="hidden" value="' + tag + '" name="t" />' +
'<input name="url" id="textbox" type="text" value="http://" size="50" />' +
'<div style="margin-top: 3px;"><input id="cancel" type="button" name="cancel" value="Cancel" ' +
'onclick=\'clearDiv("etag")\' />' +
'&nbsp;<input id="submit" type="submit" name="submit" value="OK" /></div>' +
'</form></div></div>';

}

function shAddMp3F1(cat, tag)
{
	var eDiv = document.getElementById('etag');
	
	eDiv.innerHTML = '<div id="popIn">' +
'<p id="xBut"><a id="xBut" href="javascript:clearDiv(\'etag\')"><img border=0 src="/images/trans1.gif" /></a></p>' +
'<h4 style="margin-top: 3px;">&nbsp;Add MP3</h4>' +
'<div style="margin: 10px;">' +
'<form name="addEntry" id="frmetag" action="javascript:submitIt(\'etag\')" method="post">' +
'<input type="hidden" value="' + cat + '" name="bt" />' +
'<input type="hidden" value="' + tag + '" name="t" />' +
'<input type="hidden" value="new" name="eid" />' +
'<input type="hidden" value="mp3" name="itype" />' +
'<p style="margin-top: 5px; margin-bottom: 5px;" >URL to .MP3 File:<br /><input name="url" id="textbox" type="text" value="http://" size="50" /></p>' +
'<p style="margin-top: 5px; margin-bottom: 5px;" >Title:<br /><input name="et" id="textbox"' +
' type="text" value="" size="50" maxlength="80" /></p>'+
'<p style="margin-bottom: 5px;" >Description - <input name="remlen" id="textbox" type="text" '+
' value="400" size="2" readonly="true">&nbsp;characters left<br /><textarea '+
' wrap="virtual" id="textbox" style="width: 495px; height: 162px" name="etx" rows="10" cols="60" '+
' onKeyUp="limits(400,0)"></textarea></p>' +
'<div style="margin-top: 3px;"><input id="cancel" type="button" name="cancel" value="Cancel" ' +
'onclick=\'clearDiv("etag")\' />' +
'&nbsp;<input id="submit" type="submit" name="submit" value="OK" /></div>' +
'</form></div></div>';
}

function shAddDownloadF1(cat, tag)
{
	var eDiv = document.getElementById('etag');
	
	eDiv.innerHTML = '<div id="popIn">' +
'<p id="xBut"><a id="xBut" href="javascript:clearDiv(\'etag\')"><img border=0 src="/images/trans1.gif" /></a></p>' +
'<h4 style="margin-top: 3px;">&nbsp;Add Download (PAD URL)</h4>' +
'<div style="margin: 10px;">' +
'<p><b>Pad File File Submission</b><br />Enter your PAD File URL</p>' +
'<form name="addEntry" id="frmetag" action="javascript:submitIt(\'etag\')" method="post">' +
'<input type="hidden" value="pad" name="itype" />' +
'<input type="hidden" value="pad" name="eid" />' +
'<input type="hidden" value="x" name="et" />' +
'<input type="hidden" value="x" name="etx" />' +
'<input type="hidden" value="' + cat + '" name="bt" />' +
'<input type="hidden" value="' + tag + '" name="t" />' +
'<input name="url" id="textbox" type="text" value="http://" size="50" />' +
'<div style="margin-top: 3px;"><input id="cancel" type="button" name="cancel" value="Cancel" ' +
'onclick=\'clearDiv("etag")\' />' +
'&nbsp;<input id="submit" type="submit" name="submit" value="OK" /></div>' +
'</form></div></div>';

}


function shAddVideoF1(cat, tag)
{
	var eDiv = document.getElementById('etag');
	
	eDiv.innerHTML = '<div id="popIn">' +
'<p id="xBut"><a id="xBut" href="javascript:clearDiv(\'etag\')"><img border=0 src="/images/trans1.gif" /></a></p>' +
'<h4 style="margin-top: 3px;">&nbsp;Add Video</h4>' +
'<div style="margin: 10px;">' +
'<form id="frmetag" action="javascript:submitAddUrl1(\'etag\')" method="post">' +
'<input type="hidden" value="' + cat + '" name="bt" />' +
'<input type="hidden" value="' + tag + '" name="t" />' +
'Enter a URL for a page at YouTube.com, Google Video, GoFish.com, Grouper.com, MetaCafe.com, or a URL for a .wmv, .swf, or .mov.  The video you submit will be embedded on this page.<br />' +
'<input name="url" id="textbox" type="text" value="http://" size="50" />' +
'<div style="margin-top: 3px;"><input id="cancel" type="button" name="cancel" value="Cancel" ' +
'onclick=\'clearDiv("etag")\' />' +
'&nbsp;<input id="submit" type="submit" name="submit" value="OK" /></div>' +
'</form></div></div>';

}
function shAddCodeF1(cat, tag)
{
	var eDiv = document.getElementById('etag');
	
	eDiv.innerHTML = '<div id="popIn">' +
'<p id="xBut"><a id="xBut" href="javascript:clearDiv(\'etag\')"><img border=0 src="/images/trans1.gif" /></a></p>' +
'<h4 style="margin-top: 3px;">&nbsp;Add Code</h4>' +
'<div style="margin: 10px;">' +
'<form name="addEntry" id="frmetag" action="javascript:submitIt(\'etag\')" method="post">' +
'<input type="hidden" value="' + cat + '" name="bt" />' +
'<input type="hidden" value="' + tag + '" name="t" />' +
'<input type="hidden" value="new" name="eid" />' +
'<input type="hidden" value="code" name="url" />' +
'<input type="hidden" value="code" name="itype" />' +
'<p style="margin-top: 5px; margin-bottom: 5px;" >Title:<br /><input name="et" id="textbox"' +
' type="text" value="" size="50" maxlength="80" /></p>'+
'<p style="margin-bottom: 5px;" >Code - <input name="remlen" id="textbox" type="text" '+
' value="8000" size="4" readonly="true">&nbsp;characters left<br /><textarea '+
' wrap="virtual" id="textbox" style="width: 495px; height: 162px" name="etx" rows="10" cols="60" '+
' onKeyUp="limits(8000,0)"></textarea></p>' +
'<div style="margin-top: 3px;"><input id="cancel" type="button" name="cancel" value="Cancel" ' +
'onclick=\'clearDiv("etag")\' />' +
'&nbsp;<input id="submit" type="submit" name="submit" value="OK" /></div>' +
'</form></div></div>';
}

function getLinks0()
{
	var eDiv = document.getElementById('dig');
	
	eDiv.innerHTML = '<div id="popIn">' +
'<p id="xBut"><a id="xBut" href="javascript:clearDiv(\'dig\')"><img border=0 src="/images/trans1.gif" /></a></p>' +
'<h4 style="margin-top: 3px;">&nbsp;Extract Links</h4>' +
'<div style="margin: 10px;">' +
'<form id="frmdig" action="javascript:getLinks1()" method="post">' +
'<input name="url" id="textbox" type="text" value="http://" size="50" />' +
'<div style="margin-top: 3px;"><input id="cancel" type="button" name="cancel" value="Cancel" ' +
'onclick=\'clearDiv("dig")\' />' +
'&nbsp;<input id="submit" type="submit" name="submit" value="OK" /></div>' +
'</form></div></div>';

}

function shNewCatForm()
{
	var sTemp = encodeURIComponent('<h4 id="h"><a href="javascript:shNewCatForm()">Create a New Category</a></h4>');
	
	var ncDiv = document.getElementById('newCatFormDiv');
	
	ncDiv.innerHTML = '<div id="popIn" style="margin:10px;"><p id="xBut"><a id="xBut" href="javascript:setDiv(\'newCatFormDiv\',\'' + sTemp + '\')"><img border=0 src="/images/trans1.gif" /></a></p><h4>&nbsp;Create a New Category</h4><div style="margin: 5px;" clear:"left";>' +
'<form name="newCatForm" id="newCatForm" action="javascript:submitNewCat()" method="get">' +
'<p style="margin-top: 5px;">Category - Enter a word/phrase describing the high-level category, such as music, software, science, etc.</p>' +
'<input name="bt" id="textbox" type="text" value="" size="60"  />' +
'<p style="margin-top: 5px;">Tag Word/Phrase</p>' +
'<input name="t" id="textbox" type="text" value="" size="60"  />' +
'<p style="margin-top: 5px;">1-Line Description</p>' +
'<input name="td" id="textbox" type="text" value="" size="60"  />' +
'<p style="margin-top: 5px;"><input id="submit" type="submit" name="submit" value="Create" />&nbsp;' +
'<input id="cancel" type="button" name="cancel" value="Cancel" onclick="javascript:setDivEnc(\'newCatFormDiv\',\'' + sTemp + '\')" />&nbsp;<span id="newCatWait">&nbsp;</span></p>' +
'</form>' +
'</div></div>';

}

function submitNewCat() {
      if (xmlHttpWaiting == 0) {
      	if ((document.newCatForm.bt.value.length == 0) ||
      		(document.newCatForm.t.value.length == 0) ||
      		(document.newCatForm.td.value.length == 0))
      	{
			// Do nothing..
      	}
      	else
      	{
      		// Clear the catList cached records.
      		//clearCache(akListCats);
			document.getElementById("newCatWait").innerHTML = "<b>Processing Request</b>&nbsp;<img src='/images/working12.gif' />";	  	
			var parameters="c=newTag&bt=" +
				encodeURIComponent(document.newCatForm.bt.value) +
				"&t=" +
				encodeURIComponent(document.newCatForm.t.value) +
				"&td=" +
				encodeURIComponent(document.newCatForm.td.value) +
				"&scr=" + gMwScr;
			xpDivN(parameters);
		}	
	}
    //else {
		//document.getElementById("newCatDiv").style.visibility = 'hidden'; 
    	//return false;
	//}
}

function submitNewTag() {
      if (xmlHttpWaiting == 0) {
      	if ((document.newTagForm.bt.value.length == 0) ||
      		(document.newTagForm.t.value.length == 0) ||
      		(document.newTagForm.td.value.length == 0))
      	{
			// Do nothing.
      	}
      	else
      	{
			document.getElementById("newTagWait").innerHTML = "&nbsp;&nbsp;Processing&nbsp;<img src='/images/working12.gif' />";
			var parameters="c=newTag&bt=" +
	  	  		encodeURIComponent(document.newTagForm.bt.value) +
	  	  		"&let=" +
	  	  		gTagLet[document.newTagForm.bt.value] +
	  	  		"&t=" +
	  	  		encodeURIComponent(document.newTagForm.t.value) +
	  	  		"&td=" +
	  	  		encodeURIComponent(document.newTagForm.td.value) +
				"&scr=" + gMwScr;
	  	  	xpDivN(parameters);
      	}
	}
}

function highlight() {

	var t = document.highForm.terms.value.toLowerCase();
	t = t.trim();

	for (var i = 0; i < 500; i++) {
		
		var e0 = document.getElementById("ee" + i);
		var e1 = document.getElementById("tit" + i);
		var e2 = document.getElementById("desc" + i);
		if (e0 && e1 && e2) {

			var s = e2.innerHTML.toLowerCase() + " " + e1.innerHTML.toLowerCase();
			if (s.indexOf(t) >= 0) {
				e0.style.backgroundColor = "#FFE2C6";
			} else {
				e0.style.backgroundColor = "#FFFFFF";
			}
		}
		else {
			break;
		}
	}

}

function submitSearch() {
      if (xmlHttpWaiting == 0) {
      	var t = document.searchForm.terms.value;
      	t = t.trim();
      	if (t.length == 0)
      	{
			// Do nothing.
      	}
      	else
      	{
			document.getElementById("searchWait").innerHTML = "&nbsp;&nbsp;Searching&nbsp;<img src='/images/working12.gif' />";
			var encT = encodeURIComponent(t);
			var parameters="c=search&s=" + encT;
			
			var key = cKeySearch(t);
			var cacheEntry = gCache[key];
			if (cacheEntry) 
			{
				// Use the cached results.
				document.getElementById('searchWait').innerHTML = ""; 
	            updatepage('dig',cacheEntry);
			}
			else
			{
				// Send the search request to the server.
			    var xmlHttpReq = false;
			    var self = this;
			    
			    self.xmlHttpReq = getHttpReqObj();
			    initHttpReq(self.xmlHttpReq,parameters);
			  
			    self.xmlHttpReq.onreadystatechange = function() {
			        if (self.xmlHttpReq.readyState == 4) {
			        	cacheResults(key,akSearch,self.xmlHttpReq.responseText);
						document.getElementById('searchWait').innerHTML = ""; 
			            updatepage('dig',self.xmlHttpReq.responseText);
			        }
			    }
			  self.xmlHttpReq.send(parameters);
			  xmlHttpWaiting = 1;
			}
      	}
	}
}

function submitEditTag(divId) {
      if (xmlHttpWaiting == 0) {
		var formId = "frm" + divId;
      	if (document.getElementById(formId).td.value.length == 0)
      	{
      		// Do nothing...
      	}
      	else
      	{
			var parameters="c=editTag&bt=" +
	  	  		encodeURIComponent(document.getElementById(formId).bt.value) +
	  	  		"&t=" +
	  	  		encodeURIComponent(document.getElementById(formId).t.value) +
	  	  		"&td=" +
	  	  		encodeURIComponent(document.getElementById(formId).td.value);
      		
      		var divTagDesc = document.getElementById('divTagDesc');
      		if (divTagDesc != null)
      		{
      			divTagDesc.innerHTML = document.getElementById(formId).td.value;
      		}

      		xpDivN(parameters);
      	}
	}
	document.getElementById(divId).innerHTML = "";
}

function submitAddUrl1(divId) {
      if (xmlHttpWaiting == 0) {
		var formId = "frm" + divId;
      	if (document.getElementById(formId).url.value.length == 0)
      	{
      		// Do nothing...
      	}
      	else
      	{
			var parameters="c=addUrlForm2&bt=" +
	  	  		encodeURIComponent(document.getElementById(formId).bt.value) +
	  	  		"&t=" +
	  	  		encodeURIComponent(document.getElementById(formId).t.value) +
	  	  		"&div=" +
	  	  		encodeURIComponent(divId) +
	  	  		"&url=" +
	  	  		encodeURIComponent(document.getElementById(formId).url.value);
	  	  	
			document.getElementById(divId).innerHTML = "<b>Checking URL&nbsp;<img src='/images/working12.gif' /></b>";
	  	  	
      		xpDiv(parameters, divId);
      	}
	}
}
function submitIt(divId) {
      if (xmlHttpWaiting == 0) {
		var formId = "frm" + divId;
      	if (document.getElementById(formId).url.value.length == 0)
      	{
      		// Do nothing...
      	}
      	else
      	{
			var parameters="c=addIt2&bt=" +
	  	  		encodeURIComponent(document.getElementById(formId).bt.value) +
	  	  		"&t=" +
	  	  		encodeURIComponent(document.getElementById(formId).t.value) +
	  	  		"&itype=" +
	  	  		encodeURIComponent(document.getElementById(formId).itype.value) +
	  	  		"&et=" +
	  	  		encodeURIComponent(document.getElementById(formId).et.value) +
	  	  		"&eid=" +
	  	  		encodeURIComponent(document.getElementById(formId).eid.value) +
	  	  		"&etx=" +
	  	  		encodeURIComponent(document.getElementById(formId).etx.value) +
	  	  		"&div=" +
	  	  		encodeURIComponent(divId) +
	  	  		"&url=" +
	  	  		encodeURIComponent(document.getElementById(formId).url.value);
	  	  	
			document.getElementById(divId).innerHTML = "<b>Adding&nbsp;<img src='/images/working12.gif' /></b>";
	  	  	
      		xpDivN(parameters, divId);
      	}
	}
}

function addFriend(divId) {
      if (xmlHttpWaiting == 0) {
		var formId = "frm" + divId;
		
			var parameters="c=addFriend&bt=" +
	  	  		encodeURIComponent(document.getElementById(formId).bt.value) +
	  	  		"&t=" +
	  	  		encodeURIComponent(document.getElementById(formId).t.value) +
	  	  		"&et=" +
	  	  		encodeURIComponent(document.getElementById(formId).et.value) +
	  	  		"&url=" +
	  	  		encodeURIComponent(document.getElementById(formId).url.value) +
	  	  		"&url2=" +
	  	  		encodeURIComponent(document.getElementById(formId).url2.value);
	  	  	
			document.getElementById(divId).innerHTML = "<b>Submitting&nbsp;<img src='/images/working12.gif' /></b>";
	  	  	
      		xpDivN(parameters, divId);
	}
}

function genFriendSpace(divId) {
      if (xmlHttpWaiting == 0) {
		var formId = "frm" + divId;
		
			var parameters="c=genFriendSpace&bt=" +
	  	  		encodeURIComponent(document.getElementById(formId).bt.value) +
	  	  		"&et=" +
	  	  		encodeURIComponent(document.getElementById(formId).et.value) +
	  	  		"&nc=" +
	  	  		encodeURIComponent(document.getElementById(formId).nc.value) +
	  	  		"&iw=" +
	  	  		encodeURIComponent(document.getElementById(formId).iw.value) +
	  	  		"&ih=" +
	  	  		encodeURIComponent(document.getElementById(formId).ih.value) +
	  	  		"&t=" +
	  	  		encodeURIComponent(document.getElementById(formId).t.value);
	  	  	
			document.getElementById(divId).innerHTML = "<b>Generating&nbsp;<img src='/images/working12.gif' /></b>";
	  	  	
      		xpDivN(parameters, divId);
	}
}
function genBlogFriendSpace(divId) {
      if (xmlHttpWaiting == 0) {
		var formId = "frm" + divId;
		
			var ck1 = "no";
			if (document.getElementById(formId).blogt.checked) { ck1 = "checked"; }
			
			var parameters="c=genBlogFriendSpace&bt=" +
	  	  		encodeURIComponent(document.getElementById(formId).bt.value) +
	  	  		"&et=" +
	  	  		encodeURIComponent(document.getElementById(formId).et.value) +
	  	  		"&nc=" +
	  	  		encodeURIComponent(document.getElementById(formId).nc.value) +
	  	  		"&iw=" +
	  	  		encodeURIComponent(document.getElementById(formId).iw.value) +
	  	  		"&ih=" +
	  	  		encodeURIComponent(document.getElementById(formId).ih.value) +
	  	  		"&blogt=" + ck1 +
	  	  		"&t=" +
	  	  		encodeURIComponent(document.getElementById(formId).t.value);
	  	  	
			document.getElementById(divId).innerHTML = "<b>Generating&nbsp;<img src='/images/working12.gif' /></b>";
	  	  	
      		xpDivN(parameters, divId);
	}
}

function getLinks1() {
      if (xmlHttpWaiting == 0) {
		var formId = "frmdig";
      	if (document.getElementById(formId).url.value.length == 0)
      	{
      		// Do nothing...
      	}
      	else
      	{
			var parameters="c=getLinks1&url=" +
	  	  		encodeURIComponent(document.getElementById(formId).url.value);
	  	  	
			document.getElementById('dig').innerHTML = "<b>Fetching URL&nbsp;<img src='/images/working12.gif' /></b>";
	  	  	
      		xpDivN(parameters);
      	}
	}
}

function submitAddUrl2(divId) {

      if (xmlHttpWaiting == 0) {
		var formId = "frm" + divId;

      	if ( (document.getElementById(formId).et.value.length == 0) ||
      		 (document.getElementById(formId).etx.value.length == 0) )
      	{
      		// Do nothing...
      	}
      	else
      	{
      		var frm = document.getElementById(formId);
			var parameters="c=addEntry&bt=" +
	  	  		encodeURIComponent(frm.bt.value) +
	  	  		"&t=" +
	  	  		encodeURIComponent(frm.t.value) +
	  	  		"&et=" +
	  	  		encodeURIComponent(frm.et.value) +
	  	  		"&etx=" +
	  	  		encodeURIComponent(frm.etx.value) +
	  	  		"&div=" +
	  	  		encodeURIComponent(divId) +
	  	  		"&url=" +
	  	  		encodeURIComponent(frm.url.value);

			document.getElementById("aw"+divId).innerHTML = "<b>Submitting&nbsp;<img src='/images/working12.gif' /></b>";
      		xpDivN(parameters);
      		
      	}
	
	}
}

function jsSubmitUrl(divId) {

      if (xmlHttpWaiting == 0) {

      	if ( (document.getElementById("jsSubmitForm").et.value.length == 0) ||
      		 (document.getElementById("jsSubmitForm").etx.value.length == 0) )
      	{
      		// Do nothing...
      	}
      	else
      	{
      		var frm = document.getElementById("jsSubmitForm");

      		// Get the category / tag...
      		var cat = frm.ncat.value;
      		var tag = frm.ntag.value;
      		cat = cat.trim();
      		tag = tag.trim();
      		if ((cat.length == 0) || (tag.length == 0))
      		{
      			cat = frm.bt.options[frm.bt.selectedIndex].value;
      			tag = frm.t.options[frm.t.selectedIndex].value;
      		}
      		
			var parameters="c=addEntry&js=1&bt=" +
	  	  		encodeURIComponent(cat) +
	  	  		"&t=" +
	  	  		encodeURIComponent(tag) +
	  	  		"&et=" +
	  	  		encodeURIComponent(frm.et.value) +
	  	  		"&etx=" +
	  	  		encodeURIComponent(frm.etx.value) +
	  	  		"&url=" +
	  	  		encodeURIComponent(frm.url.value);
	  	  	
	  	  	if (frm.popup) {
	  	  		parameters = parameters + "&popup=1";
	  	  	}
	  	  	
			document.getElementById(divId).innerHTML = "<b>Submitting&nbsp;<img src='/images/working12.gif' /></b>";
			
			// This is good for FireFox with the popup, but not IE...
			// This will return the jsSaved HTML.
			var ua = navigator.userAgent;
			if (ua.indexOf('Firefox') != -1)
			{
				// The response is jsSaved.html, which closes the window...
				window.location = "/tapp/db.exe?" + parameters;
			}
			else
			{
				// Do an XMLHTTP call and when complete, set the window.location to the original URL.
				postAndGoto(parameters+"&b=ie",frm.url.value);
			}
      		//postAndCloseWin(parameters);
      		
      	}
	
	}
}

function submitComment(divId) {
      if (xmlHttpWaiting == 0) {
		var formId = "euf" + divId;
      	if (document.getElementById(formId).etx.value.length == 0)
      	{
      		// Do nothing...
      	}
      	else
      	{
      		var frm = document.getElementById(formId);

      		var tag = frm.t.value;
			var cat = frm.bt.value;
      		
			var parameters="c=addComment&bt=" +
	  	  		encodeURIComponent(cat) +
	  	  		"&t=" +
	  	  		encodeURIComponent(tag) +
	  	  		"&etx=" +
	  	  		encodeURIComponent(frm.etx.value) +
	  	  		"&id=" +
	  	  		encodeURIComponent(frm.cmtid.value) +
	  	  		"&div=" +
	  	  		encodeURIComponent(divId) +
	  	  		"&url=" +
	  	  		encodeURIComponent(frm.url.value);
	  	  	
			document.getElementById("ew"+divId).innerHTML = "<b>Submitting&nbsp;<img src='/images/working12.gif' /></b>";
	  	  	
  			xpDivN(parameters);
      	}
	}
}
function submitEditUrl(divId) {
      if (xmlHttpWaiting == 0) {
		var formId = "euf" + divId;
      	if ( (document.getElementById(formId).et.value.length == 0) ||
      		 (document.getElementById(formId).etx.value.length == 0) )
      	{
      		// Do nothing...
      	}
      	else
      	{
      		var frm = document.getElementById(formId);

      		var tag = frm.t.value;
			var cat = frm.bt.value;
			cat = cat.trim();
			if ((cat.length == 0) && (gMwScr == "showTag"))
			{
				cat = gMwCat;
				tag = gMwTag;
			}
      		
			var parameters="c=addEntry&bt=" +
	  	  		encodeURIComponent(cat) +
	  	  		"&t=" +
	  	  		encodeURIComponent(tag) +
	  	  		"&d=" +
	  	  		encodeURIComponent(frm.d.value) +
	  	  		"&et=" +
	  	  		encodeURIComponent(frm.et.value) +
	  	  		"&etx=" +
	  	  		encodeURIComponent(frm.etx.value) +
	  	  		"&div=" +
	  	  		encodeURIComponent(divId) +
	  	  		"&url=" +
	  	  		encodeURIComponent(frm.url.value) +
	  	  		"&scr=" + gMwScr;
	  	  	
			document.getElementById("ew"+divId).innerHTML = "<b>Submitting&nbsp;<img src='/images/working12.gif' /></b>";
	  	  	
  			xpDivN(parameters);
      	}
	}
}

function submitX(divId) {
	
      if (xmlHttpWaiting == 0) {

		var formId = "xf" + divId;
  		var frm = document.getElementById(formId);

      	if ( (frm.et.value.length == 0) ||
      		 (frm.etx.value.length == 0) || 
      		 (frm.kw.value.length == 0)
      		) {
      		// Do nothing...
      		alert("One or more required fields are empty!");
      	} else {
      		
			var parameters="c=submitX&et=" +
	  	  		encodeURIComponent(frm.et.value) +
	  	  		"&etx=" +
	  	  		encodeURIComponent(frm.etx.value) +
	  	  		"&kw=" +
	  	  		encodeURIComponent(frm.kw.value) +
	  	  		"&div=" +
	  	  		encodeURIComponent(divId) +
	  	  		"&url=" +
	  	  		encodeURIComponent(frm.url.value);
	  	  		  	  	
			xpDivN(parameters);
      	}
    }
}


function submitSettings() {
      if (xmlHttpWaiting == 0) {
      	if ( (document.settingsForm.pwd.value.length == 0) ||
      		 (document.settingsForm.pwd2.value.length == 0) )
      	{
      		// Do nothing...
      	}
      	else
      	{
      		var frm = document.settingsForm;
			var parameters="c=accUpdate&l=" +
	  	  		encodeURIComponent(frm.l.value) +
	  	  		"&pwd=" +
	  	  		encodeURIComponent(frm.pwd.value) +
	  	  		"&pwd2=" +
	  	  		encodeURIComponent(frm.pwd2.value) +
	  	  		"&hurl=" +
	  	  		encodeURIComponent(frm.hurl.value) +
	  	  		"&friendid=" +
	  	  		encodeURIComponent(frm.friendid.value) +
	  	  		"&adsenseid=" +
	  	  		encodeURIComponent(frm.adsenseid.value) +
	  	  		"&dl=" +
	  	  		encodeURIComponent(frm.dl.value) +
	  	  		"&dp=" +
	  	  		encodeURIComponent(frm.dp.value) +
	  	  		"&fl=" +
	  	  		encodeURIComponent(frm.fl.value) +
	  	  		"&fp=" +
	  	  		encodeURIComponent(frm.fp.value) +
	  	  		"&bll=" +
	  	  		encodeURIComponent(frm.bll.value) +
	  	  		"&blp=" +
	  	  		encodeURIComponent(frm.blp.value) +
	  	  		"&smpl=" +
	  	  		encodeURIComponent(frm.smpl.value) +
	  	  		"&smpp=" +
	  	  		encodeURIComponent(frm.smpp.value) +
	  	  		"&nvl=" +
	  	  		encodeURIComponent(frm.nvl.value) +
	  	  		"&nvp=" +
	  	  		encodeURIComponent(frm.nvp.value) +
	  	  		"&bml=" +
	  	  		encodeURIComponent(frm.bml.value) +
	  	  		"&bmp=" +
	  	  		encodeURIComponent(frm.bmp.value) +
	  	  		"&jotl=" +
	  	  		encodeURIComponent(frm.jotl.value) +
	  	  		"&jotp=" +
	  	  		encodeURIComponent(frm.jotp.value) +
	  	  		"&scl=" +
	  	  		encodeURIComponent(frm.scl.value) +
	  	  		"&scp=" +
	  	  		encodeURIComponent(frm.scp.value) +
	  	  		"&shdl=" +
	  	  		encodeURIComponent(frm.shdl.value) +
	  	  		"&shdp=" +
	  	  		encodeURIComponent(frm.shdp.value) +
	  	  		"&sprl=" +
	  	  		encodeURIComponent(frm.sprl.value) +
	  	  		"&sprp=" +
	  	  		encodeURIComponent(frm.sprp.value) +
	  	  		"&bckl=" +
	  	  		encodeURIComponent(frm.bckl.value) +
	  	  		"&bckp=" +
	  	  		encodeURIComponent(frm.bckp.value) +
	  	  		"&tagline=" +
	  	  		encodeURIComponent(frm.tagline.value);
	  	  	
			document.getElementById('settingsInProg').innerHTML = "&nbsp;<b>Submitting&nbsp;<img src='/images/working12.gif' /></b>";
	  	  	
      		xpDiv(parameters, 'settingsInProg');
      	}
	}
}


var xmlHttpWaiting = 0;

function getHttpReqObj() {
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {
    	return false;
    }
}

function initHttpReq(obj, parameters)
{
	obj.open('POST', '/tapp/db.exe', true);
	obj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	obj.setRequestHeader("Content-length", parameters.length);
	obj.setRequestHeader("Connection", "close");
}

function clearDiv(clearId) {
	document.getElementById(clearId).innerHTML = ""; 
}

function setDiv(divId, value) {
	document.getElementById(divId).innerHTML = value; 
}

// Set the div with a value that needs to be decoded.
function setDivEnc(divId, encValue) {
	document.getElementById(divId).innerHTML = decodeURIComponent(encValue); 
}


function xpDiv(parameters, divId) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', '/tapp/db.exe', true);
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(divId,self.xmlHttpReq.responseText);
        }
    }
    
  self.xmlHttpReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  self.xmlHttpReq.setRequestHeader("Content-length", parameters.length);
  self.xmlHttpReq.setRequestHeader("Connection", "close");
  self.xmlHttpReq.send(parameters);
  xmlHttpWaiting = 1;
  
}

function postAndGoto(parameters, targetUrl) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', '/tapp/db.exe', true);
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            window.location = targetUrl;
        }
    }
    
  self.xmlHttpReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  self.xmlHttpReq.setRequestHeader("Content-length", parameters.length);
  self.xmlHttpReq.setRequestHeader("Connection", "close");
  self.xmlHttpReq.send(parameters);
  xmlHttpWaiting = 1;
  
}



// The server's response indicates the divs to actually update.
function xpDivN(parameters) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', '/tapp/db.exe', true);
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepageN(self.xmlHttpReq.responseText);
        }
    }
    
  self.xmlHttpReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  self.xmlHttpReq.setRequestHeader("Content-length", parameters.length);
  self.xmlHttpReq.setRequestHeader("Connection", "close");
  self.xmlHttpReq.send(parameters);
  xmlHttpWaiting = 1;
  
}

function updatepageN(str){
	var hParts = str.split('|');
	for (var i = 0; i < hParts.length; i += 2) {
		if (hParts[i] == "alert") {
			alert(hParts[i+1]);
		}
		else if (hParts[i] == "0") {
			// Ignore this part..
		}
		else if (hParts[i] == "goto") {
			window.location = hParts[i+1];
			break;
		}
		else if (hParts[i] == "open") {
			window.open(hParts[i+1]);
			break;
		}
		else if (hParts[i] == "v2") {
			var pLeft = screen.width - 600;
			//var ua = navigator.userAgent;
			//if (ua.indexOf('Firefox') != -1) {
				var w = window.open(hParts[i+1],"v2");
			//} else {
			//	var w = window.open(hParts[i+1],"v2");
			//}
			w.focus();
		}
		else if (hParts[i] == "eval") {
			eval(hParts[i+1]);
		}
		else {
			var hp = document.getElementById(hParts[i]);
			if (hp) {
				hp.innerHTML = hParts[i+1];	
			} else {
				alert("Error: page part not found (" + hParts[i] + ")");
			}
		}
	}
    xmlHttpWaiting = 0;
}

function updatepage(divId,str){
    document.getElementById(divId).innerHTML = str;
    xmlHttpWaiting = 0;
}

function makeBtDivs(n) {
	var s = "<table><tr><td>";
	for (var i=0; i<n; i++) {
		s = s + '<div id="bt' + i + '"></div>';
		if (i == 9) {
			s = s + "</td><td>";
		}
	}
	s = s + "</td></tr></table>";
	document.getElementById('tlist').innerHTML = s;
}

function bq(idx,tag,p) {	
	var s = "<p>";
	if (btOn) {
		if (p == 1) {
			s = s + '<a href="javascript:rmTagIdx(\'' + btCat + "','" + tag + "','" + btLet + "','" + idx + "')\"><img title=\"Remove Tag from Left Rail\" src=\"/images/minus8.gif\" border=0 /></a>&nbsp;";
		} else {
			s = s + '<a href="javascript:addTagIdx(\'' + btCat + "','" + tag + "','" + btLet + "','" + idx + "')\"><img title=\"Add Tag to Left Rail\" src=\"/images/plus8.gif\" border=0 /></a>&nbsp;";
		}
	}
	s = s + "<a title=\"View Tag\" href=\"javascript:showTagBt('" + btCat + "','" + tag + "','" + btLet + "','" + btCLet + "')\">" + tag + "</a></p><div id=\"etg" + idx + "\"></div>";
	
	document.getElementById('bt'+idx).innerHTML = s;
}

