// whitespace characters
var whitespace = " \t\n\r";

var defaultEmptyOK = false;

var section = '';

// checkString (TEXTFIELD theField, STRING s, [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is not all whitespace.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
	
function checkString (theField, emptyOK) {
	// Next line is needed on NN3 to avoid "undefined is not a number" error
    // in equality comparison below.
    if (checkString.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (isWhitespace(theField.value)) {
		return false;
    } else return true;
}

// Check whether string s is empty.

function isEmpty(s) {
	return ((s == null) || (s.length == 0))
}

// Returns true if string s is empty or
// whitespace characters only.

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;
}

// Check Email (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid Email.
//
// If emptyOK == true then value cannot be null

function checkEmail (theField, emptyOK) {
    if (checkEmail.arguments.length == 1) {
        emptyOK = defaultEmptyOK;
    }   
    if ((emptyOK == true) && (isEmpty(theField.value))) {
        return true;
    } else if (!checkEmailInternal(theField.value, false)) {
        return false;
    } else {
        return true;
    }
}


                                                                                                                                                                                                                                                               
function checkEmailInternal (emailStr, reportError) {

// if reportError = true then alert, false - silent execution

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

	var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

	var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

	var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

	var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

	var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

	var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

	var matchArray=emailStr.match(emailPat);
	
	if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

		if (reportError) 
			alert("Email address seems incorrect (check @ and .'s)");
		return false;
	}
	
	var user=matchArray[1];
	var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
			if (reportError) 
				alert("Ths username contains invalid characters."); 
			return false;
		}
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			if (reportError) 
				alert("Ths domain name contains invalid characters."); 
			return false;
		}
	}

// See if "user" is valid 

	if (user.match(userPat)==null) {
	// user is not valid
		if (reportError) 
			alert("The username doesn't seem to be valid."); 
		return false;
	}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
	// this is an IP address
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				if (reportError) 
					alert("Destination IP address is invalid!");
				return false;
			}
		}
		return true;
	}

// Domain is symbolic name.  Check if it's valid.
 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			if (reportError) 
				alert("The domain name does not seem to be valid.");
			return false;
		}
	}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
		if (reportError) 
			alert("The address must end in a well-known domain or two letter " + "country."); 
		return false;
	}

// Make sure there's a host name preceding the domain.

	if (len<2) {
		if (reportError)  
			alert("This address is missing a hostname!");  
		return false;
	}

// If we've gotten this far, everything's valid!
	return true;
}

// Check the grant amount value
//
// If emptyOK == true then value cannot be null
// Checks if value is a number

function isValidAmount (theField, emptyOK)
{   if (isValidAmount.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else if ( (isNaN(theField.value)) || ((emptyOK == false) && (isEmpty(theField.value)))  ) {
                return false;
        } else 
                return true;
}

// Checks if one of the radio buttons is checked
/*
function isRadioChecked(radioGroup) {
        for(var i=0;i<radioGroup.length;i++) {
                if (radioGroup[i].checked) 
                        return true
        }
        return false;
}*/

function isRadioChecked(radioGroup) {
        for(var i=0;i<radioGroup.length;i++) {
                if (radioGroup[i].checked) 
                        return radioGroup[i].value;
        }
        return false;
}

// Validate Check Box
function isCheckBoxChecked(field) {
     var strValue= field.checked;
     if (!strValue) {
     	return false;
     } else {
	 	return true;
	}
}
        
function checkPhoneSuffix(theField, emptyOK) {

        if (checkPhoneSuffix.arguments.length == 1) emptyOK = defaultEmptyOK;
        if ((emptyOK == true) && (isEmpty(theField.value))) {
                return true;
        } else {
                if (!isInteger(theField.value) || theField.value.length != 4) {
                        return false;
                }
        }

        return true;
}

function checkPhonePrefix(theField, emptyOK) {

        if (checkPhonePrefix.arguments.length == 1) emptyOK = defaultEmptyOK;
        if ((emptyOK == true) && (isEmpty(theField.value))) {
                return true;
        } else {
                if (!isInteger(theField.value) || theField.value.length != 3) {
                        return false;
                }
        }

        return true;
}

function checkPhoneAreaCode(theField, emptyOK) {

        if (checkPhoneAreaCode.arguments.length == 1) emptyOK = defaultEmptyOK;
        if ((emptyOK == true) && (isEmpty(theField.value))) {
                return true;
        } else {
                if (!isInteger(theField.value) || theField.value.length != 3) {
                        return false;
                }
        }

        return true;
}

function checkPhoneExtension(theField, emptyOK) {

        if (checkPhoneExtension.arguments.length == 1) emptyOK = defaultEmptyOK;
        if ((emptyOK == true) && (isEmpty(theField.value))) {
                return true;
        } else {
                if (!isInteger(theField.value)) {
                        return false;
                }
        }

        return true;
}

// check5DigitZIP(TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid ZIP code.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function check5DigitZIP(theField, emptyOK) {
        if (check5DigitZIP.arguments.length == 1) emptyOK = defaultEmptyOK;
        if ((emptyOK == true) && (isEmpty(theField.value))) {
                return true;
        } else {
                if (!isInteger(theField.value) || theField.value.length != 5) {
                        return false;
                }
        }

        return true;
}

