//
//  Cookie Functions -- "Night of the Living Cookie" Version (25-Jul-96)
//
//  Written by:  Bill Dortch, hIdaho Design <bdortch@hidaho.com>
//
//      http://www.netscape.com/newsref/std/cookie_spec.html    
//
//******************************************************************
//
// "Internal" function to return the decoded value of a cookie
//
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
//
//  Function to correct for 2.x Mac date bug.  document.
//
function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);
}
//
//  Function to return the value of the cookie specified by "name".
//
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}
//
//  Function to create or update a cookie.
//
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

//  Function to delete a cookie. (Sets expiration date to start of epoch)
//
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}


//
//-------------------------
// PPP - SAGE II javascript

browser = (((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4 )) || ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 3 )))
internetV2 = (((navigator.appName == "Microsoft Internet Explorer") || (navigator.appName == "Netscape")) && (parseInt(navigator.appVersion) >= 3 ))
window.top.name="feedback";

var lastidx=0;
var numImages=8;

function copyrightyr() {
     brsrType=navigator.appName;
     brsrMSIE=(navigator.appName == "Microsoft Internet Explorer");
     brsrNS=(navigator.appName == "Netscape");
     var timestamp=document.lastModified;
     var timesecs=Date.parse(timestamp)
     var datetime=new Date();
     datetime.setTime(timesecs);
     if (brsrMSIE) {
        document.write(datetime.getYear());     
     } else {
        document.write(datetime.getYear()+1900);
     }
}  // end of copyrightyr()


function reDisplay() {
   var launchCode=GetCookie("launch");   
   var e_Mail=GetCookie("email");

   if (e_Mail!=null) {
   } else {
      e_Mail=" ";
   }
   document.feedback.email.value=e_Mail;

}  // end of reDisplay()


//--- set the image (called from getDisplay()-see below)
function picDisplay(Mimage) {
   var MVimage=Mimage;
   document.nobot.src=MVimage;
}


//---select the indexed image to display 
function getDisplay(Mrnd) {
      var getRnd=Mrnd;
      switch (getRnd) {
        case 0 : 
          picDisplay('images/nobot1.jpg');
          break;
        case 1 : 
          picDisplay('images/nobot4.jpg');
          break;
        case 2 : 
          picDisplay('images/nobot6.jpg');
          break;
        case 3 : 
          picDisplay('images/nobot2.jpg');
          break;
        case 4 : 
          picDisplay('images/nobot8.jpg');
          break;
        case 5 : 
          picDisplay('images/nobot7.jpg');
          break;
        case 6 : 
          picDisplay('images/nobot3.jpg');
          break;
        case 7 : 
          picDisplay('images/nobot5.jpg');
          break;

        default :
          picDisplay('images/nobot1.jpg');
          break;
     }  //--- end of switch
}


//---randomly select an image
function reDisplay() {
      var MVrnd=Math.round(Math.random()*numImages);
      if (MVrnd==lastidx) { 
         if (MVrnd>0)
            MVrnd=MVrnd-1;
         else
            MVrnd=MVrnd+1;
      }
      lastidx=MVrnd;
      getDisplay(MVrnd);

      var launchCode=GetCookie("launch");   
      var e_Mail=GetCookie("email");

      if (e_Mail!=null) {
      } else {
         e_Mail=" ";
      }
      document.feedback.email.value=e_Mail;
}


//--------------------------------------
function checkFields(formChk) { 
   if (formChk.biofilter.value.length<2) {
      alert("BioFilter is a required field...");
      return false;
   }

   if (formChk.email.value.length<2) {
      alert("'email address' is a required field...");
      return false;
   }
   return true;
}
