/* author: Chris Stephen */
/* Generated by AceHTML Freeware http://freeware.acehtml.com */
/* Creation date: 21/11/2003 */

/* The replace function was introduced in JavaScript 1.1           */ 
/* define it for browsers only supporting 1.0                      */
/* This will remove the 'Back button protection' for such browsers */ 
if (location.replace == null) location.replace = location.assign;

function bemail(user, domain, suffix)
{ return 'mailto:' + user + '@' + domain + '.' + suffix;
};

function jemail(user, domain, suffix)
{ var argv = jemail.arguments;
  var argc = jemail.arguments.length;
  if (argc > 3)
  { document.write('<a href="' + bemail(user, domain, suffix) + '" class="email">' + argv[3] + '</a>');
  }
  else
  { document.write('<a href="' + bemail(user, domain, suffix) + '" class="email">' + user + '@' + domain + '.' + suffix + '</a>');
  }
  return null;
};

function sendmail(user, domain, suffix)
{ var argv = sendmail.arguments;
  var argc = sendmail.arguments.length;
  if (argc > 3)
  { window.location=bemail(user, domain, suffix) + '?subject=' + argv[3];
  }
  else
  { window.location=bemail(user, domain, suffix);
  }
  return undefined;
};

function lastupdated()
{ var mydate=new Date(document.lastModified)
  var year=mydate.getYear()
  var day=mydate.getDay()
  var month=mydate.getMonth()
  var daym=mydate.getDate()
  var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
  var daytharray=new Array("","st","nd","rd","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","st","nd","rd","th","th","th","th","th","th","th","st")
  var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
  var hours = mydate.getHours();
  var mins = mydate.getMinutes();
  var time;
  if (year < 1000) year+=1900;
  if (hours >= 12) 
  { time = " p.m.";
    if (hours > 12) hours -= 12; 
  } 
  else 
  { time = " a.m."; 
    if (hours == 0) hours = 12; 
	}; 
  if (mins < 10) mins = "0" + mins; 
  document.writeln("<FONT size=1><I>Last Updated: " + hours + ":" + mins + time + " " + dayarray[day] + "&nbsp;" + daym + "<SUP>" + daytharray[daym] + "</SUP>&nbsp;" + montharray[month] + "&nbsp;" + year + "</I></FONT>");
  return null;
};

function popup(page)
{ var width=(screen.width * 7) / 8;
  var height=(screen.height * 7) / 8;
  var windowprops = "height=" + height + ",width=" + width + ",location=no," + "scrollbars=yes,menubars=no,toolbars=no,resizable=yes";
  window.open(page, "Gallery", windowprops);
  return null;
}

function GetSearchValue (name)
{ 
	var slen = top.location.search.length;
	if (slen > 1)
	{ 
		/* search parameters exist, replace the leading '?' with the separator character '&'   */
		/* and suffix with it too to ease location and extraction of the first and last params */
		var searchstring = "&" + top.location.search.substring(1,slen) + "&";
		var i = searchstring.indexOf("&" + name + "=");
		if (i >= 0)
		{
			i += name.length + 2;
			var j = searchstring.indexOf("&",i);
			return searchstring.substring(i,j);
		}
	}
  return null;
}

function GetCookieValue (name)
{ 
	if (document.cookie.length > 0)
	{ 
		/* cookies exist, prefix and suffix  entire string with the separator character (space) */
		/* to ease location and extraction of the first and last value                          */
		var cookiestring = " " + document.cookie + " ";
		var i = cookiestring.indexOf(" " + name + "=");
		if (i >= 0)
		{
			i += name.length + 2;
			var j = cookiestring.indexOf(" ",i);
			return cookiestring.substring(i,j);
		}
	}
  return null;
}

function SetCookie (name, value)
{ var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null; 
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) +
                    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
                    ((path == null) ? "" : ("; path=" + path)) +
                    ((domain == null) ? "" : ("; domain=" + domain)) +
                    ((secure == true) ? "; secure" : "");
  return null;
}

function DeleteCookie (name)
{ if (GetCookieValue(name) != null)
  { var exp = new Date();
    exp.setTime (exp.getTime() - 1);
    document.cookie = name + "=; expires=" + exp.toGMTString();
	}
  return null;
}

function setwindowtitle ()
{ top.document.title = document.title;
  return null;
}

function forceintoframe (framepage, framename)
{ 
	var dir = location.pathname;
  var dirlvl = -1;
	/* Break out of the redirection for local development */
  if (location.host == "") return null;
  /* calculate directory for cookie (dir where the frameset page is) */
  for (;
       dir = dir.substring(0, dir.lastIndexOf('/')),
	     dirlvl = framepage.indexOf('/', dirlvl + 1),
	     dirlvl >= 0;)
  {};
  dir += '/';
  /* Now we can determine the ralative path to this page */ 
  var needurl = location.pathname.substring(dir.length, location.pathname.length + 1);
  SetCookie(framename, needurl + location.hash, null, dir);
	if (GetCookieValue(framename) != null)
	{
	  /* now redirect to the frameset */
  	top.location.replace(framepage);
	}
	else
	{
		/* redirect to the frameset using search strings */
		var hashval = location.hash;
		if (hashval != "") needurl += "%23" + hashval.substring(1,hashval.length);
		top.location.replace(framepage + "?usecookies=N&" + framename + "=" + needurl);
	}
  return null;
}

function checkchildframe(framepage, framename)
{	/* Break out of the redirection for local development */
  var topdir = top.location.href
  var dir = location.href
	var len
  if (location.host == "") return null;
	len = topdir.indexOf('?');
	if (len >= 0) topdir = topdir.substring(0,len);
	len = dir.indexOf('?');
	if (len >= 0) dir = dir.substring(0,len);
	if (topdir == dir) 
  { /* page is not displayed in a frame */
    forceintoframe(framepage, framename);
  }
  else
  { /* check that top frame is in the same or a parent directory */
    topdir = topdir.substring(0, topdir.lastIndexOf('/') +1 );
    dir = dir.substring(0, dir.lastIndexOf('/') + 1);
    if (topdir.length > dir.length) 
	  { forceintoframe(framepage, framename);
	  }
    else 
	  { if (dir.substring(0, topdir.length) != topdir) 
	    { forceintoframe(framepage, framename);
  } } }
  return null;
}

function populateframes()
{ if (top.location != location)
  { /* break out of frame */
    top.location.replace(location.href);
  }
  else
  { /* check if we've been referred from checkchildframe */
    var framename;
	  var page;
	  var i;
		var usecookies = (GetSearchValue("usecookies") != "N")
	  for (i = 0; i < top.frames.length; i +=  1)
	  { framename = top.frames[i].name;
	    if (framename && (framename != ""))
	    { 
				page=(usecookies? GetCookieValue(framename) : GetSearchValue(framename));
        if (page && (page != ""))
        {
					var hashind = page.indexOf("%23");
					if (hashind >= 0) page = page.substring(0,hashind) + "#" + page.substring(hashind + 3,page.length);
          top.frames[i].location.replace(page);
					if (usecookies)	DeleteCookie(framename);
				}
				else
				{
					if (top.frames[i].location.href == "about:blank")
					{
	          top.frames[i].location.replace(framename + ".html");
  } } } } }
  return null;
}

function framebreakout()
{ if (top.location != location) top.location.replace(document.location.href) ;
  return null;
};
