function movepic(img_name, img_src) { 
		document[img_name].src=img_src;
}

// Validation Regexes
// updated
var reWhitespace = /^\s+$/;
var reEmail = /^.+\@.+\..+$/;
var reInteger = /^\d+$/;
var reDollar = /^\$?((\d*\.\d\d)|(\d+))$/;

// VARIABLE DECLARATIONS
var digits = "0123456789";
var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz";
var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

// whitespace characters as defined by this sample code
var whitespace = " \t\n\r";

// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";

// characters which are allowed in US phone numbers
var validUSPhoneChars = digits + phoneNumberDelimiters;
 
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = digits + phoneNumberDelimiters + "+";

// non-digit characters which are allowed in 
// Social Security Numbers
var SSNDelimiters = "- ";

// characters which are allowed in Social Security Numbers
var validSSNChars = digits + SSNDelimiters;

// U.S. Social Security Numbers have 9 digits.
// They are formatted as 123-45-6789.
var digitsInSocialSecurityNumber = 9;

// U.S. phone numbers have 10 digits.
// They are formatted as 123 456 7890 or (123) 456-7890.
var digitsInUSPhoneNumber = 10;

// non-digit characters which are allowed in ZIP Codes
var ZIPCodeDelimiters = "-";

// our preferred delimiter for reformatting ZIP Codes
var ZIPCodeDelimeter = "-";

// characters which are allowed in Social Security Numbers
var validZIPCodeChars = digits + ZIPCodeDelimiters;

// U.S. ZIP codes have 5 or 9 digits.
// They are formatted as 12345 or 12345-6789.
var digitsInZIPCode1 = 5;
var digitsInZIPCode2 = 9;

// Another way to Validate a phone number
function isPhone(s){
			if((s == null) || (s.length == 0)){
				return false;
			}
			var stripped = s.replace(/[\(\)\.\-\ ]/g, '');

			if (!/^\d{10}$|^$/.test(stripped)) 
			{
				return false;
			}
			
			return true;
}

//check to make sure birthday is not  empty and has mm/dd/yyyy format
function isBirthday(s){

		if (!/^(12|11|10|0[1-9])\/(31|30|[12][0-9]|0[1-9])\/(19|20)\d{2}$|^$/.test(s)){
				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) {
    return (isEmpty(s) || reWhitespace.test(s));
}

// Returns true for an integer
function isInteger (s) {
   var i;
    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    return reInteger.test(s)
}

// Removes all characters which appear in regexp bag from string s.
// NOTES:
// 1) bag must be a regexp which matches single characters in isolation,
//    i.e. A or B or C or D or 1 or 2 ...
//    e.g. /\d/g  or /[a-zA-Z]/g
// 2) make sure to append the 'g' modifier (for global search & replace)
//    at the end of the regexp
//    e.g. /\d/g  or /[a-zA-Z]/g
function stripCharsInRE (s, bag) {
	return s.replace(bag, "")
}

// 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;
}

// Removes all whitespace characters from s.
// Global variable whitespace (see above)
// defines which characters are considered whitespace.
function stripWhitespace (s) {
   return stripCharsInBag (s, whitespace)
}

// Returns true if it is a valid email address.
function isEmail (s) {
   if (isEmpty(s)) {  
   		return false
    }
	else if(s.length < 4){
		return false;
	}
	else if(s.indexOf('@') == -1){ 
		return false;
	}
	else{ return true; }
}

function isCharacters(s){ 
   if(isEmpty(s)) {  
   		return false;
    }
   else if(s.length < 6){
   		return false;
   }
   else{
   		return true;
   }
}
// Checks the length a of string for a minimum and maximum length;
function isLengthinRange (s, minimum, maximum) {
	if (s.length < minimum || s.length > maximum) {
		return false;
	} else {
		return true;
	}
}

// function to determine if value is in acceptable range for this application
function inRange(inputStr, lo, hi) {
	if (!isInteger (inputStr)) {
		return false
	}
	var num = parseInt(inputStr)
		if (num < lo || num > hi) {
			return false
		}
	return true
}

// Match the value property of 2 fields
function isMatch(fielda, fieldb) {
	if (fielda.value != fieldb.value) {
		return false;
	} else {
		return true;
	}
}

// Checks for a checked radio button
function isRadioChecked(radiofield) {
	for (var i = 0; i < radiofield.length; i++) {
		if (radiofield[i].checked) {
			return true;
		}
	}
	return false;
}

