<!--

function showWarnAlert(){
   alert('Since the Amish don’t have computers,\nthis virus works on the honor system.\n\nPlease delete all the files on your C:\\ Drive.');
   document.getElementById('tbwarn').style.display='none';
}

function left(str, n){
   if (n <= 0)
       return "";
   else if (n > String(str).length)
       return str;
   else
       return String(str).substring(0,n);
}

function getURL() 
{
   var currentUrl = window.location;
   return currentUrl
}

function checkURL(){
   if (left(currentUrl,19) == "http://barthost.net" || left(currentUrl,23) == "http://www.barthost.net"){
      //window.location = "no_content_message.html";
      window.location = "barthost/bh_index.php";
   }
   
   if (left(currentUrl,21) == "http://wilkesclan.com"){
      window.location = "wilkesclan/index.php";
   }
}
   
function blockURL(){
   if (left(currentUrl,19) == "http://barthost.net" || left(currentUrl,23) == "http://www.barthost.net"){
      window.location = "no_content_message.html";
   }
}

function openPage(ypage){
   //window.location = "index.php?page="+ypage;   
   var nscroll= document.getElementById('hidscroll').value;
   window.location = ypage+"&urlscroll="+nscroll;   
}

function handleErrors(yMessage,yUrl,yLine){
   if (yMessage == 'document.getElementById("divdown") is null'){
      // do nothing for these pageload timing errors
   }
   else{
      alert("Error: " + yMessage + "\nURL:" + yUrl + "\nLine #: " + yLine);
   }
   return true;
}

window.onerror = window.handleErrors;
document.oncontextmenu="return false";

// pop-up menu code

   // IE EVENT HANDLING
   
   function clickMenu(ymenu) {
      //when the custom menu is visible (and capturing events),
      //this handler runs after a click event.  if one of the
      //menu items is clicked, it takes appropriate action.
      //otherwise, it just hides the menu.
      omenu = eval(ymenu);
      omenu.style.display="none";
      el=event.srcElement;
      // the drawings na is no longer used here
      if (el.id=="mnu1") 
         window.location = "drawings_people.php";
      if (el.id=="mnu2") 
         window.location = "drawings_animals.php";
      if (el.id=="mnu3") 
         window.location = "drawings_disney_animals.php";
      if (el.id=="mnu4") 
         window.location = "drawings_disney_people.php";
      if (el.id=="mnu5") 
         window.location = "drawings_sponge_bob.php";
      if (el.id=="mnu6") 
         window.location = "drawings_nick.php";
      if (el.id=="mnu7") 
         window.location = "drawings_incredibles.php";
      if (el.id=="mnu8") 
         window.location = "drawings_spiderman.php";
      if (el.id=="mnu9") 
         window.location = "drawings_super.php";
      if (el.id=="mnu10") 
         window.location = "drawings_star_wars.php";
      if (el.id=="mnu11") 
         window.location = "drawings_robots.php";
      if (el.id=="mnu12") 
         window.location = "drawings_misc.php";
      if (el.id=="mnu13") 
         window.location = "drawings_mythological.php";
      if (el.id=="mnue1") 
         window.location = "exempt.php#TOP";
      if (el.id=="mnue2") 
         window.location = "exempt1.html#1";
      if (el.id=="mnue3") 
         window.location = "exempt2.html#1";
      if (el.id=="mnue4") 
         window.location = "exempt3.html#1";
      if (el.id=="mnue5") 
         window.location = "exempt4.html#1";
      if (el.id=="mnue6") 
         window.location = "exempt5.pdf";
      if (el.id=="mnue7") 
         window.location = "exempt6.pdf";
      if (el.id=="mnue8") 
         window.location = "exempt7.pdf";
      if (el.id=="mnue9") 
         window.location = "exempt8.html#1";
      if (el.id=="mnue10") 
         window.location = "exempt9.html#1";    
      omenu.releaseCapture();
   }
   
   function contextTwice() {
      //this handles the case in div#5 when you might right-click, and then you ctrl-right-click in the same div.
//      if (whichDiv)
//         if (event.srcElement==whichDiv)
//            showMenu();
   }
   
   function toggleMenu() {
       //as the mouse moves over the menuItems, highlight them
       el=event.srcElement;
       if (el.className=="menuItem") {
          el.className="highlightItem";
       } 
       else if (el.className=="highlightItem") {
          el.className="menuItem";
       }
}

   function showMenu(ymenu, yevent) {
      //this function will position and display a nested div that acts like a menu
      var omenu = document.getElementById(ymenu);
      var snav = navigator.userAgent
      snav = snav.toLowerCase();
      if (snav.indexOf('firefox') > 0){
           posx = yevent.pageX;
          posy = yevent.pageY; 
         omenu.style.posTop=posy+document.body.scrollTop;
         omenu.style.posTop=posx+document.body.scrollLeft;
      }
      else{
         omenu.style.posLeft=yevent.clientX+document.body.scrollLeft;
         omenu.style.posTop=yevent.clientY+document.body.scrollTop;
         omenu.setCapture();
      }
      omenu.style.display="block";
   }

   // FIREFOX EVENT HANDLING
   
    function get_mouse(e){
    var x=0;
    var y=0;
        if ('number' == typeof window.scrollX){
                x = e.clientX + window.scrollX;
                y = e.clientY + window.scrollY;
        } 
        else{
                x = event.x + document.body.scrollLeft;
                y = event.y + document.body.scrollTop;
        }
        
        x=x+Xoffset;
        y=y+yyy;
        x=x+"px";
        y=y+"px";
        skn.left = x;
        skn.top  = y;

    }
   
   

