/* JavaScript for Glasgow - City of Sculpture */
/* Copyright 2001 scot-it.com */

  window.onError = null;
  var stat = 'Glasgow - City of Sculpture';
  window.defaultStatus = stat;

/**************************************/

/* Preloads all images on page */

      var len = document.images.length;
      var pix = new Array(len);

      for (i = 0; i < len; i++)
      {
        pix[i] = new Image();
        pix[i] = document.images[i];
        pix[i].src = document.images[i].src;
      }

/**********************************************/

function sendmail1()
{
  var address = document.letter.address.value;
  if (address == "gary" || address == "tim") {
    location.href = "pg_notes.php";}
  else {
    window.open("f_subscribe.php?address=" + address, "", "width=300,height=100"); }
}


function sendmail2()
{
  var url = document.linking.url.value;
  window.open("f_linking.php?url=" + url, "", "width=300,height=100");
}

function sendmail2a()
{
  var url = document.linking2.url.value;
  window.open("f_linking.php?url=" + url, "", "width=300,height=100");
}

function showStat()
{
  status = stat;
}

/******************************************************/

/* Gives Random Thumbnails */

var rtna = new Array(); // Portrait size

rtna[0] = "a1066";
rtna[1] = "a1020";
rtna[2] = "a2065";
rtna[3] = "a1678";
rtna[4] = "a1989";
rtna[5] = "a2283";
rtna[6] = "a2285";
rtna[7] = "a1942";
rtna[8] = "a1051";
rtna[9] = "a0921";

var maxa = rtna.length;
var rtnasrc = new Array();

for ( i=0; i<maxa; i++ )
{
  rtnasrc[i] = "thumbs/" + rtna[i] + "_t.jpg";
}

function getRtna()
{
  var rana = Math.round(Math.random()*maxa);
  var imga = rtnasrc[rana];
  document.write("<img src='" + imga + "' alt='Glasgow - City of Sculpture - " + rtna[rana] + "' width=90 height=120>");
}

/******************************************************/

/* Opens a pop-up window displaying an image */

function openpop(ref,h,w,x,z,alt,ttl)
{
  var imgref = wpath + ref;
  var source = imgref + "_w.jpg";
  var imgsize = "height:" + h +"; width:" + w +";";
  var y = 0;
  if (x == 0) y = 300;

  var txt = "";
  txt += "<html><head><title>" + alt + "</title></head>\n";
  txt += "<body bgcolor=#000066 text=#FFFF00><font face=\"Verdana, Arial, sans-serif\">\n";
  txt += "<div style='position:absolute; top=10; left=10; align=\"center\"'>\n";
  txt += "<table width=100%><tr><td>\n";
  txt += "<a href='javascript:window.close()'><img src='" + source + "' ";
  txt += "style='" + imgsize + "border-color:#00BFFF; border-style:double; border-width:3;'></a>\n";
  if (x == 0) {
    txt += "</td><td width=" + y + "><center>" + ttl + "<br><img src='gifs/clear.gif' width=1 height=" + z + "><br>\n";
    txt += "<a href='javascript:window.close()'><img src='gifs/close.gif' alt='close'></a></center></td></tr></table>\n"; }
  else {
    txt += "</td></tr></table><table align=\"center\" height=" + x + "><tr><td align=\"center\">" + ttl + "</td></tr><tr>\n";
    txt += "<td align=\"center\"><a href='javascript:window.close()'><img src='gifs/close.gif' alt='close'></a></td></tr></table>\n"; }
  txt += "</div></font></body></html>\n";

  var wh = h + 40 + x;
  var ww = w + 40 + y;
  var ws = "height=" + wh + ",width=" + ww;
  var newin = window.open("",null,ws);

  newin.document.write(txt);
  newin.focus();
}

function openwin(ref,h,w,x,alt,ttl)
{
  var imgref = wpath + ref;
  var source = imgref + "_w.jpg";
  var imgsize = "height:" + h +"; width:" + w +";";
  var y = 0;
  if (x == 0) y = 300;

  var txt = "";
  txt += "<html><head><title>" + alt + "</title></head>\n";
  txt += "<body bgcolor=#000066 text=#FFFF00><font face=\"Verdana, Arial, sans-serif\">\n";
  txt += "<div style='position:absolute; top=10; left=10; align=center'>\n";
  txt += "<table width=100%><tr><td>\n";
  txt += "<a href='javascript:window.close()'><img src='" + source + "' ";
  txt += "style='" + imgsize + "border-color:#00BFFF; border-style:double; border-width:3;'></a>\n";
  if (x == 0) {
    txt += "</td><td width=" + y + "><center>" + ttl + "<br><img src='gifs/clear.gif' height=50><br>\n";
    txt += "<a href='javascript:window.close()'><img src='gifs/close.gif' alt='close'></a></center></td></tr></table>\n"; }
  else {
    txt += "</td></tr><tr><td align=center>" + ttl + "</td></tr><tr>\n";
    txt += "<td align=center><a href='javascript:window.close()'><img src='gifs/close.gif' alt='close'></a></td></tr></table>\n"; }
  txt += "</div></font></body></html>\n";

  var wh = h + 40 + x;
  var ww = w + 40 + y;
  var ws = "height=" + wh + ",width=" + ww;
  var newin = window.open("",null,ws);

  newin.document.write(txt);
  newin.focus();
}

