
//    tLiScripties.js

function klume() {
    return(0)
}

function findObj(n, d) {
    var p,i,x;  
    if(!d) d=document; 
    if ( (p=n.indexOf("?")) > 0 && parent.frames.length ) {
        d=parent.frames[n.substring(p+1)].document;
        n=n.substring(0,p);
    }
    if (! (x=d[n]) && d.all) x=d.all[n]; 
    for (i=0; !x && i<d.forms.length; i++) x=d.forms[i][n];
    for (i=0; !x && d.layers && i<d.layers.length; i++) x=findObj(n,d.layers[i].document);
    if (!x && document.getElementById) x=document.getElementById(n); 
    return x;
}
function ShowHide() {
    var i,obj,args=ShowHide.arguments;
    for (i=0; i<(args.length-1); i+=2)
    {
        if ((obj=findObj(args[i]))!=null)
        {
            if (obj.style)
                obj = obj.style;
            obj.visibility=args[i+1];
        }
    }
}
function DoPg(theURL) {
  window.open(theURL,'Sattelite','top=10,left=10,height=600,width=800,scrollbars=yes,resizable=no,status=yes')
}
function Manu(theURL) {
  window.open(theURL,'Manumission','top=50,left=50,height=630,width=990,scrollbars=yes,resizable=no,status=yes')
}
function gotoPage(num) {
    window.parent.location="#"+num;
}

fileID="~~";

labelChars="_ABCDEFGHIJKLMNOPQRSTUVWXYZ";
function GD_Jump(label,idx) {
    if (label == "") {
        alert("GD_Jump: label is <null>");
    }
    else {
        dir = "";
        loc = "";
        if (idx>0) {
            for (ch=0;ch<27;ch++)
            {
                lab = "document.GD_"+labelChars.charAt(ch);
                if (eval(lab))
                {
                    eval(lab+".sel.selectedIndex = idx");
                }
            }            
            ch = label.charAt(3).toUpperCase();
        }
        else {
            if (idx==-1)  // from main level (main gluedog, search)
                dir = "./info/gluedog/";
            else
            if (idx==-2)  // one up, two down
                dir = "../info/gluedog/";
            else
                dir = "../../info/gluedog/"; // two up, two down
            if (label.substring(0,3) == "GD_")
                ch = label.charAt(3).toUpperCase();
            else
                ch = label.charAt(0).toUpperCase();
        }
//alert("GD_Jump: ch='"+ch+"' label='"+label+"'");

        if (   (ch >= fileID.charAt(0))
            && (ch <= fileID.charAt(1))
           )
            loc="#"+label;

        else
        if (ch <= "E")
            loc=dir+"gluedog_AE.htm#"+label;

        else
        if (ch <= "K")
            loc=dir+"gluedog_FK.htm#"+label;
        else
        if (ch <= "Q")
            loc=dir+"gluedog_LQ.htm#"+label;
        else
        if (ch <= "S")
            loc=dir+"gluedog_RS.htm#"+label;

        else
            loc=dir+"gluedog_TZ.htm#"+label;
//alert("GD_Jump: loc='"+loc+"'");
        window.parent.location=loc;
        
    }
}

function find_home(curr) {
    curr = curr + ""; // force to string object
    if (curr.indexOf("file:") == 0 ) {
        return curr.substring(0,curr.indexOf("/site/")+5)+"/index.html"
    }
    else {
        return "http://the-Lara-inn.org"
    }
}
function to_tLi() {
    window.parent.location=find_home(window.parent.location)
}
function to_Tol() {
  window.open('http://www.turians.com/cgi-bin/dict.cgi','Turian Dic','top=10,left=10,height=400,width=200,scrollbars=yes,resizable=no,status=yes')
}


//-------------------
//-- Encrypt/Decrypt for Password
//-- http://javascript.internet.com/passwords/ascii-encryption.html

function Encrypt(clearText) {
    cryptText = new String;
    cry = new Array();
    key = new Array();
    TextSize = clearText.length;
    for (i = 0; i < TextSize; i++) {
        rnd = Math.round(Math.random() * 122) + 68;
        cry[i] = clearText.charCodeAt(i) + rnd;
        key[i] = rnd;
    }
    for (i = 0; i < TextSize; i++) {
        cryptText += String.fromCharCode(cry[i], key[i]);
    }
    return cryptText;
}
function Decrypt(cryptText) {
    clearText = new String;
    cry = new Array();
    key = new Array();
    TextSize = cryptText.length;
    for (i = 0; i < TextSize; i++) {
        cry[i] = cryptText.charCodeAt(i);
        key[i] = cryptText.charCodeAt(i + 1);
    }
    for (i = 0; i < TextSize; i = i+2) {
        clearText += String.fromCharCode(cry[i] - key[i]);
    }
    return clearText;
}

//-------------------
//-- XOR encryption

