var currentSite = "moffattfamily";
// Must need change current site as appropriate;
// Do not change the indices of the arrays - links depend upon them!;
// The order does not matter;
var allSites = new Array;
// var extSite = new Array;
// var pc_Site = new Array;
if (typeof alerts == "undefined") alerts = 0;
localroot = "File://C:/j/moffst/d/ibm/HTMLPRojects/Inputs/all_sites/";
localhost = "http://localhost/";
allSites[0] = "http://localhost/";
allSites[1] = "http://www.";
allSites[2] = "moffattfamily.org.uk";
// Not used after this;
allSites[3] = "purechocolate.org.uk";
allSites[4] = "purechocolate";
allSites[5] = "pure.chocolate";
allSites[6] = "moffatt.family";
allSites[7] = "putneyevan.church";
allSites[8] = "cricp";
allSites[9] = "";

// extSite[0] = "moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm";

// pc_Site[1] = "http://cricp.org.uk/index.htm        |../../../cricp.org.uk/index.htm                                                      |";
// pc_Site[1] = "http://www.cricp.org.uk/index.htm    |../../../cricp.org.uk/index.htm                                                      |";
// pc_Site[1] = "http://moffattfamily.org.uk/index.htm|../../../moffattfamily.org.uk/index.htm                                              |";
// pc_Site[1] = "http://www.moffattfamily.org.uk      |../../../moffattfamily.org.uk/chocolate/gmx/blue_pc_new.htm                          |";
// pc_Site[1] = "http://music.moffattfamily.org.uk    |../../../moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm    |";
// pc_Site[1] = "http://purechocolate.org.uk          |../../../pure.chocolate/index.htm                                                    |";
// pc_Site[1] = "http://aa.purechocolate.org.uk       |http://www.arthurandersen.com/                                                       |../../../putneyevan.church/andersen/andersen.htm|";
// pc_Site[1] = "http://aauk.purechocolate.org.uk     |http://www.arthurandersen.co.uk/                                                     |../../../putneyevan.church/andersen/andersen.htm|";
// pc_Site[1] = "http://abacus.purechocolate.org.uk/  |http://thomsonreuters.com/products_services/taxacct/united_kingdom/abacus_enterprise/|../../../moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|";
// pc_Site[1] = "http://abacus.purechocolate.org.uk/  |http://www.abacus.deloitte.co.uk/                                                    |../../../moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|";
// pc_Site[1] = "http://de.purechocolate.org.uk       |http://www.andersen.de/                                                              |http://www.arthurandersen.de/|../../new/index_aa_de.htm|../../../putneyevan.church/andersen/arthurandersen_de_modified.htm|";
// pc_Site[1] = "http://deloitte.purechocolate.org.uk |http://www.deloitte.com/                                                             |../../../moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|";
// pc_Site[1] = "http://deloitte2.purechocolate.org.uk|http://184.24.80.128                                                                 |../../../moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|";
// pc_Site[1] = "http://music.purechocolate.org.uk    |http://72.1.201.156                                                                  |../../../moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|";
// pc_Site[1] = "http://uk.purechocolate.org.uk       |http://www.moffattfamily.org.uk/                                                     |../../../moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|";
// pc_Site[1] = "http://www.purechocolate.org.uk      |http://freespace.virgin.net/pure.chocolate/index_pc.htm                              |../../../pure.chocolate/index.htm|../../../moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|";
// pc_Site[1] = "http://acklamhall.org.uk             |http://freespace.virgin.net/moffatt.family/temp/index.htm                            |../../../moffatt.family/temp/index.htm|";
// pc_Site[1] = "http://www.acklamhall.org.uk         |http://freespace.virgin.net/moffatt.family/temp/index2.htm                           |../../../moffatt.family/temp/index2.htm|";
// pc_Site[1] = "http://free.acklamhall.org.uk        |http://www.freeparking.co.uk                                                         |../../../moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|";
// pc_Site[1] = "http://music.acklamhall.org.uk       |http://www.seftonhall.org.uk                                                         |../../../moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|";
// pc_Site[1] = "http://test.acklamhall.org.uk        |http://www.acklamhall.org.uk                                                         |../../../moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|";
// pc_Site[1] = "http://acklamhall.org                |http://www.moffattfamily.org.uk/theparty/ahgs/ahgs.htm                               |../../../moffatt.family/theparty/ahgs/ahgs.htm|";
// pc_Site[1] = "http://www.acklamhall.org            |http://www.moffattfamily.org.uk/theparty/ahgs/ahgs.htm                               |../../../moffatt.family/theparty/ahgs/ahgs.htm|";
// pc_Site[1] = "http://seftonhall.org.uk             |http://freespace.virgin.net/putneyevan.church/zim/zpt.htm                            |../../../putneyevan.church/zim/zpt.htm|../../../moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|";
// pc_Site[1] = "http://www.seftonhall.org.uk         |http://freespace.virgin.net/putneyevan.church/library/gallery.htm                    |../../../putneyevan.church/library/gallery2.htm|../../../putneyevan.church/library/gallery.htm|";
// pc_Site[1] = "http://zw.seftonhall.org.uk          |http://www.seftonhall.org.uk                                                         |../../../moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|";
// pc_Site[1] = "http://themoffatts.org.uk            |http://freespace.virgin.net/moffatt.family/index.htm                                 |";
// pc_Site[1] = "http://themoffatts.org.uk            |../../../moffatt.family/index.htm                                                    |";
// pc_Site[1] = "http://themoffatts.org.uk            |../../../moffatt.family/stuartmoffatt/index.htm                                      |";
// pc_Site[1] = "http://www.themoffatts.org.uk        |http://freespace.virgin.net/moffatt.family/index.htm                                 |";
// pc_Site[1] = "http://moffattfamily.org.uk/htm/netscape/index.htm                             |../../../moffattfamily.org.uk/htm/netscape/index.htm                  |";
// pc_Site[1] = "http://moffattfamily.org.uk/htm/freeserve/index.htm                            |../../../moffattfamily.org.uk/htm/freeserve/index.htm                 |";
// pc_Site[1] = "http://www.moffattfamily.org.uk/htm/netscape/index2.htm                        |../../../moffattfamily.org.uk/htm/netscape/index2.htm                 |";
// pc_Site[1] = "http://moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|http://homepages.ic4life.net/users/stuart.moffatt/                    |../../../moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|";
// pc_Site[1] = "http://moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|http://moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|../../../moffattfamily.org.uk/htm/freeserve/seftonhall/underconstructionindex.htm|";
// pc_Site[1] = "http://freespace.virgin.net/moffatt.family/stuartmoffatt/fammus.htm            |../../../moffatt.family/stuartmoffatt/fammus.htm                      |";
// pc_Site[1] = "http://freespace.virgin.net/moffatt.family/christinemoffatt/homepage.htm       |http://www.moffattfamily.org.uk/netscape/christinemoffatt/homepage.htm|../../../moffatt.family/christinemoffatt/HomePage.htm|";
// pc_Site[1] = "http://freespace.virgin.net/moffatt.family/johnpmoffatt/homepage.htm           |http://www.moffattfamily.org.uk/netscape/johnpmoffatt/homepage.htm    |../../../moffatt.family/johnpmoffatt/HomePage.htm|";
// pc_Site[1] = "http://freespace.virgin.net/moffatt.family/katiemoffatt/homepage.htm           |http://www.moffattfamily.org.uk/netscape/katiemoffatt/homepage.htm    |../../../moffatt.family/katiemoffatt/HomePage.htm|";
// pc_Site[1] = "http://freespace.virgin.net/moffatt.family/stuartmoffatt/homepage.htm          |http://www.moffattfamily.org.uk/netscape/stuartmoffatt/homepage.htm   |../../../moffatt.family/stuartmoffatt/HomePage.htm|";
// pc_Site[1] = "http://freespace.virgin.net/pure.chocolate/new/index.htm                       |../../../pure.chocolate/new/index.htm                                 |";
// pc_Site[1] = "http://freespace.virgin.net/pure.chocolate/htm/pclmusic.htm                    |../../../pure.chocolate/htm/pclmusic.htm                              |";
// pc_Site[1] = "http://freespace.virgin.net/pure.chocolate/new/index_aa_de.htm                 |../../../pure.chocolate/new/index_aa_de.htm                           |";