// end of pop-up code   

function doMouseover(yobj){
   yobj.style.cursor='pointer'; 
   yobj.style.color='#0000FF';
   yobj.style.textDecoration = 'none';
}

function doMouseout(yobj){
   yobj.style.color='#000000';   
}   

function showTable(yyear){
   stb = "document.all.tb"+yyear;
   otb=eval(stb);
   if (otb.style.display=='none')
      otb.style.display='';
   else   
      otb.style.display='none'
}
         
function preloadImages() { 
   var d=document; 
     if(d.images){ 
        if(!d.MM_p) 
           d.MM_p=new Array();
      var i, j=d.MM_p.length, a=preloadImages.arguments; 
      for(i=0; i < a.length; i++){
           if (a[i].indexOf("#")!=0){ 
             d.MM_p[j]=new Image; 
             d.MM_p[j++].src=a[i];
          }
      }
   }
}

         
function googleSearch(ystring,ytype){
   var ssite = "";
   if (ytype == 1)
      var ssite = "&as_sitesearch=badbartopia.net";
   //var googleWin = window.open("http://www.google.com/search?as_q="+ystring+ssite, "Google",
   //   "height="+(screen.availHeight/2)+",width="+((2*screen.availWidth)/3)+",top=0,left=0, resizable=yes, scrollbar=yes, menubar=yes, toolbar=yes, statusbar=yes,"+
   //      "scrollbars=1;menubar=1,location=1,resizable=yes,directories=1,toolbar=1,status=1");
   //googleWin.focus();
   window.open("http://www.google.com/search?as_q="+ystring+ssite);
}
      
