function showFlash()
{
  var div, divW, divH, divT, divB;
  div = document.getElementById("divFlash");
  var winSize = windowSize();

  if (!div) return;

  div.style.display="block";
  div.style.visibility="visible";
  div.style.position="absolute";

  divW = 437;
  divH = 320;

  var cW = parseFloat(800 - divW) / 2 ;
  var cH = parseFloat(600 - divH) / 2;

  div.style.left = cW + "px";
  div.style.top = cH + "px";

  createFlashObj();
  commandText();
}

function createFlashObj()
{
  var td = document.getElementById("tdFlash");
  td.innerHTML = "<object id=\"introFlash\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" " +
                "codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" " +
                "height=\"281\" width=\"425\"><param name=\"movie\" value=\"Images/Werribee.swf\"> " +
                "<param name=\"quality\" value=\"high\"><param name=\"play\" value=\"true\"> " +
                "<param name=\"allowScriptAccess\" value=\"sameDomain\" /><embed allowscriptaccess=\"sameDomain\" height=\"281\" width=\"425\" " +
                "swliveconnect=\"true\" name=\"introFlash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" " +
                "quality=\"high\" src=\"Images/Werribee.swf\" type=\"application/x-shockwave-flash\"></embed></object>";
}

function loadFlash()
{
  var vv = getCookie("flashPopup");
  if (vv=="1")
  {
    return false;
  }
  window.setTimeout("showFlash()",2000);
  return false;
}

function showHide()
{
  var div, aCommand;
  div = document.getElementById("divFlash");
  if (!div) return;

  aCommand = document.getElementById("aCommand");

  if (div.style.visibility=="hidden")
  {
    showFlash();
    aCommand.innerHTML="Hide Intro";
  }
  else
  {
    div.style.display="none";
    div.style.visibility="hidden";
    aCommand.innerHTML="Show Intro";
    document.getElementById("tdFlash").innerHTML = "";
    setCookie("flashPopup","1",0,12);
  }
  return false;
}

function controlFlash(command)
{
  var flash;
  flash = getFlashMovieObject("introFlash");
  if (command)
  {
    if (command == "play")
    {
      flash.Play();
    }
    else if (command == "stop")
    {
      flash.StopPlay();
    }
  }
  return false;
}

function commandText()
{
  var div, aCommand;
  div = document.getElementById("divFlash");
  aCommand = document.getElementById("aCommand");

  if (div.style.visibility=="hidden")
  {
    aCommand.innerHTML="Show Intro";
  }
  else
  {
    aCommand.innerHTML="Hide Intro";
  }
  return false;
}

function windowSize()
{
  var winW, winH;

  if (parseInt(navigator.appVersion)>3)
  {
    if (navigator.appName=="Netscape")
    {
     winW = window.innerWidth;
      winH = window.innerHeight;
    }
    if (navigator.appName.indexOf("Microsoft")!=-1)
    {
      winW = document.body.offsetWidth;
      winH = document.body.offsetHeight;
    }
  }
  var winSize = new Array();
  winSize[0] = winW;
  winSize[1] = winH;
  return winSize;
}

function getFlashMovieObject(movieName)
{
  if (window.document[movieName])
  {
    return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName];
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

// Cookie Management

/* File Functions:
   1. setCookie - writes cookie
   2. getCookie - gets value of cookie
   3. removeCookie - deletes a cookie
   4. detectCookies - checks if cookies are enabled
*/

function setCookie(cookieName, cookieValue, expireDays, expireHours)
{
  /* Pass in three strings - the name of the cookie, the value, and the
  number of days until expiration.
  Pass in a "" empty string for expireDays to set a session cookie (no
  expires date).
  Pass in any other date for expire as a number of days to be added to
  today's date. */

  var expires = "";
  var re = /^\d+$/;
  
  /* make sure expireDays is a number */
  if (expireDays && re.test(expireDays))
  {
    expires = new Date();
    expires.setDate(expires.getDate() + expireDays);
  }
  if (expireHours && re.test(expireHours))
  {
    expires = new Date();
    expires.setHours(expires.getHours() + expireHours);
    if (expireDays && re.test(expireDays))
    {
      expires.setDate(expires.getDate() + expireDays);
    }
  }

  document.cookie = cookieName+"="+cookieValue+";expires="+expires;
}

function removeCookie(cookieName)
{
  /* Pass in the name of the cookie as a string and it will be removed. */
  var expires = new Date();
  document.cookie = cookieName+"= ;expires="+expires.toGMTString();
}

function getCookie (cookieName)
{
  cookieValue = ""
  if (document.cookie.indexOf(cookieName) == -1)
  {
    /* there is no cookie by this name for this user */
    return cookieValue;
  }
  else
  {
    /* get the beginning index of the cookie by looking for the cookie name */
    cookieStart = document.cookie.indexOf(cookieName);
    /* get the beginning index of the cookie value by looking for the equal sign after the name */
    cookieValStart = (document.cookie.indexOf("=", cookieStart) + 1);
    /* get the end index of the cookie value by looking for the semi-colon after the value */
    cookieValEnd = document.cookie.indexOf(";", cookieStart);
    /* if no semi-colon, then use the whole length */
    if (cookieValEnd == -1)
    {
      cookieValEnd = document.cookie.length
    }
    /* use substring to get the text between the two indices and that is
    the value of the cookie */
    cookieValue = document.cookie.substring(cookieValStart, cookieValEnd);
    return cookieValue;
  }
}

function detectCookies()
{
  /* function returns true if cookies are enables, false if not */
  setCookie("test", "test", "");
  tmp = getCookie("test")
  if (tmp != "test")
  {
    return false;
  }
  else
  {
		return true;
  }
}