// extSite[1]  = "http://www.andersen.com/                                        |../../../putneyevan.church/andersen/andersen.htm     |http://freespace.virgin.net/putneyevan.church/andersen/andersen.htm|http://aa.purechocolate.org.uk|http://www.awo.com/|../../new/index_aa.htm";
// extSite[2]  = "http://www.usdoj.gov/opa/pr/2001/July/345ag.htm                 |../../../putneyevan.church/andersen/DOJ.htm          |http://freespace.virgin.net/putneyevan.church/andersen/DOJ.htm      ";
// extSite[3]  = "http://news.bbc.co.uk/                                          |";
// extSite[4]  = "http://news.bbc.co.uk/1/hi/business/4596949.stm                 |../../../putneyevan.church/bbc/index.htm             |http://freespace.virgin.net/putneyevan.church/bbc/index.htm         ";
// extSite[5]  = "http://news.bbc.co.uk/1/hi/talking_point/3684041.stm            |../../../putneyevan.church/bbc/eurovision.htm        |http://freespace.virgin.net/putneyevan.church/bbc/eurovision.htm    ";
// extSite[6]  = "http://www.alumni.net/                                          |";
// extSite[7]  = "http://www.clsg.demon.co.uk                                     |";
// extSite[8]  = "http://www.deloitte.com/                                        |http://deloitte2.purechocolate.org.uk                |http://deloitte.purechocolate.org.uk";
// extSite[9]  = "http://www.farese.com/rbcd/rbcd.htm                             |";
// extSite[10] = "http://www.geocities.com/miszt009/index.html                    |";
// extSite[11] = "http://www.guysandstthomas.nhs.uk/services/therapies/physio.aspx|";
// extSite[12] = "http://www.hebrondowlais.org.uk/                                |";
// extSite[13] = "http://www.ic.ac.uk/                                            |";
// extSite[14] = "http://www.lympho.org                                           |";
// extSite[15] = "http://www.lymphontario.ca/                                     |";
// extSite[16] = "http://2011-ilf-conference.ettend.com?119                       |";
// extSite[17] = "http://www.ntworthy.com                                         |http://nwc-scriptorium.org/class4.html#Moffatt";
// extSite[18] = "http://www.putneyevangelicalchurch.org.uk                       |";
// extSite[19] = "http://www.tvu.ac.uk/                                           |http://www.Wolfson.tvu.ac.uk/";
// extSite[20] = "http://en.wikipedia.org/wiki/Christine_Moffatt                  |";
// extSite[21] = "http://get.adobe.com/flashplayer/                               |";
// extSite[22] = "http://homepages.wmich.edu/~k0kavana/specialwords.html          |../../putneyevan.church/wmichkkavana/specialwords.htm|http://freespace.virgin.net/putneyevan.church/wmichkkavana/specialwords.html|http://www.stumbleupon.com/url/homepages.wmich.edu/~k0kavana/specialwords.html|http://www.stumbleupon.com/stumbler/johnshaven/review/26874842/|";