function openBIM(){
   var wwidth=300;
   var wheight=190;
   var wtop=(screen.availHeight-(wheight))/2;
   var wleft=(screen.availWidth-(wwidth))/2;
   var bimWindow = window.open("http://badbartopia.net/bim_login.php", "BIM", "top="+wtop+",left="+wleft+",height="+wheight+",width="+wwidth+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

function Open_Mail(){
   var wwidth=580;
   var wheight=360;
   var wtop=(screen.availHeight-(wheight))/2;
   var wleft=(screen.availWidth-(wwidth))/2;
   var mailWindow = window.open("http://badbartopia.net/mail.html", "winMail", "top="+wtop+",left="+wleft+",height="+wheight+",width="+wwidth+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

function isdefined(variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}

function openStory(ystory){
   var wwidth=800;
   var wheight=600;
   var wtop=(screen.availHeight-(wheight))/2;
   var wleft=(screen.availWidth-(wwidth))/2;
   var sWindow = window.open("dss/"+ystory, "winStory", "top="+wtop+",left="+wleft+",height="+wheight+",width="+wwidth+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
}

function Set_BookMark(yurl,ychap){
   if (ychap > 0)
   {
      if (ychap < 10)
      {
         schap = "00" + ychap;
      }
      if (ychap < 100 && ychap > 9)
      {
         schap = "0" + ychap;   
      }
      if (ychap > 99)
      {
         schap = ychap;
      }
   }
   var sloc = yurl + "#" + schap
   var sgoUrl= "dss/" + sloc;
   var today = new Date();
   var expire = new Date(today.getTime() + 30 * 24 * 60 * 60 * 1000);
   var keyname = 'BOOKMARK=';
   document.cookie=keyname + escape(sgoUrl) + '; path=/; expires=' + expire.toGMTString();
}

function load_page()
{
   var bgwc=document.cookie;
   var char_index = bgwc.indexOf('BOOKMARK=');
   if (char_index > -1)
   {
      char_index=char_index+9;
      var endstr = bgwc.length +1;
      var bm_extract = unescape(bgwc.substring(char_index, endstr));
      var pound_loc = bm_extract.indexOf('#');
      endstr = pound_loc + 4;
      var cookie_value = bm_extract.substring(0,endstr);
      var wwidth=800;
      var wheight=600;
      var wtop=(screen.availHeight-(wheight))/2;
      var wleft=(screen.availWidth-(wwidth))/2;
      window.open(cookie_value,"bookmark","top="+wtop+",left="+wleft+",height="+wheight+",width="+wwidth+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
   }
   else
   {
      alert('No Bookmark found (or bookmark has expired--30 day life).');
   }
}

   
function substitute(baseChar, shiftIdx, action) 
{
   if (baseChar==' ') 
   { 
      return baseChar; 
   }
   if (action) 
   {
      var shiftSum = shiftIdx + this.chars.indexOf(baseChar);
      return (this.chars.charAt((shiftSum < this.chars.length) ? 
      shiftSum : (shiftSum % this.chars.length)));
       }
   else 
   {
          var shiftDiff = this.chars.indexOf(baseChar) - shiftIdx;
          return (this.chars.charAt((shiftDiff < 0) ? 
      shiftDiff + this.chars.length : shiftDiff));
       }
}

function opennewwindow() 
{
   window.open("", "mywindow", "toolbar=0, menubar=0, scrollbars=1, titlebar=0, resizable=1")
}

function clear_keys()
{
   var today = new Date("March 28, 1969");
   var expired = new Date(today.getTime());

   document.cookie="PRINCESS_KEY=null; expires=" + expired.toGMTString();
   document.cookie="SITH_KEY=null; expires=" + expired.toGMTString();
   document.cookie="TEMP_KEY=null; expires=" + expired.toGMTString();
   document.cookie="BNW_KEY=null; expires=" + expired.toGMTString();
   document.cookie="ARCHIVE_KEY=null; expires=" + expired.toGMTString();
   document.cookie="BOOKMARK=null; expires=" + expired.toGMTString();
   
   window.status = 'All passwords for BadBartopia have been reset.';
   alert('Keys cleared.');
}

function HLRow(yCId,yColor)
{
   yCId.style.backgroundColor=yColor;   
}

function NormalRow(yCId, yColor){
   yCId.style.backgroundColor=yColor;   
}

function set_key(ytype)
{

var today = new Date();
var expire = new Date(today.getTime() + 1 * 1 * 30 * 60 * 1000);      // 30 minute expiration
var pswd = document.password.txtpswd.value;
var keyname = "";
//var reroute = "";

   if (pswd.length < 1) 
      alert('You call that a password?')
   else 
   {
      switch(ytype)
      {
      case "P":
         keyname='PRINCESS_KEY=';
         //reroute='main_page.html';
         break;
      case "T":
         keyname='TEMP_KEY=';
         //reroute='downarea.html';
         break;
      case "S":
         keyname='SITH_KEY=';
         //reroute='downarea.html';
         break;
      case "A":
         keyname='ARCHIVE_KEY=';
         //reroute='s_menu.html';
         break;
      case "B":
         keyname='BNW_KEY=';
         //reroute='g_menu.html';
         break;
      }
      document.cookie=keyname + escape(pswd) + '; path=/; expires=' + expire.toGMTString();
      check_key(ytype,'V');
      //window.location=reroute;
   }

}

function D(ystr)
{
   var sresult = '';
   var iloop = 0;
   var ichar = 0;
   var itchar = 0;
   var stchar = '';

   for (iloop=0; iloop<ystr.length-1; iloop++)
   {
      if (iloop<(ystr.length-5))
      {
         ichar = ystr.charCodeAt(iloop);
         itchar = ichar - 5;
         if (itchar<48)
         {
            itchar = 122 - (48-itchar);
         }
         if (itchar>122)
         {
            itchar = (itchar-122) + 48;
         }
         stchar = unescape('%'+itchar.toString(16));
         sresult = sresult + stchar;
      }
   }
   return sresult + ystr.substring(ystr.length-5, ystr.length);
}

function check_key(ytype,yscreen)
{
   var bgwc = document.cookie;
   var index = 0;
   var endstr = 0;
   var cookie_value = '';
   var cp = "";
   var dest = "";
   var reroute = "";

   switch(ytype)
   {
   case "P":
      cp=T('2Hbifx6647'); 
      dest=D('uwnshjxxjx.html');
      index = bgwc.indexOf('PRINCESS_KEY=')+13;
      endstr = index + cp.length;
      reroute="enter_p_key.html";
      break;
   case "T":
      cp=T('9?^a?^oq8');
      dest=D('r~dxyzkk.html');
      index = bgwc.indexOf('TEMP_KEY=')+9;
      endstr = index + cp.length;
      reroute="enter_t_key.html";
      break;
   case "S":
      cp=T('6A^oqeS^abo9');
      dest=D('ifwpdxnij.html');
      index = bgwc.indexOf('SITH_KEY=')+9;
      endstr = index + cp.length;
      reroute="enter_s_key.html";
      break;
   case "A":
      cp=T('6Grifb5');
      dest=D('xdrjsz.html');
      index = bgwc.indexOf('ARCHIVE_KEY=')+12;
      endstr = index + cp.length;
      reroute="../../enter_a_key.html";
      break;
   case "B":
      cp=T('1Pfjlk2');
      dest=D('yjruagx.html');
      index = bgwc.indexOf('BNW_KEY=')+8;
      endstr = index + cp.length;
      reroute="../enter_b_key.html";
      break;
   }

   //alert(dest);
   cookie_value = unescape(bgwc.substring(index, endstr));
   if (cookie_value == cp) 
   {
      if (yscreen=='V')
         window.location = dest;
      else
         if (yscreen.length > 1)
            window.location = yscreen;
   }
   else if (cookie_value != cp) 
   {
      alert ('Access denied.');
      window.location=reroute;
   }
}

function T(ystr)
{
   var sresult = '';
   var iloop = 0;
   var ichar = 0;
   var itchar = 0;
   var stchar = '';

   for (iloop=0; iloop<ystr.length-1; iloop++)
   {
      if (iloop>0)
      {
         if (iloop<ystr.length-1)
         {
            ichar = ystr.charCodeAt(iloop);
            itchar = ichar + 3;
            if (itchar<48)
            {
               itchar = 122 - (48-itchar);
            }
            if (itchar>122)
            {
               itchar = (itchar-122) + 48;
            }
            stchar = unescape('%'+itchar.toString(16));
            sresult = sresult + stchar;
         }
      }
   }
   return sresult;
}

function showalert()
{
   alert("Unfortunately, a solar flare has knocked out the sub-etha communications with the Guide central computers. We hope to have the Guide relocated to a more accommodating solar system in the near future...Thank you for your continued patience.");
}

function setCookie(ykey,ydata)
{
   // cookie expires when browser is closed
   var cookval = ydata;
   document.cookie=ykey+'='+escape(cookval)+'; path=/;'
}

function setPermaCookie(ykey,ydata)
{
   // cookie should  last for a year
   var expdate=new Date();
   expdate.setDate(expdate.getDate()+365);
   var cookval = ydata;
   document.cookie=ykey+'='+escape(cookval)+'; path=/;expires='+expdate;
}

function getCookie(ykey,ylength) 
{
   //length is not being used!
    var start = document.cookie.indexOf(ykey+"=");
    var len = start+ykey.length+1;
    if ((!start) && (ykey != document.cookie.substring(0,ykey.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) 
       end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function getFname(yStr)
{
   var sFileName = ""
   var nloop = 0;
   for (nloop=yStr.length;nloop>1;nloop--)   
   {
      if (yStr.charAt(nloop)=="/")
      {
         sFileName=yStr.substring(nloop+1,yStr.length);
         return sFileName;
      }
   }
}

function changeDiv(yDiv)
{
   sImg = eval("document.all.imgH"+yDiv+".src");
   sDiv = "document.all.div"+yDiv;
   sFile = getFname(sImg);
   if (sFile == "plus.gif")
   {
      scImg = "document.all.imgH"+yDiv+".src = 'http://badbartopia.net/images/minus.gif'";
      eval(scImg);
      scDiv = "document.all.div"+yDiv+".style.display=''";
      eval(scDiv);
   }
   else
   {
      scImg = "document.all.imgH"+yDiv+".src = 'http://badbartopia.net/images/plus.gif'";
      eval(scImg);
      scDiv = "document.all.div"+yDiv+".style.display='none'";
      eval(scDiv);
   }
}

function strtrim() {
    return this.replace(/^\s+/,'').replace(/\s+$/,'');
}
String.prototype.trim = strtrim;

function getParameter(paramName) 
{
   var currentUrl = window.location.search
   //alert(currentUrl);
   var strBegin = currentUrl.indexOf(paramName) + (paramName.length+1)
   var strEnd = currentUrl.indexOf("&",strBegin)

   if (strEnd==-1)
      strEnd = currentUrl.length

   //alert("URL PARAMTER: "+currentUrl.substring(strBegin,strEnd));   
   return currentUrl.substring(strBegin,strEnd)
}

function openViewer(yImg,yDir)
{
   if (yDir == undefined)
      surl="http://badbartopia.net/"+yImg;
   else
      surl="http://badbartopia.net/images/"+yDir+"/"+yImg;
   window.open(surl,'Actual_Image','left=0,top=0,height=480,width=640,resizable');   
   
//   simage=getParameter('IMG');
//   sdir = getParameter('DIR');
//   var wwidth=640;
//   var wheight=480;
//   var wtop=(screen.availHeight-(wheight))/2;
//   var wleft=(screen.availWidth-(wwidth))/2;
//   var sURL = "http://badbartopia.net/viewer.php?IMG="+yImg+"&DIR="+yDir;
//   var Window = window.open(sURL, "winView", "scrolling=auto, resizable=1, width="+wwidth+", height="+wheight+", top="+wtop+", left="+wleft);
}
-->
