<!-- // Begin hiding from old browsers

// load whitespace characters: space,\n:manual line feed,\t:tab, and \r:carriage return
var whitespace = " \t\n\r";

// load quote characters
//var quotes = "\'\""
var quotes = "\""

// load both quote characters
var bquotes = "\'\""

// load comma characters
var commas = ","

// load dollar characters
var dollar = "$"


// isEmpty:  returns true if string s is empty

function isEmpty(s) 
{   return ((s == null) || (s.length == 0))
}

   
// isWhitespace: returns true if string s is empty or whitespace characters only.
// uses isEmpty

function isWhitespace(s)
{   var i;
    // Is s empty?
    if (isEmpty(s)) return true;
    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1) return false;
    }
    // All characters are whitespace.
    return true;
}

// hasWhitespace:  returns true if string s has whitespace characters

function hasWhitespace(s)
{   var i;
    // Search through string's characters one by one
    // until we find a whitespace character.
    // When we do, return true; if we don't, return false
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (whitespace.indexOf(c) != -1) return true;
    }
    // All characters are whitespace.
    return false;
}

// stripCharsInBag: removes all characters which appear in string bag from string s.

function stripCharsInBag (s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

// stripWhitespace: removes all whitespace characters from string s
// uses stripCharsInBag

function stripWhitespace(s)
{   return stripCharsInBag (s,whitespace)
}

// charInString:  finds a character in a string s

function charInString (c, s)
{   for (i = 0; i < s.length; i++)
    {   if (s.charAt(i) == c) return true;
    }
    return false
}

// stripInitialWhitespace: removes initial whitespaces from string s
// uses charInString

function stripInitialWhitespace (s)
{   var i = 0;
    while ((i < s.length) && charInString (s.charAt(i), whitespace))
       i++;
    var newstr = s.substring (i, s.length);
    return(newstr);
}


// isEmail: returns true if valid email address from string s
// * must be of form a@b.c -- in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
// * only one @ 

function isEmail(s)
{   // there must be >= 1 character before @, so we start looking at character position 1 (second character)
    var i = 1;
    var sLength = s.length;
    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }
    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;
    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }
    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    // make sure there is only one @
    var j = 0, k = 0;
    while (j < sLength)
    { if (s.charAt(j) == "@") k = k + 1;
    	j++
    }
    if (k != 1) return false;    
    else return true;
}


// hasQuotes: returns true if string s has double quote character

function hasQuotes(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   var c = s.charAt(i);
        if (quotes.indexOf(c) != -1) return true;
    }
    return false;
}

// hasAnyQuotes: returns true if string s has either single or double quote characters

function hasAnyQuotes(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   var c = s.charAt(i);
        if (bquotes.indexOf(c) != -1) return true;
    }
    return false;
}


// hasDollar: returns true if string s has quote characters

function hasDollar(s)
{   inputVal = s.value
	inputStr = inputVal.toString()
	for (var i = 0; i < inputStr.length; i++) {
		var oneChar = inputStr.charAt(i)
		if (oneChar == '$') {
			return true
		}
	}
	return false;
}
   
// hasCommas: returns true if string s has commas characters

function hasCommas(s)
{   inputVal = s.value
	inputStr = inputVal.toString()
	for (var i = 0; i < inputStr.length; i++) {
		var oneChar = inputStr.charAt(i)
		if (oneChar == ',') {
			return true
		}
	}
	return false
}

// chkLength: returns true if string s is longer than integer l
function chkLength(s,l)
{	var strLen = s.length;
	if (strLen > l) {return true;} else {return false};
}

// isDigit:  return true if character is a digit
function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

// isInteger:  returns true if string s in an integer
function isInteger(s)
{   var i;
    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (!isDigit(c)) return false;
    }
    // All characters are numbers.
    return true;
}

// isIntegerInRange:  returns true if integer string s is with range
// established by a and b
function isIntegerInRange (s, a, b)
{   // explicitly change the type to integer via parseInt
    // so that the comparison code below will work both on 
    // JavaScript 1.2 (which typechecks in equality comparisons)
    // and JavaScript 1.1 and before (which doesn't).
    var num = parseInt (s);
    return ((num >= a) && (num <= b));
}