/******************************************************/

/* Opens a new page displaying an image */

function openwin2(sub,ref,h,w,x,alt,ttl)
{
  var imgref = wpath + ref;
  var source = imgref + "_w.jpg";
  var imgsize = "height:" + h +"; width:" + w +";";
  var y = 0;
  if (x == 0) y = 300;

  var txt = "";
  txt += "<html><head><title>" + alt + "</title></head>\n";
  txt += "<body bgcolor=#000066 text=#FFFF00><font face=\"Verdana, Arial, sans-serif\">\n";
  txt += "<div style='position:absolute; top=10; left=10; align=center'>\n";
  txt += "<table width=100%><tr><td>\n";
  txt += "<a href='javascript:window.close()'><img src='" + source + "' ";
  txt += "style='" + imgsize + "border-color:#00BFFF; border-style:double; border-width:3;'></a>\n";
  if (x == 0) {
    txt += "</td><td width=" + y + "><center>" + ttl + "<p><img src='gifs/clear.gif' height=50><p><a href='javascript:window.close()'>\n";
    txt += "<img src='gifs/close.gif' alt='close'></a></center></td></tr></table>\n"; }
  else {
    txt += "</td></tr><tr><td align=center>" + ttl + "</td></tr><tr>\n";
    txt += "<td align=center><a href='javascript:window.close()'><img src='gifs/close.gif' alt='close'></a></td></tr></table>\n"; }
  txt += "</div></font></body></html>\n";

  var wh = h + 40 + x;
  var ww = w + 40 + y;
  var ws = "height=" + wh + ",width=" + ww;

  window.location = "pg_display_php?sub=sub";

}

/******************************************************/

/* Toggles between Show and Hide */

function toggleLinks()
{
  var sub = links.style;
  if (sub.display == 'none') { sub.display = 'block' }
  else { sub.display = 'none' };
}

function toggleInfo(link)
{
  var sub = document.all[(link + "Info")].style;
  if (sub.display == 'none') { sub.display = 'block'; }
  else { sub.display = 'none'; };
}


/* Use for not-yet-connected links */
function sorry()
{
  alert("Sorry, but we are still working on that part of the site. Hopefully we shall have something to show you on your next visit.")
}

/****************************************************/

/* Cookie Exchange */

function preCookie(cookieName, val, durMs)
{
  var exp = new Date();
  exp.setTime(exp.getTime() + durMs);
  setCookie(cookieName, val, exp);
}

function setCookie(name, value, expires)
{
  document.cookie = name + "=" + escape(value) + "; path=/" + ((expires == null)? "":"; expires=" + expires.toGMTString());
}

function getCookie(name)
{
  var cname = name + "=";
  var dc = document.cookie;
  if (dc.length >0)
  {
    begin = dc.indexOf(cname);
    if (begin != -1)
    {
      begin += cname.length;
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;

      return unescape(dc.substring(begin, end));
    }
  }
}

/***************************************************/

function notri(obj)
{
  if (ns6)
  {
  var objImg = eval("document." + obj + "Img.style");
  objImg.visibility = "hidden";
  }
  else
  {
  var objImg = eval("document.all." + obj + "Img.style");
  objImg.visibility = "hidden";
  }
}
function redtri(obj)
{
  if (ns6)
  {
  var objImg = eval("document." + obj + "Img.style");
  objImg.visibility = "visible";
  }
  else
  {
  var objImg = eval("document.all." + obj + "Img.style");
  objImg.visibility = "visible";
  }
}
function noinfo(obj)
{
  if (ns6)
  {
  document.menuInfo.innerHTML = document.homeInfo.innerHTML;
  }
  else
  {
  menuInfo.innerHTML = homeInfo.innerHTML;
  }
  notri(obj);
}
function menuinfo(obj)
{
  if (ns6)
  {
  document.menuInfo.innerHTML = eval("document." + obj + "Info").innerHTML;
  }
  else
  {
  menuInfo.innerHTML = eval(obj + "Info").innerHTML;
  }
  redtri(obj);
}