/* xbdhtml.js (Cross-Browser Nav4/Gecko/IE DHTML API) 
   14 May 98, Eric Krock, Copyright Netscape Communications
   Permission is granted to reuse, redistribute, and modify 
   without charge. */
	
// This is a simplified version of the JavaScript Client Sniffer code 
// found at http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html

function Is ()
{   // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase()

    // --- BROWSER VERSION ---
    this.major   = stringToNumber(navigator.appVersion)
    this.minor   = parseFloat(navigator.appVersion)

    this.nav     = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1)
                   && (agt.indexOf('compatible') == -1)))
    this.nav2    = (this.nav && (this.major == 2))
    this.nav3    = (this.nav && (this.major == 3))
    this.nav4    = (this.nav && (this.major == 4))
	
	//Netscape 6
	this.nav5    = (this.nav && (this.major == 5))
	this.nav6    = (this.nav && (this.major == 5))
	this.gecko   = (this.nav && (this.major >= 5))
	
	//Mozilla
	this.moz12   = (this.gecko && (agt.indexOf('gecko/20021130')!=-1))
//	this.moz13   = (this.gecko && (agt.indexOf('gecko/20030312')!=-1))
	this.moz2003 = (this.gecko && (agt.indexOf('gecko/2003')!=-1))
	this.moz2004 = (this.gecko && (agt.indexOf('gecko/2004')!=-1))
	this.moz2005 = (this.gecko && (agt.indexOf('gecko/2005')!=-1))
	this.moz2006 = (this.gecko && (agt.indexOf('gecko/2006')!=-1))
	this.moz13up = (this.moz2003 || this.moz2004 || this.moz2005 || this.moz2006)
//	this.moz131  = (this.gecko && (agt.indexOf('gecko/20030425')!=-1))
//	this.moz141  = (this.gecko && (agt.indexOf('gecko/20030624')!=-1))

    this.ie      = (agt.indexOf("msie") != -1)
    this.ie3     = (this.ie && (this.major == 2))
    this.ie4     = (this.ie && (this.major == 3))
    this.ie5     = (this.ie && (this.major == 4))


    this.opera   = (agt.indexOf("opera") != -1)
     
    this.nav4up  = this.nav && (this.major >= 4)
    this.ie4up   = this.ie  && (this.major >= 4)
}

var is = new Is();

/* A version of stringToNumber that returns 0 if there is NaN returned, or number is part of a string, like 100px... */
function stringToNumber(s)
{
        return parseInt(('0' + s), 10)
}

// Checks a form element to see if it is null. If it is null, return true.
// If the element's value is not null, return false.
function isNull( field ) {
  var selected = 0;
  var fieldIsNull = 0;
  if ( field.type == "text" ||
       field.type == "password" ||
       field.type == "textarea" ) {
    if ( field.value == "" )
      fieldIsNull = 1;
  } else if ( field.type == "select-one" ) {
      if ( field.options[field.selectedIndex].value == "%null%")
        fieldIsNull = 1;
  } else if ( field.type == "select-multiple" ) {
      fieldIsNull = 1;
      for ( i = 0; i < field.length; i++ )
        if ( field.options[i].selected )
          fieldIsNull = 0;
  } else if ( field.type == "undefined" ||
              field.type == "checkbox"  ||
              field.type == "radio" ) {
      fieldIsNull = 1;
      for ( i = 0; i < field.length; i++ )
        if ( field[i].checked )
          fieldIsNull = 0;
  }
  if ( fieldIsNull ) {
      if ( field.type == "text" ||
           field.type == "textarea"  ||
           field.type == "password"  ||
           field.type == "select-one"  ||
           field.type == "select-multiple" ) field.focus();
      return true;
  }
  
  return false;
}
