//******************************
//
// CLASS: Browser
//
function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer; backcompat
  this.name    = null;
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.name = "opera";
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.name = "netscape";
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.
  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.name = "gecko";
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.name = "ie";
    this.version = parseFloat(ua.substr(i + s.length));
    this.isIE = true;    // backcompat
    return;
  }
}
var sBrowser = new Browser();


/******************************
 * Get elements by class.
 * If your elements are unchanging, you may wish to cache results for speed.
 *
 * pClass is the class name.
 * pNode is the top node to search: if null, search document.
 * pTag is the tag: default is "*" (all tags)
 *
 * Original provided by: Dustin Diaz.
 */
function getElementsByClass(pClass, pNode, pTag) {
  var vClassElems = new Array();
  if ( pNode == null ) {
      pNode = document;
    }
  if ( pTag == null ) {
    pTag = '*';
  }
  var vElems = pNode.getElementsByTagName(pTag);
  var vElemsLen = vElems.length;
  var vPattern = new RegExp("(^|\s)"+pClass+"(\s|$)");
  for (i = 0, j = 0; i < vElemsLen; i++) {
    if ( vPattern.test(vElems[i].className) ) {
      vClassElems[j] = vElems[i];
      j++;
    }
  }
  return vClassElems;
}


/******************************
 * Get a cookie.
 *
 * Original provided by: Dustin Diaz.
 */
function getCookie( name ) {
  var start = document.cookie.indexOf( name + "=" );
  var len = start + name.length + 1;
  if ((!start) && (name != document.cookie.substring(0, name.length))) {
    return null;
  }
  if (start == -1) {
    return null;
  }
  var end = document.cookie.indexOf( ";", len );
  if ( end == -1 ) {
    end = document.cookie.length;
  }
  return unescape(document.cookie.substring(len, end));
}

/******************************
 * Set a cookie.
 *
 * Original provided by: Dustin Diaz.
 */
function setCookie(name, value, expires, path, domain, secure) {
  var today = new Date();
  today.setTime( today.getTime() );
  if ( expires ) {
    expires = expires * 1000 * 60 * 60 * 24;
  }
  var expires_date = new Date( today.getTime() + (expires) );
  document.cookie =
    name + "=" + escape(value)
    + ((expires) ? ";expires=" + expires_date.toGMTString() : "" )
    + ((path)    ? ";path="    + path : "" )
    + ((domain)  ? ";domain="  + domain : "" )
    + ((secure)  ? ";secure" : "" );
}

/******************************
 * Delete a cookie.
 *
 * Original provided by: Dustin Diaz.
 */
function deleteCookie( name, path, domain ) {
  if (getCookie(name)) {
    document.cookie =
      name + "="
      + ((path) ? ";path=" + path : "")
      + ((domain) ? ";domain=" + domain : "" )
      + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
  }
}

// end of file

