function isBrowser () {
  // BROWSER CHECK
  // Note: On IE5, these return 4, so use is.ie5up to detect IE5.
  
	// convert all characters to lowercase to simplify testing 
	var agt=navigator.userAgent.toLowerCase(); 
  
  this.major = parseInt(navigator.appVersion); 
  this.minor = parseFloat(navigator.appVersion); 
  
  this.nav     = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1)); 
  this.nav2    = (this.nav && (this.major == 2)); 
  this.nav3    = (this.nav && (this.major == 3)); 
  this.nav4    = (this.nav && (this.major == 4)); 
  this.nav4up  = (this.nav && (this.major >= 4)); 
  this.navonly = (this.nav && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)) ); 
  this.nav5    = (this.nav && (this.major == 5)); 
  this.nav5up  = (this.nav && (this.major >= 5)); 
  this.nav6    = (this.nav && (this.major == 6)); 
  
  this.ie      = (agt.indexOf("msie") != -1); 
  this.ie3     = (this.ie && (this.major < 4)); 
  this.ie4     = (this.ie && (this.major == 4) && (agt.indexOf("msie 5")==-1) && (agt.indexOf("msie 6")==-1) ); 
  this.ie45    = (this.ie && (this.major == 4) && (agt.indexOf("msie 4.5")==-1) ); 
  this.ie4up   = (this.ie && (this.major >= 4)); 
  this.ie5     = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
  this.ie55    = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5")!=-1) );  
  this.ie6     = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.0")!=-1) ); 
  this.ie5up   = (this.ie && !this.ie3 && !this.ie4 && !this.ie5); 
}

function displayBody() {
  if (isBrowser.nav4up) {
    document.loading.visibility  = "hidden";
    document.mainBody.visibility = "show";
  } else if (isBrowser.nav6 || isBrowser.ie5up) {
    document.getElementById('loading').style.visibility  = 'hidden';
    document.getElementById('mainBody').style.visibility = 'visible';
  } else if (isBrowser.ie4up) {
    document.all['loading'].style.visibility  = 'hidden';
    document.all['mainBody'].style.visibility = 'visible';
  }
}

var isBrowser = new isBrowser();

// cookie functions
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 setCookie(name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

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";
  }
}

// open window functions
function openBorderless (url) {
  window.open(url, 'win', 'toolbar=no,location=no,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=400');
}

// popup functions
function openPopup (ref, url, width, height, menu, scroll) {
  window.open(url,
              ref,
              "toolbar=no, location=no, menubar=" + ((menu) ? 'yes' : 'no')  + ", " +
              "scrollbars=" + ((scroll) ? 'yes' : 'no')  + ", " +
              "resizable=no, width=" + width + ", height=" + height
             );
}