/* ***********************************************************
BROWSER.JS - JS Browser check & CSS redirect
** =========================================
**
** Author      Ver  Date    Comments
** ======      ===  ====    ========
** Scott Ion   1.0  1/1/00  First release
**
** Copyright 2000, 10n Inc., all rights reserved.
********************************************************* */

version=parseInt(navigator.appVersion);
if (navigator.appVersion.indexOf('5.')>-1){version=5};
  browser='OTHER';
if (navigator.appName=='Netscape'){browser='NS';}
if (navigator.appName=='Microsoft Internet Explorer'){browser='MSIE';}
if (navigator.appVersion.indexOf('MSIE 3')>0) {browser='MSIE3';}


if (browser=='MSIE') {
        document.styleSheets[0].href="css/style.css";
}

if (document.images) {
  option1_off = new Image(80,20);
  option1_off.src = "images/about.gif";
  option1_on = new Image(80,20);
  option1_on.src = "images/about_over.gif";

  option2_off = new Image(80,20);
  option2_off.src = "images/projects.gif";
  option2_on = new Image(80,20);
  option2_on.src = "images/projects_over.gif";

  option3_off = new Image(80,20);
  option3_off.src = "images/partners.gif";
  option3_on = new Image(80,20);
  option3_on.src = "images/partners_over.gif";

  option4_off = new Image(80,20);
  option4_off.src = "images/contact.gif";
  option4_on = new Image(80,20);
  option4_on.src = "images/contact_over.gif";

}

function rollover(imgDocID,imgObjName) {
    if (document.images) {
    document.images[imgDocID].src = eval(imgObjName + ".src");
  }
}

// Declare 'Page level' variables

var status = true;
var errors = "";
var warnings = "Warnings:\n";
var firstErrorField = "";
var warningField;
var osubmit = true;

// Function:        Validate
// Description:     Turns form validation on/off
// Input arguments: none
// Return value:    true / false
// Note:            
// 

function validate() {
  return true;
}

// Function:        buttonSubmit
// Description:     Eliminates double-click submissions
// Input arguments: form (form name)
// Return value:    true / false
// Note:            
// 

function buttonSubmit(form) {
  // ensure we don't double-submit if user double-clicks button
  if (!osubmit) { 
    return false; 
  }
  osubmit = false;

  form.submit();
  return true;
}

// Function:        trim
// Description:     This function remove leading and trailing spaces from a string
// Input arguments: str (String)
// Return value:    none
// Note:            
//
function trim(str) {
  return ltrim(rtrim(str))
}


// Function:        rtrim
// Description:     This function remove trailing space from a string
// Input arguments: str (String)
// Return value:    none
// Note:            
//
function rtrim(str) {
  var i = 0
  for (i = str.length - 1; i > -1; i--) {
    if (str.charAt(i) != ' ') break
  }
  return str.substring(0, i+1)
}

// Function:        ltrim
// Description:     This function remove leading spaces from a string
// Input arguments: str (String)
// Return value:    none
// Note:            
//
function ltrim(str) {
  var trimStr = ""
  var i = 0
  for (i = 0; i < str.length; i++) {
    if (str.charAt(i) != ' ') break
  }
  if (i < str.length) trimStr = str.substring(i, str.length)
  return trimStr
}

// Function:        addError
// Description:     This function builds an error message based on the specified 
//                  error type.
// Input arguments: objName (String)
//                  errType (String)
//                  fieldName (String)
//                  dtlMsg (String)
//                  addlInfo (String)
// Return value:    none
// Note:            
// 
function addError(objName, errType, fieldName, addlInfo) {
  status = false;
  if (countError() < 10) {
    getMessage(errType,fieldName,addlInfo);
    if(firstErrorField == "") {
      firstErrorField = objName;
    }
  } else if (countError() == 10) {
    errors += "\n\nAdditional error messages may be displayed once these have been corrected.";
  } else {
    return false;
  }
}


// Function:        countError
// Description:     This function counts error messages  
// Input arguments: none
// Return value:    none
// Note:            
// 
function countError() {
  var substrings = errors.split("\n");
  return substrings.length - 1;
}



// Function:        displayError
// Description:     This function display an error message based on the specified 
//                  error type.
// Input arguments: none
// Return value:    none
// Note:            
// 
function displayError() {
  firstErrorField.focus();
  window.alert(errors);

// clear page variables & reset values
  errors = "";
  warnings = "Warnings:\n";
  status = true;
  firstErrorField = "";
}

// Function:        getMessage
// Description:     This function retrieves error message wording
// Input arguments: errType (String)
//                  fieldName (String)
//                  addlInfo (String)
// Return value:    none
// Note:            
// 

function getMessage(errType,fieldName,addlInfo) {

  if (errType == "REQUIRED_FIELD") { 
    errors += "\n" + fieldName + " is a required field. Please return to the form and add some details"
  }
}
