﻿<!--
// Accepts a number or string and formats it like U.S. currency
function formatCurrency(num) {
        num = num.toString().replace(/\$|\,/g,'');
        if(isNaN(num) || ( trim(num) == '') || (trim(num) == ' ')) { 
                return num = "-1";
        }
        sign = (num == (num = Math.abs(num)));
        num = Math.floor(num*100+0.50000000001);
        cents = num%100;
        num = Math.floor(num/100).toString();
        if(cents<10) {
                cents = "0" + cents;
        }
        for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
                num = num.substring(0,num.length-(4*i+3))+','+
                num.substring(num.length-(4*i+3));
                
        return (((sign)?'':'-') + num + '.' + cents);
}
// String will trim spaces from the string
function trim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   var obj = /  /g;
   while (temp.match(obj)) { temp = temp.replace(obj, " "); }
   return temp;
}
// Converts first letter of each word to upper case
function toUpper(oldStr) {
        var pattern = /(\w)(\w*)/;
        var parts;
        var firstLetter;
        var restOfWord;
        var newStr;
        var a;
        a = oldStr.split(/\s+/g);
        for (i = 0 ; i < a.length ; i ++ ) {
                parts = a[i].match(pattern);
                firstLetter = parts[1].toUpperCase();
                restOfWord = parts[2].toLowerCase();
                a[i] = firstLetter + restOfWord;
        }
        newStr = a.join(' ');
        return newStr;
}
// Returns the style object by the given name
function getStyleByName( name )
{
        var sheetList = document.styleSheets;
        var ruleList;
        var i, j;
        
        // look through stylesheets in reverse order that
        //  they appear in the document
        for (i=sheetList.length-1; i >= 0; i--)
        {
                if (sheetList[i].cssRules != null) // for Netscape Browser
                {
                        ruleList = sheetList[i].cssRules;
                }
                else // for Internet Explorer
                {
                        ruleList = sheetList[i].rules;
                }
                for (j=0; j<ruleList.length; j++)
                {
                        if (ruleList[j].selectorText == name)
                        {
                                return ruleList[j].style;
                        }   
                }
        }
        return null;
}
// Auto tab functionality
var isNN = ( navigator.appName.indexOf( "Netscape" ) != -1 ); 
 
function autoTab( input,len, e ) { 
    var keyCode    = ( isNN ) ? e.which : e.keyCode; 
    var filter    = ( isNN ) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46]; 
    if( input.value.length >= len && !containsElement( filter, keyCode )) { 
    input.value = input.value.slice( 0, len ); 
    input.form[( getIndex( input ) + 1 ) % input.form.length].focus(); 
    } 
    return true; 
} 
 
function containsElement( arr, ele ) { 
    var found = false, index = 0; 
    while( !found && index < arr.length ) 
    if( arr[index] == ele ) { 
        found = true; 
    } else { 
        index++; 
    } 
    return found; 
} 
 
function getIndex( input ) { 
    var index = -1, i = 0, found = false; 
    while ( i < input.form.length && index == -1 ) 
    if ( input.form[i] == input ) { 
        index = i; 
    } else { 
        i++; 
    } 
    return index; 
} 
function changeImages() {
    if (document.images) {
        for (var i=0; i<changeImages.arguments.length; i+=2) {
            document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
        }
    }
}
function newImage(arg) {
    if (document.images) {
        rslt = new Image();
        rslt.src = arg;
        return rslt;
    }
}
function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
    // W3C DOM
    return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
    // MSIE 4 DOM
    return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
    // NN 4 DOM.. note: this won't find nested layers
    return document.layers[objectId];
    } else {
    return false;
    }
} // getStyleObject
function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
    styleObject.visibility = newVisibility;
    return true;
    } else {
    // we couldn't find the object, so we can't change its visibility
    return false;
    }
}
function openOutsideLink(theURL,winName,features) {
    window.open(theURL,winName,features);
}
function redirect(theURL) {
    var outsideLinks = /http:/;
    
    if (theURL.search(outsideLinks) != -1) {
        window.open(theURL);
    } else {
        document.location = theURL;
    }
}
function disableCheckboxes(qNamePat, disableField){
        var theForm = document.questionnaire;
        
        for(i=0; i<theForm.elements.length; i++) {
            if(theForm.elements[i].name.substring(0,3) == qNamePat){
                var element=theForm.elements[i];
                element.blur();
                
                if (element.type == "text") {
                    element.value='';
                }
                
                if (element.type == "checkbox") {
                    element.checked=false;
                }
                
                element.disabled=disableField;
            }
        }
    }
    
function onMouseOver(element) {
     (element.parentNode).style.backgroundColor='#CEC9C5';
     element.style.color='#666666';
}
function onMouseOut(element) {
     (element.parentNode).style.backgroundColor='#9E958F';
     element.style.color='#FFFFFF';
}
-->