function checkZipCodeExt(theField, emptyOK) {
        if (checkZipCodeExt.arguments.length == 1) emptyOK = defaultEmptyOK;
        if ((emptyOK == true) && (isEmpty(theField.value))) {
                return true;
        } else {
          if (!isInteger(theField.value) || theField.value.length != 4) {
                return false;
          }
        }

        return true;
}

// 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;
}



// Removes all characters which do NOT appear in string bag
// from string s.

function stripCharsNotInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is 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;
}

// Returns true if character c is a digit
// (0 .. 9).

function isDigit(c) {
        return ((c >= "0") && (c <= "9"))
}

// isInteger (STRING s [, BOOLEAN emptyOK])
//
// Returns true if all characters in string s are numbers.
//
// Accepts non-signed integers only. Does not accept floating
// point, exponential notation, etc.
//
// We don't use parseInt because that would accept a string
// with trailing non-numeric characters.
//
// By default, returns defaultEmptyOK if s is empty.
// There is an optional second argument called emptyOK.
// emptyOK is used to override for a single function call
//      the default behavior which is specified globally by
//      defaultEmptyOK.
// If emptyOK is false (or any value other than true),
//      the function will return false if s is empty.
// If emptyOK is true, the function will return true if s is empty.
//
// EXAMPLE FUNCTION CALL:     RESULT:
// isInteger ("5")            true
// isInteger ("")             defaultEmptyOK
// isInteger ("-5")           false
// isInteger ("", true)       true
// isInteger ("", false)      false
// isInteger ("5", false)     true

function isInteger(s) {

        var i;

        if (isEmpty(s)) {
                if (isInteger.arguments.length == 1) {
                        return defaultEmptyOK;
                } else {
                        return (isInteger.arguments[1] == true);
                }
        }

    // 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;
}

// Checks if Date1 which consists of year1, month1, and day1
// is prior to Date2 which consists of year2, month2, and day2

function isPriorDate(year1, month1, day1, year2, month2, day2) {
        
        intYear1 = parseInt(year1, 10);
        intYear2 = parseInt(year2, 10);
        
        intMonth1 = parseInt(month1, 10);
        intMonth2 = parseInt(month2, 10);
        
        intDay1 = parseInt(day1, 10);
        intDay2 = parseInt(day2, 10);
        
        if (intYear1 < intYear2)
                return true;
        else if ( (intYear1 == intYear2) && (intMonth1 < intMonth2) )
                return true;
        else if ( (intYear1 == intYear2) && (intMonth1 == intMonth2) && (intDay1 < intDay2) )
                return true;
        else 
                return false;
}

function checkDate(strYear, strMonth, strDay) {

        var intday;
        var intMonth;
        var intYear;

        var minYear=1900;
        var maxYear=2100;

        intday = parseInt(strDay, 10);
        if (isNaN(intday)) {
                return false;
        }

        intMonth = parseInt(strMonth, 10);
        if (isNaN(intMonth)) {
                return false;
        }

        intYear = parseInt(strYear, 10);
        if (isNaN(intYear)) {
                return false;
        }

        if (intYear < minYear || intYear > maxYear) {
			return false;
		}

        if (intMonth > 12 || intMonth < 1) {
                return false;
        }

        if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
                return false;
        }

        if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
                return false;
        }

        if (intMonth == 2) {
                if (intday < 1) {
                        return false;
                }

                if (isLeapYear(intYear) == true) {
                        if (intday > 29) {
                                return false;
                        }
                } else {
                        if (intday > 28) {
                                return false;
                        }
                }
        }

        return true;
}


