/* Write additional links (local machine) */

//whether this is cd edition (cd1==true) or web edition (cd1==false)
var cd1=false;
document.oncontextmenu= nocontext;

function nocontext() {return false;}

function slink( strSite, strURL, strText, blnNoTag, level) {
  var strSRoot=getPath(strSite);
  strURL=strSRoot+strURL;
  //assemble string (with list and tag)
  if (blnNoTag != true && strSite!= "CM") strText +=" [Space1999.Net]";
  strText='<a hre'+'f="'+ strURL+'">'+strText+'</a> ';
  if (blnNoTag != true) strText ="<li type='circle'>"+strText+ "</li>";
  //write it
  if (strSRoot != "") document.writeln(strText);
}

function alink(strSite, strURL,level) {
  var strSRoot=getPath(strSite);
  strURL=strSRoot+strURL;
   //assemble string (with list and tag)
   strText='<a hre'+'f="'+ strURL+'">';
   //write it
   if (strSRoot != "") document.writeln(strText);
}

function ulink(ulid, strSite, strURL, txt) {
  var IsLocal= true;
  if (strSite != "CM" && strSite != "C") IsLocal= false;
  var strSRoot=getPath(strSite);
  if (strSRoot=="") return; //no action

  if (strSite!="C") strURL= strSRoot+strURL;
  if (strSite=="CYB") {
    strURL+=".htm";
    if (typeof txt != "string") txt="Cybrary episode page";
  } else {
    if (!IsLocal) txt+=" [Space1999.Net]";
  }

if (document.getElementById) { //w3c ie5+ moz1+
 var ul= document.getElementById(ulid);
 //list
 var newli= document.createElement("li");
 if (!IsLocal) newli.setAttribute("type","circle");
 //a
 var a= document.createElement("a");
 a.setAttribute("href", strURL);
 if (!IsLocal) a.setAttribute("title", "external link");
 var txtnode= document.createTextNode(txt);
 //li-a-txt
 a.appendChild(txtnode);
 newli.appendChild(a);
 ul.appendChild(newli);
} else { //nn4
 s= '<li type="circle"><a hre';
 s+= 'f="'+ strURL+ '">'+txt+'</a></li>';
 document.writeln(s);
}
}

function getPath(strSite) {
  if (cd1==false && location.host == "") {
    var i= location.href.indexOf("catacombs",0);
    strSRoot= location.href.substring(0,i);
    if (strSite== "CM") strSRoot= location.href.substring(0,i+10); //cm part of catacombs
    if (strSite== "CYB") strSRoot= "../../../cd/Cybrary/"; //path to cybrary
    } else {
      strSRoot = "http://www.space1999.net/";
     if (strSite== "CM") strSRoot= "http://www.space1999.net/~catacombs/";
    }
  switch (strSite) {
    case "C": 
      if (cd1) strSRoot=""; //cd version- hide extras
      break;
    case "CM": 
      strSRoot+="cybermuseum/";
      break;
    case "CYB": 
      break;
    case "MB": 
      strSRoot+="~moonbase99/";
      break;
    case "MF": 
      strSRoot+="~metaforms/";
      break;
    case "AC": 
      strSRoot+="~chronicle/";
      break;
     case "CS": 
      strSRoot+= "~cosmos1999/";
      if (!cd1) strSRoot=""; //cosmos offline awaiting move
      break;
    default: 
      strSRoot=""; //don't show anything
      break;
  }
  return strSRoot;
}