function makeArray(n) {
//   this.length = n;
   for (var i = 1; i <= n; i++) {
      this[i] = 0
   } 
   return this
}

var daysInMonth = makeArray(12);
daysInMonth[1] = 31;
daysInMonth[2] = 29;   // must programmatically check this
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;

// daysInFebruary(INTEGER year): Given integer argument year, returns number 
// of days in February of that year.
function daysInFebruary(year)
{   // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}

// isDate(STRING year, STRING month, STRING day): returns true 
// if string arguments year, month, and day form a valid date.
function isDate (year, month, day)
{   // Explicitly change type to integer to make code work in both
    // JavaScript 1.1 and JavaScript 1.2.
    var intYear = parseInt(year);
    var intMonth = parseInt(month);
    var intDay = parseInt(day);

    // catch invalid days, except for February
    if (intDay > daysInMonth[intMonth]) return false; 
    if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;
    return true;
}

	// End of hide -->
	

// general purpose function to see if a suspected numeric input
// is a positive or negative number
// input should be pass as the object not value
function isNumber(input) {
  inputVal = input.value
	oneDecimal = false
	inputStr = inputVal.toString()
	for (var i = 0; i < inputStr.length; i++) {
		var oneChar = inputStr.charAt(i)
		if (i == 0 && oneChar == "-") {
			continue
		}
		if (oneChar == "." && !oneDecimal) {
			oneDecimal = true
			continue
		}
		if (oneChar < "0" || oneChar > "9") {
		  //alert("Invalid Number.")
		  input.focus()
		  input.select()
			return false
		}
	}
	return true
}

// general purpose function to see if a suspected numeric input
// is a positive or negative number
// input should be pass as the object not value
function isPosNumber(input) {
  inputVal = input.value
	oneDecimal = false
	inputStr = inputVal.toString()
	for (var i = 0; i < inputStr.length; i++) {
		var oneChar = inputStr.charAt(i)
		if (i == 0 && oneChar == "-") {
			//continue
			return false
		}
		if (oneChar == "." && !oneDecimal) {
			oneDecimal = true
			continue
		}
		if (oneChar < "0" || oneChar > "9") {
		  //alert("Invalid Number.")
		  input.focus()
		  input.select()
			return false
		}
	}
	return true
}

// general purpose function to see if a string is valid date
function validDate(input) {
	inputVal = input.value
	inputStr = inputVal.toString()
	strArray = inputStr.split('/')
	if ( strArray.length < 3 ) {
	    return false;
	} else {
		tmpArray = strArray[0].split('')
		if ( tmpArray.length = 2 ) {
			if ( parseInt(tmpArray[0]) == 0 ) {
				strArray[0] = tmpArray[1];
			}
		}
		tmpArray = strArray[1].split('')
		if ( tmpArray.length = 2 ) {
			if ( parseInt(tmpArray[0]) == 0 ) {
				strArray[1] = tmpArray[1];
			}
		}	
		
		if ( !isInteger(strArray[0]) || parseInt(strArray[0]) < 1 || parseInt(strArray[0]) > 12 || !(parseInt(strArray[0]))  ) {
			return false;
		}
		if ( !isInteger(strArray[2]) ||!(parseInt(strArray[2])) || parseInt(strArray[2]) < 1900 ) {
			return false;
		}
	    if ( !isInteger(strArray[1]) || !(parseInt(strArray[1])) || parseInt(strArray[1]) < 1 || parseInt(strArray[1]) > daysInMonth[parseInt(strArray[0])]) {
			return false; 
		}
	    if ((parseInt(strArray[0]) == 2) && (parseInt(strArray[1]) > daysInFebruary(parseInt(strArray[2])))) {
			return false;		
		}
	}	
	return true;
}


function openHTML( pageToLoad, winname, width, height, center) {

	xposition=0; yposition=0;
	if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height) / 2;
	}
	args = 'width=' + width + ',height=' + height + ',location=0,menubar=0,resizable=1,';
	args = args + 'scrollbars=1,status=0,titlebar=0,toolbar=0,hotkeys=0,screenx=' + xposition + ',';
	args = args + 'screeny=' + yposition + ',left=' + xposition + ',top=' + yposition;

	window.open( pageToLoad,winname,args);
}