function isLeapYear(intYear) {
        if (intYear % 100 == 0) {
                if (intYear % 400 == 0) { return true; }
        }
        else {
                if ((intYear % 4) == 0) { return true; }
        }
        return false;
}

function leadingZero (num) {
        if (num >= 10 ) return num;
                return "0" + num;
}

function isDateNotInFuture(strYear, strMonth, strDay) {

        var intday;
        var intMonth;
        var intYear;

        intday = parseInt(strDay, 10);
        if (isNaN(intday)) {
                return false;
        }

        intMonth = parseInt(strMonth, 10);
        if (isNaN(intMonth)) {
                return false;
        }

        intYear = parseInt(strYear, 10);
        if (isNaN(intYear)) {
                return false;
        }

        if (intMonth > 12 || intMonth < 1) {
                return false;
        }

        if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
                return false;
        }

        if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
                return false;
        }

        if (intMonth == 2) {
                if (intday < 1) {
                        return false;
                }

                if (isLeapYear(intYear) == true) {
                        if (intday > 29) {
                                return false;
                        }
                } else {
                        if (intday > 28) {
                                return false;
                        }
                }
        }

        var curDate = new Date();
        var curYear = curDate.getYear();
        var curMonth = curDate.getMonth() + 1;
        var curDay = curDate.getDate();

        // Hack to get correct year.  If year < 200, then add 1900.
        if (curYear < 200) {
                curYear = curYear + 1900;
        }

        if (intYear > curYear) {
                return false;
        } else {
                if (intYear < curYear) {
                        return true;
                }
        }

        if (intMonth > curMonth) {
                return false;
        } else {
                if (intMonth < curMonth) {
                        return true;
                }
        }

        if (intday > curDay) {
                return false;
        } else {
                if (intday < curDay) {
                        return true;
                }
        }

        // This line gets called if the date is today.
        return true;
}

// 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 openReferencesPopup(page) {
	OpenWin = this.open(page, "References", "scrollbars=yes,resizable=yes,width=550,height=600");
}

function openNewWindow(page,name,width,height,top,left,propSet) {
	
	var windowProps = new Array (8);

	windowProps[0] = "resizable=yes";
	windowProps[1] = "scrollbars=yes";
	windowProps[2] = "titlebar=yes";
	windowProps[3] = "toolbar=yes";
	windowProps[4] = "menubar=yes";
	windowProps[5] = "location=yes";
	windowProps[6] = "status=yes";
	windowProps[7] = "directories=yes";
	
	var myProps = "";
	var mySize = "";
	
	if (propSet == 'one') {
		 myProps = ',' + windowProps[0] + ',' + windowProps[1];
	} else if (propSet == 'print') {
		 myProps = ',' + windowProps[4];
	} else if (propSet == "full") {
		myProps = ',' + windowProps.join(",");
	} else {
		myProps = "";
	}	
	
	if ((width > 50)||(height > 50)) {
		var mySize = 'width=' + width + ',' + 'height=' + height + ',' + 'top=' + top + ',' + 'left=' + left;
	}
	
	var myString = mySize + myProps;
	window.open(page,name,myString);
	
}

function openEmailColleaguePopup(page, emailPage) {
	var fullURL = page + "?url=" + emailPage;
	OpenWin = this.open(fullURL, "Email", "scrollbars=yes,resizable=yes,width=600,height=610");
}

function popProDisclaimer(url) {
	legal=window.open(url,"legal","width=440,height=240,menubar=no,status=no,scrollbars=no,scrollable=no,toolbar=no,resizable=no,location=no");
}

function printRecipe() {
	if (document.location.search != "") {
		mark = document.location.search + "&";
	} else {
		mark = "?";
	}
	var recipePage = document.location.pathname + mark +'printRecipe=yes';
	openNewWindow(recipePage,'Recipe',750,600,0,0,'full');
}

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 showPrintPage(loc) {
	if (loc.search != "") {
		mark = loc.search + "&";
	} else {
		mark = "?";
	}
	var url = loc.pathname + mark +'printVersion=yes';
	window.open(url);
}

function openOutsideLink(theURL,winName,features) {
	window.open(theURL,winName,features);
}

