// qb3.js $Revision: 1.1 $ Sun May 09 2010 23:00
function getStarted()
{
if (top != self) top.location.replace(self.location.href.toLowerCase());
try { document.getElementById("rightnav").style.display = "none"; } catch (ee) {}
var topics = getMyElement("li", "page-item-246");
if (topics != null) { topics.onclick = doTopics; }
try { document.search.s.onfocus = prepSearch; } catch (e) {}
var a = document.getElementsByTagName("a");
for (var i = 0; i < a.length; i++)
{ if (a[i].getAttribute("rel") == "external") a[i].target = "_blank"; }
window.defaultStatus = "Mitch Miller's Web"; 
return true;
}
function getMyElement(eType, klass)
{
var lists = document.getElementsByTagName(eType);
var retval = null;
for (var i = 0; i < lists.length && retval == null; i++)
{ if ((lists[i].className.indexOf(klass)) != -1) retval = lists[i]; }
return retval;
}
function doTopics()
{
var content = document.getElementById("content");
var side = document.getElementById("sidebarright");
var rnav = document.getElementById("rightnav");
if (content == null || side == null || rnav == null) return true;
if (rnav.style.display == "none")
{
content.style.marginRight = "195px";
rnav.style.display = "block";
side.style.display = "block";
loadTextDiv('/php/topics011010.php', 'sidebarright', null);
}
else
{
rnav.style.display = "none";
side.style.display = "none";
content.style.marginRight = "10px";
}
return false;
}
function byeBye() { window.defaultStatus = ""; }
function prepSearch()
{
if (document.search.s.value.substr(0, 6) == 'Search')
document.search.s.value = "";
return true;
}
function getRequest()
{
var xmlreq = false;
if (window.XMLHttpRequest)
{
xmlreq = new XMLHttpRequest();
return xmlreq;
}
if (window.ActiveXObject)
{
try { xmlreq = new ActiveXObject("Msxml2.XMLHTTP"); }
catch (err) { xmlreq = false; }
if (xmlreq == false)
{
try { xmlreq = new ActiveXObject("Microsoft.XMLHTTP"); }
catch (err) { xmlreq = false; }
}
}
return xmlreq;
}
function loadTextDiv(cgi, div, query)
{
var answer = "";
var command, elem, program, req, ok = false;
if (cgi == null || div == null) return false;
if ((elem = document.getElementById(div)) == null ) return false;
program = (cgi.charAt(0) == '/') ? cgi : '/cgi-bin/' + cgi + '.cgi';
command = (query == null) ? program : program + '?' + escape(query);
if ((req = getRequest()) == false) return false;
req.open("GET", command, false);
req.send(null);
if (req.status != 204)
{
if (req.status == 200) ok = true;
answer = req.responseText; 
}
elem.innerHTML = answer;
return ok;
}

if (window.addEventListener)
{
window.addEventListener('load', getStarted, false);
window.addEventListener('unload', byeBye, false);
}
else
{
window.attachEvent('onload', getStarted);
window.attachEvent('onunload', byeBye);
}