// Checks for a selected option
function isOptionSelected(selectfield) {
	if (selectfield.options[selectfield.selectedIndex].value == "") {
		return false;
	} else {
		return true;
	}
}

// Checks for a checked radio button
function isMultiSelected(multifield,minimum) {
	var selectcount = 0;
	for (var i = 0; i < multifield.length; i++) {
		if (multifield[i].selected) {
			selectcount++;
		}
	}
	if (selectcount >= minimum) {
		return true;
	} else {
		return false;
	}
}

// Validates a phone number
function isUSPhoneNumber (s)
{   if (isEmpty(s)) 
       if (isUSPhoneNumber.arguments.length == 1) return defaultEmptyOK;
       else return (isUSPhoneNumber.arguments[1] == true);
    return (isInteger(s) && s.length == digitsInUSPhoneNumber);
}

// isZIPCode (STRING s [, BOOLEAN emptyOK])
// 
// isZIPCode returns true if string s is a valid 
// U.S. ZIP code.  Must be 5 or 9 digits only.
//
// NOTE: Strip out any delimiters (spaces, hyphens, etc.)
// from string s before calling this function.  
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isZIPCode (s) {
  if (isEmpty(s)) 
       if (isZIPCode.arguments.length == 1) return defaultEmptyOK;
       else return (isZIPCode.arguments[1] == true);
   return (isInteger(s) && 
            ((s.length == digitsInZIPCode1) ||
             (s.length == digitsInZIPCode2)))
}

function reformat (s)
{   var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}


// Validates a date via 3 fields, month,day,year.
function checkdate(monthselect,dayselect,yearselect,message) {
	var monthVal = parseInt(monthselect.options[monthselect.selectedIndex].value);
	var dayVal = parseInt(dayselect.options[dayselect.selectedIndex].value);
	var monthMax = new Array(31,31,29,31,30,31,30,31,31,30,31,30,31);
	var top = monthMax[monthVal];
	if ((!inRange(dayVal,1,top)) || (!inRange(yearselect[yearselect.selectedIndex].value,1900,2100))) {
		alert(message);
		return false;
	} else {
		return true;
	}
}

// Check the field
function checkString (theField, message, emptyOK) {
	// Next line is needed on NN3 to avoid "undefined is not a number" error
    // in equality comparison below.
    if (checkString.arguments.length == 2) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (isWhitespace(theField.value)) 
       return warnEmpty (theField, message);
    else return true;
}

// Check an Email
function checkEmail (theField, message, emptyOK) {
	if (checkEmail.arguments.length == 2) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else if (!isEmail(theField.value, false)) 
       return warnInvalid (theField, message);
    else return true;
}

// Checks to make sure entry is in range.
function checkRange(theField, lo, hi, message, emptyOK) {
	if (checkRange.arguments.length == 4) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else if (!inRange(theField.value, lo, hi)) 
       return warnInvalid (theField, message);
    else return true;
}

// Checks a password for length - This may need to be customized on a per instance basis
function checkPassword (theField, message, emptyOK) {
	if (checkPassword.arguments.length == 2) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else if (!isLengthinRange(theField.value, 1, 20)) 
       return warnInvalid (theField, message);
    else return true;
}

// Checks for a matching confirmation password. - This may need to be customized on a per instance basis
function checkConfirmPassword (fielda, fieldb, message) {
	var emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(fielda.value))) return true;
    else if (!isMatch(fielda, fieldb)) 
       return warnInvalid (fielda, message);
    else return true;
}

// Requires a selection for a radio set
function checkRadio(radiofield, message) {
    if (!isRadioChecked(radiofield)) {
		alert(message);
		return false;
    } else {
		return true;
	}
}

// Checks for a selected option
function checkSelect(selectfield, message) {
	if (!isOptionSelected(selectfield)) {
		alert(message);
		return false;
	} else {
		return true;
	}
}

// Checks for a checked radio button
function CheckMultiSelected(multifield,minimum,message) {
	if (!isMultiSelected(multifield,minimum)) {
		alert(message);
		return false;
	} else {
		return true;
	}
}

// reformats a zip code
function reformatZIPCode (ZIPString)
{   if (ZIPString.length == 5) return ZIPString;
    else return (reformat (ZIPString, "", 5, "-", 4));
}