local_site = currentSite + ".org.uk";
wan_site = local_site;
altwan_site = wan_site;
isLocal = 0;

var reby = document.referrer;
var opby = "Opener is null or not an object";
if (typeof opener == "object" && opener != null && (typeof document.opener == "object") ) {opby = document.opener.location.href };
temploc = location.toString();
if (temploc.indexOf("file:") > -1  )
{
  htmroot = location;
  nweb = 1;
// Chrome and Firefox gets into here;
}
else
{
  htmroot = top.location;
}
// alert(htmroot.indexOf("/"))

function sethtmroot(localSite,wanSite,altwanSite)
{
  local_site = allSites[localSite];
  wan_site = allSites[wanSite];
  altwan_site = allSites[altwanSite];
  isLocal = 0;

//  if (location.href.indexOf("http:") > -1 && location.href.indexOf("localhost") > -1)
//  {
//    htmroot = "http://localhost/" + local_site + "/";
//    isLocal = 1;
//  }
//  else if (location.href.indexOf("http:") > -1 && location.href.indexOf(currentSite) > -1)
//  {
//    htmroot = "http://www." + wan_site + "/";
//  }
//  else
//  {
//    htmroot = "http://www." + altwan_site + "/";
//  }
// Why does not file work? ;

  if (typeof alerts != "undefined") {if (alerts) alert("3 " + htmroot);}

  if (location.toString().indexOf("localhost")>-1)
  {
    htmroot = "http://localhost/" + local_site + "/";
    isLocal = 1;
  }
  else if (location.toString().indexOf("file:")>-1)
  {
    htmroot = localroot + local_site + "/";
    isLocal = 1;
  }
  else if (location.href.indexOf("http:") > -1 && location.href.indexOf(currentSite) > -1)
  {
    htmroot = "http://www." + wan_site + "/";
  }
  else
  {
    htmroot = "http://www." + altwan_site + "/";
  }
}