function submitSearch()
{
        if(validSearchForm()) {
            document.googleSearch.submit();
        }
}

function validSearchForm()
{
    var searchArg;

    searchArg = document.googleSearch.elements["searchString"];
    if(!checkString(searchArg)){
        alert("Please input search argument");
        searchArg.select();
        return false;
    }
    searchArg.value = searchArg.value.toLowerCase();
    return true;
}

function getRadioValue(radioGroup) {
        for(var i=0;i<radioGroup.length;i++) {
                if (radioGroup[i].checked) 
                        return radioGroup[i].value;
        }
        return false;
}

function formatCurrencyField(theField) {
	var formatedCurrency;
	formatedCurrency = formatCurrency(theField.value);
	if (formatedCurrency != -1) {
		theField.value = formatedCurrency;
	} else {
		theField.value = "";
	}
}

function toUpperCaseField(theField) {
	var afterTrim = trim(theField.value);
	if ((checkString(afterTrim, true)) && (afterTrim != "") && (afterTrim != " ")) {
		theField.value = toUpperCaseFirstLetters(theField.value);
	}
}

function toUpperCaseFirstLetters(text) {
	
	var capBySpace = text.toLowerCase();
	var val_1 = '';
	capBySpace = capBySpace.split(' ');
	
	for(var c=0; c<capBySpace.length; c++) {
		val_1 += capBySpace[c].substring(0,1).toUpperCase() + capBySpace[c].substring(1,capBySpace[c].length) + ' ';
	}
	
	var capByDash = val_1;
	var val_2 = '';
	capByDash = capByDash.split('-');
	
	for(var i=0; i<capByDash.length; i++) {
		val_2 += capByDash[i].substring(0,1).toUpperCase() + capByDash[i].substring(1,capByDash[i].length) + '-';
	}
	
	val_2 = val_2.substring(0,(val_2.length - 2));
	return val_2;
}

/*
Form field Limiter script- By Dynamic Drive
For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
This credit MUST stay intact for use
*/
var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
	if (window.event&&event.srcElement.value.length>=maxlength)
		return false
	else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
		var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
		if (pressedkey.test(String.fromCharCode(e.which)))
			e.stopPropagation()
	}
}

function countlimit(maxlength,e,placeholder){
	var theform=eval(placeholder)
	var lengthleft=maxlength-theform.value.length
	var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
	if (window.event||e.target&&e.target==eval(placeholder)){
		if (lengthleft<0)
			theform.value=theform.value.substring(0,maxlength)
		placeholderobj.innerHTML=lengthleft
	}
}


function displaylimit(thename, theid, thelimit){
	var theform=theid!=""? document.getElementById(theid) : thename
	var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> characters remaining on your input limit'
	if (document.all||ns6)
		document.write(limit_text)
	if (document.all){
		eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
		eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
	}
	else if (ns6){
		document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true);
		document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
	}
}

function validateMonthYear(monthField, yearField, emptyOK) {
  if (validateMonthYear.arguments.length == 2) emptyOK = defaultEmptyOK;
  if ((emptyOK == true) && (!isInteger(monthField.value) && isEmpty(yearField.value))) return true;
  var minYear=1900;
  var maxYear=2100;
  if (monthField.value > 12 || monthField.value < 1) {
	return false;
  }
  if (yearField.value.length != 4 || !isInteger(yearField.value) || yearField.value < minYear || yearField.value > maxYear)
	return false;
  return true;
}
	
function checkState(stateField, emptyOK) {
  if (checkState.arguments.length == 1) emptyOK = defaultEmptyOK;
  if ((emptyOK == true) && (isEmpty(stateField.value))) return true;
  if (stateField.value.length != 2) 
    return false;
  return true;
}

function MM_preloadImages() {
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() {
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) {
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() {
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function printpage(){
	window.print();
}

// Select Value in Drop Down Menu
function selectDropDown(optionGroup, value) {
    if(value == "") {
    	return;
    } else {
        for(var i = 0; i < optionGroup.options.length; i++) {
            if(optionGroup.options[i].value == value) {
                optionGroup.options[i].selected = true;
                return;
            }
        }
    }
}

// Check if value is selected
function isSelectedInDropDown(optionGroup, value) {
    if(value == "" || !isInteger(value)) {
    	return;
    } else if (optionGroup.options[value-1].selected == true) {
    	return true;	
    } else {
		return false;
	}
}

//-->