
// Created by Tom Salmon, TSI Incorporated 8/10/00
// Updated 11/17/00 by Tom Salmon
/* This script does the following:
*  1. reloads document in Netscape 4.x
*  2. checks browser/version/platform
*  3. sets the swap/preload image behaviors
*  4. sets the spacers for Netscape browsers
*  5. sets a cookie
*/


function MM_reloadPage(init2) {  //reloads the window if Nav4 resized
  if (init2==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);



var plat;
var brow;
var brow_version;
var brow_v = (parseInt(navigator.appVersion));

//obsolete browser variable
var sb=((navigator.appVersion.charAt(0)<4)||((navigator.appName.indexOf('Netscape')<0)&&(navigator.appName.indexOf('Microsoft Internet Explorer')<0)));

// Sets variables win, mac, ie, ns. //

if (sb) {
  plat = null;
  brow = null;
}
else {
  plat = (navigator.platform.indexOf('Mac') > -1) ? 'mac' : 'win';
  if (navigator.platform.indexOf('Linux') > -1) {
    plat = "linux";
  }
  brow = (navigator.appName.indexOf('Microsoft') > -1) ? 'ie' : 'ns';
  iebrow_version = 4;
//  if (navigator.appVersion.indexOf('MSIE 4')) {
//   iebrow_version = 4;
//  }
//  else if (navigator.appVersion.indexOf('MSIE 5.0')) {
//   iebrow_version = 4;
//  }
//  else if (navigator.appVersion.indexOf('MSIE 5.5')) {
//   iebrow_version = 5;
//  }
//  else {
//   if (navigator.appVersion.indexOf('MSIE')) {
//     iebrow_version = 5;
//   }
//  }
// alert(navigator.appVersion);
}



// checks Netscape browser version (i.e. 4.5)
   brow_version = parseFloat(navigator.appVersion);




// Swap and preload images

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



// In Netscape, sets the space at the very top between the top of the browser window and the TSI menubar
function ns_top_space() { 
  if (brow == "ns") document.write("<img src=\"/corp/images/shim.gif\" width=\"50\" height=\"8\"><br>");
}


// In Netscape, sets the space near the bottom between the bottom menu bar and the hypertext links
function ns_bottom_space() { 
  if (brow == "ns") document.write("<img src=\"/corp/images/shim.gif\" width=\"50\" height=\"14\"><br>");
}



// Set Cookie

function getCookie() { 
  if(document.cookie) return true;
  else return false;
}


function getCookieValue(name) {
    name += "="; // append '=' to name string
    var i = 0; // index of first name=value pair
    while (i < document.cookie.length) {
      var offset = i + name.length; // end of section to compare with name string
      if (document.cookie.substring(i, offset) == name) { // if string matches
        var endstr = document.cookie.indexOf(";", offset); // locate end of name=value pair
        if (endstr == -1) endstr = document.cookie.length;
        return unescape(document.cookie.substring(offset, endstr)); // return cookie value section
      }
      i = document.cookie.indexOf(" ", i) + 1; // move i to next name=value pair
      if (i == 0) break; // no more values in cookie string
    }
    return null; // cookie not found
  }



  var today = new Date();
  var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000); // plus 1 year

function setCookie(name, value) { // use: setCookie("name", value);
  document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString() + "; path=/; domain=.tsi.com"
}

var cookie_true = getCookie();
if(cookie_true == false) {
    var random = Math.random() * 100000000000000000;
  setCookie("id", random);
}
getid = getCookieValue("id");

// for testing only
// alert(getid);