// Checks for a valid zip code
function checkZipCode (iZIPCode, message, emptyOK) {
   if (checkZipCode.arguments.length == 2) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(iZIPCode.value))) return true;
    else
    { var normalizedZIP = stripCharsInBag(iZIPCode.value, ZIPCodeDelimiters)
      if (!isZIPCode(normalizedZIP, false)) {
         return warnInvalid (iZIPCode, message);
      } else {
	    // if you don't want to insert a hyphen, comment next line out
         iZIPCode.value = reformatZIPCode(normalizedZIP)
         return true;
      }
    }
}

// takes USPhone, a string of 10 digits
// and reformats as (123) 456-789

function reformatUSPhone (USPhone)
{   return (reformat (USPhone, "", 3, "-", 3, "-", 4))
}

// checkUSPhone (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid US Phone.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkUSPhone (theField, message, emptyOK)
{   if (checkUSPhone.arguments.length == 2) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    {  var normalizedPhone = stripCharsInBag(theField.value, phoneNumberDelimiters)
       if (!isUSPhoneNumber(normalizedPhone, false)) 
          return warnInvalid (theField, message);
       else 
       {  // if you don't want to reformat as (123) 456-789, comment next line out
          theField.value = reformatUSPhone(normalizedPhone)
          return true;
       }
    }
}


// Alert a warning for a field with a message
function warnEmpty (theField, message) {
	theField.focus();
	alert(message);
	return false;
}

// Alert a warning for a field with a message, highlight the text
function warnInvalid (theField, message)
{   theField.focus();
    theField.select();
    alert(message);
    return false;
}

// Date Validation functions for checking form values

function chkdate(objName) {
	var strDatestyle = "US"; //United States date style
	var strDate;
	var strDateArray;
	var strDay;
	var strMonth;
	var strYear;
	var intday;
	var intMonth;
	var intYear;
	var booFound = false;
	var datefield = objName;
	var strSeparatorArray = new Array("-"," ","/",".");
	var intElementNr;
	var err = 0;
	var strMonthArray = new Array(12);
	strMonthArray[0] = "Jan";
	strMonthArray[1] = "Feb";
	strMonthArray[2] = "Mar";
	strMonthArray[3] = "Apr";
	strMonthArray[4] = "May";
	strMonthArray[5] = "Jun";
	strMonthArray[6] = "Jul";
	strMonthArray[7] = "Aug";
	strMonthArray[8] = "Sep";
	strMonthArray[9] = "Oct";
	strMonthArray[10] = "Nov";
	strMonthArray[11] = "Dec";
	strDate = datefield.value;

	if (strDate.length < 1) {
		return true;
	}
	
	for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
		if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
			strDateArray = strDate.split(strSeparatorArray[intElementNr]);
			if (strDateArray.length != 3) {
				err = 1;
				return false;
			}
			else {
				strDay = strDateArray[0];
				strMonth = strDateArray[1];
				strYear = strDateArray[2];
			}
		booFound = true;
	  }
	}
	
	if (booFound == false) {
		if (strDate.length>5) {
			strDay = strDate.substr(0, 2);
			strMonth = strDate.substr(2, 2);
			strYear = strDate.substr(4);
	   }
	}
	
	if (strYear.length == 2) {
			strYear = '20' + strYear;
	}
	// US style
	if (strDatestyle == "US") {
		strTemp = strDay;
		strDay = strMonth;
		strMonth = strTemp;
	}
	
	intday = parseInt(strDay, 10);

	if (isNaN(intday)) {
		err = 2;
		return false;
	}
	
	intMonth = parseInt(strMonth, 10);
	
	if (isNaN(intMonth)) {
		for (i = 0;i<12;i++) {
			if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
				intMonth = i+1;
				strMonth = strMonthArray[i];
				i = 12;
	   		}
		}

		if (isNaN(intMonth)) {
			err = 3;
			return false;
		}
	}
	
	intYear = parseInt(strYear, 10);
	if (isNaN(intYear)) {
		err = 4;
		return false;
	}
	if (intMonth>12 || intMonth<1) {
		err = 5;
		return false;
	}
	if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
		err = 6;
		return false;
	}
	if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
		err = 7;
		return false;
	}
	if (intMonth == 2) {
		if (intday < 1) {
			err = 8;
			return false;
		}
		//check for leapyear
		if (LeapYear(intYear) == true) {
				if (intday > 29) {
					err = 9;
					return false;
				}
		}
		else {
				if (intday > 28) {
					err = 10;
					return false;
				}
		}
	}

	return true;
}

function LeapYear(intYear) {
	if (intYear % 100 == 0) {
	if (intYear % 400 == 0) { return true; }
	}
	else {
	if ((intYear % 4) == 0) { return true; }
	}
	return false;
}

function openWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}