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

     common_scripts.js
     
     Collection of JavaScripts that are common to most/all
     pages on westsidegardener.com
     
     If you use any of these scripts, you MUST be sure the code
     on your site lists me as the original author.
     
     All scripts written by Travis Saling  trav_at_westsidegardener_dot_com
     
**********************8******************************************** */

function jsMail(raw_address)
  {
  var this_address = raw_address.split("_at_");
  document.write("<a href=\"mailto:" + this_address[0] + "@" + this_address[1] +
    ".com\">" + this_address[0] + "@" + this_address[1] + ".com</a>");
  return;
  }

function readCookie()
  {
  //
  //  Reads the cookie (if it exists)
  //
  browser_warn = "no";
  //
  if (document.cookie)
    { 
    var cookietext = document.cookie;
    cookietext = unescape(cookietext);
    //
    //  Chop up the cookie, and retrieve the stored information
    //
    var info_array = cookietext.split("%%");
    //
    for (loop = 0; loop < info_array.length; loop ++)
      {
      var valuepair = info_array[loop].split("=");
      if (valuepair[0] == "browser_warn") { browser_warn = valuepair[1]; }
      }
    }
  return;
  }

function writeCookie(option)
  //Writes the cookie, using the parameters stored in the cookie variables. If called
  //with a parameter of -1, this routine deletes the cookie and resets the cookie variables to
  //their default values.
  {
  var cookietext = "%%";
  cookietext += "browser_warn=" + browser_warn + "%%";
  //
  cookietext = escape(cookietext);
  cookietext += ";path=/";
  if (option != -1)
    { var exp_date = new Date("December 31, 2010"); }
  else
    { var exp_date = new Date("December 31, 1990"); }
  cookietext += ";expires=" + exp_date.toGMTString();
  //
  document.cookie = cookietext;
  //
  if (option == -1)
    {
    browser_warn="yes";
    }
  return;
  }

var browser_version = navigator.appVersion.substr(0,1);

readCookie();
if (! document.getElementById) {
  if (browser_warn != "yes") {
    alert ("This site was written to take advantage of modern standards-compliant\n" +
      "browsers. If the site looks weird and/or unreadable to you, consider upgrading\n" +
      "your browser. If you choose not to do that, then turn stylesheet support off\n" +
      "using your browser's preferences settings - that should let you view the site.\n\n" +
      "You should only see this pop-up once, unless you are blocking cookies.");
    browser_warn="yes";
    writeCookie(1);
    }
  }