<!-- Begin
/************************************************************************
* Copyright 2001 by Terry Yuen.
* Email: kaiser40@yahoo.com
* Last update: July 15, 2001.
* To implement this script onto your page, copy and paste the Javascript
* on this page and place it in the page that you want the encryption
* routine available on. Then use the function "encrypt()" to encrypt
* data. This function takes two parameters. The first parameter is the
* plain text string and the second parameter is the key. The returned
* string is the encrypted string. To decrypt the string, use the
* function "decrypt()" with the encrypted string as the first parameter
* and key as the second parameter. It returns the decrypted string.
*
* Examples:
* var secret = encrypt("My surprise will consist of ....", "password");
* document.writeln(secret);
*
* document.form[0].elements[1].value = decrypt(document.form[0].elements[0].value, "password");
*
*************************************************************************/

function encryptX(str, pwd) {
  if(pwd == null || pwd.length <= 0) {
    alert("Please enter a password with which to encrypt the message.");
    return null;
  }
  var prand = "";
  for(var i=0; i<pwd.length; i++) {
    prand += pwd.charCodeAt(i).toString();
  }
  var sPos = Math.floor(prand.length / 5);
  var mult = parseInt(prand.charAt(sPos) + prand.charAt(sPos*2) + prand.charAt(sPos*3) + prand.charAt(sPos*4) + prand.charAt(sPos*5));
  var incr = Math.ceil(pwd.length / 2);
  var modu = Math.pow(2, 31) - 1;
  if(mult < 2) {
//  alert("Algorithm cannot find a suitable hash. Please choose a different password. \nPossible considerations are to choose a more complex or longer password.");
    return null;
  }
  var salt = Math.round(Math.random() * 1000000000) % 100000000;
  prand += salt;
  while(prand.length > 10) {
    prand = (parseInt(prand.substring(0, 10)) + parseInt(prand.substring(10, prand.length))).toString();
  }
  prand = (mult * prand + incr) % modu;
  var enc_chr = "";
  var enc_str = "";
  for(var i=0; i<str.length; i++) {
    enc_chr = parseInt(str.charCodeAt(i) ^ Math.floor((prand / modu) * 255));
    if(enc_chr < 16) {
      enc_str += "0" + enc_chr.toString(16);
    } else enc_str += enc_chr.toString(16);
    prand = (mult * prand + incr) % modu;
  }
  salt = salt.toString(16);
  while(salt.length < 8)salt = "0" + salt;
  enc_str += salt;
  return enc_str;
}

function decryptX(str, pwd) {
  if(str == null || str.length < 8) {
//  alert("A salt value could not be extracted from the encrypted message because its length is too short. The message cannot be decrypted.");
    return;
  }
  if(pwd == null || pwd.length <= 0) {
//  alert("Please enter a password with which to decrypt the message.");
    return;
  }
  var prand = "";
  for(var i=0; i<pwd.length; i++) {
    prand += pwd.charCodeAt(i).toString();
  }
  var sPos = Math.floor(prand.length / 5);
  var mult = parseInt(prand.charAt(sPos) + prand.charAt(sPos*2) + prand.charAt(sPos*3) + prand.charAt(sPos*4) + prand.charAt(sPos*5));
  var incr = Math.round(pwd.length / 2);
  var modu = Math.pow(2, 31) - 1;
  var salt = parseInt(str.substring(str.length - 8, str.length), 16);
  str = str.substring(0, str.length - 8);
  prand += salt;
  while(prand.length > 10) {
    prand = (parseInt(prand.substring(0, 10)) + parseInt(prand.substring(10, prand.length))).toString();
  }
  prand = (mult * prand + incr) % modu;
  var enc_chr = "";
  var enc_str = "";
  for(var i=0; i<str.length; i+=2) {
    enc_chr = parseInt(parseInt(str.substring(i, i+2), 16) ^ Math.floor((prand / modu) * 255));
    enc_str += String.fromCharCode(enc_chr);
    prand = (mult * prand + incr) % modu;
  }
  return enc_str;
}


//-------------------
//-- Cookie Functions
//-- http://www.webreference.com/js/column8/functions.html

/*
   name - name of the cookie
   value - value of the cookie
   [expires] - expiration date of the cookie
     (defaults to end of current session)
   [path] - path for which the cookie is valid
     (defaults to path of calling document)
   [domain] - domain for which the cookie is valid
     (defaults to domain of calling document)
   [secure] - Boolean value indicating if the cookie transmission requires
     a secure transmission
   * an argument defaults when it is assigned null as a placeholder
   * a null placeholder is not required for trailing omitted arguments
*/

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}


/*
  name - name of the desired cookie
  return string containing value of specified cookie or null
  if cookie does not exist
*/

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}


/*
   name - name of the cookie
   [path] - path of the cookie (must be same as path used to create cookie)
   [domain] - domain of the cookie (must be same as domain used to
     create cookie)
   path and domain default if assigned null or omitted if no explicit
     argument proceeds
*/

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// date - any instance of the Date object
// fixes an obscure bug in NS 2.0, Mac
// * hand all instances of the Date object to this function for "repairs"

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

// ---------------------------------