function locatetop()
{
 if ( top.location.href.indexOf("file:") > -1 || top.location.href.indexOf("localhost") > -1  )
  {
    null;
  }
  else if ( reby == "http://uk.purechocolate.org.uk/" || top.location.href == "http://www.moffattfamily.org.uk/" )
  {
    top.location.href = "http://moffattfamily.org.uk/chocolate/gmx/blue_pc_new.htm";
  }
  else
  {
    if ( reby == "" )
    {
      top.location.href = "http://purechocolate.org.uk";
    }
    else
    {
      top.location.href = "../events/jaquigraham/gj.htm";
    }
  }
}

// This is a script to allow pclsidebar to work
// if on the internet nweb must equal zero!
var delayme=0.5;
var NavApp = navigator.appName;// IE or Netscape;
// var CodeName = navigator.appCodeName;// IE or Mozilla;
var NavAgent = navigator.userAgent.toLowerCase();
var NavIsIE =  ((NavApp == "Microsoft Internet Explorer")? true : false);
var NavIsFF =  ((NavApp == "Netscape") && (NavAgent.search("firefox") > -1) ? true : false);
var NavIsCM =  ((NavApp == "Netscape") && (NavAgent.search("chrome") > -1)? true : false);
var web;
var nweb = 1;
var nserver = 0;
  if (NavIsIE)
  {
    if (navigator.onLine) nweb = 0;
  }
  else
  {
    nweb = 0;
  }
// This is as close as I can get it so far - but I must remember to have IE off line when developing!
// And this must be pointing correctly for local use! Script will find the absolute address above this level
var htm_location = "Inputs/";
// if ( top.location.href.indexOf("file:") > -1 || top.location.href.indexOf("localhost") > -1  ) nweb = 1;
if ( htmroot.toString().indexOf("file:") > -1 || htmroot.toString().indexOf("localhost") > -1  ) nweb = 1;
if ( htmroot.toString().indexOf("file:") > -1 ) nserver = 1;

function change_page(local,web)
{
  location_href = web;
  if (nweb) local_href(local);
  location.href = location_href;
  defaultStatus = "Pure Chocolate Library";
}

function local_href(local)
{
// Chrome and Firefox fail to access href when using a local file;
  location_href = htm_location + local;
  current_href = location.href;
  if (alerts) alert(current_href);
  i = current_href.indexOf('Inputs');
//  if ( top.location.href.indexOf("file:") > -1 ) i = current_href.lastIndexOf('/') + 1 ;
  if ( htmroot.toString().indexOf("file:") > -1 ) i = current_href.lastIndexOf('/') + 1 ;
  parent_href = current_href.substring(0,i);
  if (alerts) alert(parent_href);
  location_href = parent_href + location_href;
  if (alerts) alert(location_href);
}

function old_extLink(i,j,k)
{
if ( htmroot.toString().indexOf("file:") > -1 || htmroot.toString().indexOf("localhost") > -1  ) nweb = 1;
if ( htmroot.toString().indexOf("file:") > -1 ) nserver = 1;
  // i extSite array item - never zero;
  // j normally zero - the first item in the array;
  // k normally zero but otherwise redirects to a 'local' copy of the external site (usually 1), so that;
  // extLink(i,0,0) is the default position and goes to the external site or to the underconstruction page;
  // extLink(i,0,1) goes to the external site or a local copy of the external site;
  // extLink(i,1||2,1) always goes to a local copy of the external site;
//  extRef = extSite[i].split("|");
//  location.href = (nweb? (( nserver?  localroot: allSites[0] ) + (k? extRef[k]: extSite[0])): extRef[j]);

  // i extSite array item - never zero;
  // j external site;
  // k 'local' copy of the external site or to the underconstruction page;
  // extLink(i,j,0) goes to the j or to the underconstruction page;
  // extLink(i,j,k) goes to the j or to k (a local copy of j);
  // extLink(i,1,0) goes to 1 on the web and underconstruction off;
  // extLink(i,1,2) goes to 1 on the web and 2 off;
  // extLink(i,2,2) always goes to 2;
  extRef = extSite[i].split("|");
  location.href = (nweb? (( nserver?  localroot: localhost ) + (k? extRef[k]: extSite[0])): (j? extRef[j]:extRef[k]) );
}
