/* Query Sting 
To get query string using Javascript:
hu = window.location.search.substring(1);
document.write(hu);

-We create a variable hu
-Built-in Javascript properties: window.location is the entire url. search.substring(1) is the part after the question mark.
-We write the value of hu to the browser.

 var f = querySt("Update");
 f = f.toLocaleLowerCase();

*/
function querySt(toFind) {
   qVar = window.location.search.substring(1);
   qy = qVar.split("&");
        for (i = 0; i < qy.length; i++) {
            ft = qy[i].split("=");
        if (ft[0] == toFind) {
        return ft[1];
        }
    }
}

/* The ones below work better */
function get_cookie(cookie_name) {
    var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');

    if (results)
        return (unescape(results[2]));
    else
        return null;
}

function set_cookie(name, value, exp_y, exp_m, exp_d, path, domain, secure) {
    var cookie_string = name + "=" + escape(value);

    if (exp_y) {
        var expires = new Date(exp_y, exp_m, exp_d);
        cookie_string += "; expires=" + expires.toGMTString();
    }

    if (path)
        cookie_string += "; path=" + escape(path);

    if (domain)
        cookie_string += "; domain=" + escape(domain);

    if (secure)
        cookie_string += "; secure";

    document.cookie = cookie_string;
}

function delete_cookie(cookie_name) {
    var cookie_date = new Date();  // current date & time
    cookie_date.setTime(cookie_date.getTime() - 1);
    document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

/* lastmodified date for page */

//
// format date as mmm-dd-yy
// example: Jan-12-99
//
function date_mmmddyy(date)
{
  var d = date.getDate();
  var m = date.getMonth() + 1;
  var y = date.getYear();

  // handle different year values 
  // returned by IE and NS in 
  // the year 2000.
  if(y >= 2000)
  {
    y -= 2000;
  }
  if(y >= 100)
  {
    y -= 100;
  }

  // could use splitString() here 
  // but the following method is 
  // more compatible
  var mmm = 
    ( 1==m)?'Jan':( 2==m)?'Feb':(3==m)?'Mar':
    ( 4==m)?'Apr':( 5==m)?'May':(6==m)?'Jun':
    ( 7==m)?'Jul':( 8==m)?'Aug':(9==m)?'Sep':
    (10==m)?'Oct':(11==m)?'Nov':'Dec';

  return "" +  mmm + "-" + (d<10?"0"+d:d) + "-" + (y<10?"0"+y:y);
}


//
// get last modified date of the 
// current document.
//
function date_lastmodified()
{
  var lmd = document.lastModified;
  var s   = "Unknown";
  var d1;

  // check if we have a valid date
  // before proceeding
  if(0 != (d1=Date.parse(lmd)))
  {
    s = "" + date_mmmddyy(new Date(d1));
  }

  return s;
}

//
// finally display the last modified date
// as MMM-DD-YY
//
// document.write( 
//  "This page was updated on " + 
//  date_lastmodified() );

