function setCookie(NameOfCookie, value, expiredays){
  var ExpireDate = new Date ();
  ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

  document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function hide_message(){
  var aDiv = document.getElementById("message_window");

  aDiv.onCloseMessage();

  aDiv.style.visibility = "hidden";
}

function hide_message_no_event(){
  var aDiv = document.getElementById("message_window");
  aDiv.style.visibility = "hidden";
}

function show_message(aMessage, aMessageID, aOnCloseMessage){
  var aDiv = document.getElementById("message_window");
  aDiv.message_id = aMessageID;
  aDiv.onCloseMessage = aOnCloseMessage;

  if(navigator.appName=="Microsoft Internet Explorer"){
    aDiv.style.left = "25%";
  }

  aDiv.innerHTML = "<table class='message_main'><tr><th>Click this message to close</th></tr><tr><td>" + aMessage + "</td></tr></table>";
  aDiv.onclick = hide_message;
  aDiv.style.visibility = "visible";
}

function close_art(){
  // stop showing art message
  setCookie("artwork_message_done", "yes", 1);
}

function close_tut(){
  // stop showing tut message
  setCookie("tutorials_message_done", "yes", 1);
}

function close_pro(){
  // stop showing tut message
  setCookie("products_message_done", "yes", 1);
}

function this_year(){
  var aTime = new Date();
  return(aTime.getFullYear());
}

function show_artwork_message(){
  hide_message_no_event();
  if(cookie_value("artwork_message_done")!="yes"){
    show_message("The following images are &copy; "+this_year()+" Ian Crane. They are intended as a sample of current and previous work from 2003 until today. "+
      "Some are incomplete and others have been extracted as examples of work completed for various game modifications or t-shirt designs. "+
      "Please respect the intellectual property of the owner and enjoy!", "art", close_art);
  }
}

function show_tutorial_message(){
  hide_message_no_event();
  if(cookie_value("tutorials_message_done")!="yes"){
    show_message("A number of useful resources have been uploaded, including; trainer notes and articles relevant to the areas of my expertise. "+
      "In particular, the trainer notes are designed for use in the Vocational Education System with an emphasis on International students with basic/poor English. "+
      "Any affiliation with companies and courses these documents may have been created for has been removed. "+
      "Please adapt these notes to suit your learning environment - and enjoy!", "tut", close_tut);
  }
}

function show_products_message(){
  hide_message_no_event();
  if(cookie_value("products_message_done")!="yes"){
    show_message(
      "Product and product designs are not for commercial sale but can be reproduced upon request by the artist and owner. " +
      "They represent the owner\'s original ideas and are subject to copyright.", "pro", close_pro);
  }
}

