<!--
var isNav=false;
var isIE=false;
var coll = "";
var styleObj = "";
var NS6 = document.getElementById && !document.all ? true : false;

if(parseInt(navigator.appVersion) >= 4)
{
	if(navigator.appName == 'Netscape')
	{
		isNav = true;
	}
	else
	{
		isIE = true;
		coll = "all.";
		styleObj = ".style";
	}
}


function validateRequired(formName)
{
var focusMe;
var e;
var i;
var ok;
var prompt = '';
var validNumberPrompt = '';
var positiveNumberPrompt = '';
var invalidDecimalPrompt = '';
var invalidDatePrompt = '';
var invalidEmailPrompt = '';
var equalFieldsPrompt = '';
var invalidNumberOfDigitsPrompt = '';
var invalidPercentPrompt = '';
var numberTooLargePrompt = '';
var numberTooSmallPrompt = '';
var invalidLengthPrompt = '';

var maxDecimal = 0;
var maxDigits = 0;
var maxlength = 0;
var maxValue = 0;
var dateFormatString = "";
var f = document.forms[formName];

// default error msg style to IE
//var errorItemStart = "&nbsp;&nbsp;&nbsp;--";
var errorItemStart = "   --";
//var errorItemEnd = "<br>";
var errorItemEnd = "\n";
//var errorListStart = "<br>";
var errorListStart = "\n";
var errorListEnd = "";
var errorCategorySeparator = "";
// window.alert("In ValidationFunctions.js");
if(isNav)
{
	errorItemStart = '    - ';
	errorItemEnd = '\n';
	errorListStart = '\n';
	errorListEnd = '\n';
	errorCategorySeparator = "";
}
	var lastChecked = "";
	for (i=0; i<f.elements.length; i++)
	{
		ok = true;
		e = f.elements[i];
		var name = e.name;
//		window.alert("name = "+e.name);
//		if(e.type == 'select-multiple')	
//		{	
//			window.alert(e.type+"  "+e.name+" "+e.required);
//		}
		if (e.type == 'checkbox')
		{
// window.alert("In ValidationFunctions.js:Checkbox");
			if(lastChecked != name)
			{
				e = document.forms[0].elements[name]
				var len = e.length;
				if(isNaN(len)) len = 0;
				if(len>0)
				{
					e = document.forms[0].elements[name][0];
					if (e.required=='y')
					{
						var notChecked = true;
						for(z=0; z<document.forms[0].elements[name].length; z++)
						{
							if(document.forms[0].elements[name][z].checked == true) notChecked=false;
						}
						
						if(notChecked) 
						{
							prompt += errorItemStart+e.friendlyName+errorItemEnd;
							if (focusMe==null) focusMe=e;
							ok = false;
						}
					}
				}
			}
		}
		else if (e.type == 'radio')
		{
// window.alert("In ValidationFunctions.js:Radio");
// window.alert("name = "+e.name+" Friendly: "+e.friendlyName+" Req: "+e.required);

			if(lastChecked != name)
			{
				e = document.forms[0].elements[name]
				var len = e.length;
				if(isNaN(len)) len = 0;
				if(len>0)
				{
// window.alert("In ValidationFunctions.js:Radio: Length greater than zero");
					e = document.forms[0].elements[name][0];
// window.alert("e = "+ e.name);
	//				if (e.required=='y')
	//				{
// window.alert("In ValidationFunctions.js:Radio: Required ");
						var notChecked = true;
						for(z=0; z<document.forms[0].elements[name].length; z++)
						{
							if(document.forms[0].elements[name][z].checked == true) 
							{
								notChecked=false;
// window.alert("In ValidationFunctions.js:Radio: Notchecked set to false");
							}
						}
						
						if(notChecked) 
						{
// window.alert("In ValidationFunctions.js:Radio: Notchecked should be asking user");
							prompt += errorItemStart+name+errorItemEnd;
							if (focusMe==null) focusMe=e;
							ok = false;
						}
//					}
//window.alert("In ValidationFunctions.js:Radio: Decided it wasn't required");
				}
			}
		}
		else if (e.required=='y')
		{
// window.alert("In ValidationFunctions.js:Somewhere else");
// window.alert("name = "+e.name+" Friendly: "+e.friendlyName+" Req: "+e.required);
			if(e.type == 'select-one')
			{
				if ((e.selectedIndex == 0) && (e.allowFirst == 'n'))
				{
					prompt += errorItemStart+e.friendlyName+errorItemEnd;
					if (focusMe==null) focusMe=e;
					ok = false;
				}
			}
			else if(e.type == 'select-multiple')
			{
				var notSelected = true;
				for(y=0;y<e.size;y++)
				{
					if(e[y].selected) notSelected = false;		
				}
				if(notSelected)
				{
					prompt += errorItemStart+e.friendlyName+errorItemEnd;
					if (focusMe==null) focusMe=e;
					ok = false;
				}
			}
			else if((e.type == 'textarea') || (e.type == 'text') || (e.type == 'password'))
			{
				if(e.value.length == 0)
				{
					prompt += errorItemStart+e.friendlyName+errorItemEnd;
					if (focusMe==null) focusMe=e;
					ok = false;
				}
			}
		}
		
		if(ok)
		{
			//window.alert("Check Length of field.");
			if((e.type == 'textarea') || (e.type == 'text') || (e.type == 'password'))
			{
				//window.alert("Type = ."+e.type);
				//window.alert("my length."+e.value.length);
				//window.alert("max length."+e.maxLength);
				if(e.maxLength>0 && e.value.length>0)
				{
					if( e.maxLength < e.value.length)
					{
						invalidLengthPrompt += errorItemStart+e.friendlyName+" max("+e.maxLength+")"+errorItemEnd;
						if (focusMe==null) focusMe=e;
						ok = false;
					}
				}
			}
		}

		
		if(ok)
		{
			if(e.validNumber=='y' && e.value.length>0)
			{
				// Clear any commas entered by user
				e.value = cleanCommas(e.value);
				
				if(isNaN(e.value))
				{
					validNumberPrompt += errorItemStart+e.friendlyName+errorItemEnd;
					if (focusMe==null) focusMe=e;
					ok = false;
				}
				else
				{
					var checkOk;
					if(e.decimalAllowed=='y')
						checkOK = '0123456789-.';
					else
						checkOK = '0123456789-';

					checkStr = e.value;				
					for (x = 0;  x < checkStr.length;  x++)
					{
						ch = checkStr.charAt(x);
						for (j = 0;  j < checkOK.length;  j++)
						{
							if (ch == checkOK.charAt(j)) break;
						}
						if (j == checkOK.length)
						{
							validNumberPrompt += errorItemStart+e.friendlyName+errorItemEnd;
							if (focusMe==null) focusMe=e;
							ok = false;
						}
					}
				}
			}
		}

		if(ok)
		{
			if(e.positiveOnly=='y' && e.value.length>0)
			{
				if(e.zeroAllowed)
				{
					
					if(e.value<0)
					{
						positiveNumberPrompt += errorItemStart+e.friendlyName+errorItemEnd;
						if (focusMe==null) focusMe=e;
						ok = false;
					}
				}
				else
				{
					if(e.value<=0)
					{
						positiveNumberPrompt += errorItemStart+e.friendlyName+errorItemEnd;
						if (focusMe==null) focusMe=e;
						ok = false;
					}
				}
			}
		}

		if(ok)
		{
			if(e.maxDecimalPlaces>0)
			{
				decPos = -1;
				decPos = e.value.indexOf(".");
				if(decPos>=0)
				{
//					window.alert("decimal found at pos = "+decPos);
					newValue = e.value.substr(decPos+1);
//					window.alert(newValue);
					if(newValue.length > e.maxDecimalPlaces) 
					{
						maxDecimal = e.maxDecimalPlaces;
						invalidDecimalPrompt += errorItemStart+e.friendlyName+errorItemEnd;
						if (focusMe==null) focusMe=e;
						ok = false;
					}
				}
			}
		}

		if(ok)
		{
			if(e.maxDigits>0)
			{
				len = e.value.length;
//				window.alert("length = "+len);
				if(len>e.maxDigits)
				{
					maxDigits = e.maxDigits
					invalidNumberOfDigitsPrompt += errorItemStart+e.friendlyName+errorItemEnd;
					if (focusMe==null) focusMe=e;
					ok = false;
				}
			}
		}

		if(ok)
		{
			if(e.percentCheck=='y')
			{
				var total = 0;
				for(var z=0;z<= e.percentFields.length-1;z++)
				{
					var numb = eval("f.elements['"+e.percentFields[z]+"'].value");
					if(isNaN(numb)) numb = 0;
					total += Number(numb);
				}
				if(total != 100)
				{
					invalidPercentPrompt += "Total for "+e.percentFriendlyName+" must equal 100 percent, currently it equals "+total+" .";
					if (focusMe==null) focusMe=e;
					ok = false;
				}
			}
		}
		
		if(ok)
		{
//			window.alert("here2:"+e.name+":"+e.emailAddress);
			if((e.emailAddress=='y') && (e.value.length > 0))
			{
				var reEmailAddr = /^[\s]*[^ 	@,]+@([a-zA-Z0-9-]+\.)+[a-zA-Z0-9-]+[\s]*$/;
				//                 1111113333333333345555555555555555556666666666666777777
				/*
				English explanation of regExp:
				1. Can begin with white-space (ws).
				3. User portion must be 1 or more chars not including ws, @ and comma.
				4. Must have @ symbol here.
				5. any number of: one or more character strings (alpha-numeric and hyphen only) followed by a dot.
				8. Top-level domain. Must consist of one or more chars (alpha-numeric and hyphen only).
				9. Can end with ws.
				*/
				if (!reEmailAddr.test(e.value))
				{
					ok = false;
					invalidEmailPrompt += errorItemStart+e.friendlyName+errorItemEnd;
				}
			}
		}
		
		if(ok)
		{
			// window.alert("here2:"+e.name+":"+e.emailAddress);
			if(e.mustEqualField=='y')
			{
				var compareField = eval("f."+e.mustEqualFieldName);
				var compareValue = compareField.value;
				if (e.value != compareValue)
				{
					ok = false;
					if (e.mustEqualFieldMessage.length > 0)
					{
						equalFieldsPrompt += e.mustEqualFieldMessage+"\n\n";
					}
					else
					{
						equalFieldsPrompt += e.friendlyName + " is not equal to "+compareField.friendlyName+".  These two values must be equal.\n\n";
					}
				}
			}
		}
		if(ok)
		{
			if(e.minimumLength > 0)
			{
				if(e.minimumLength > e.value.length)
				{
					equalFieldsPrompt += e.friendlyName + " must be at least " + e.minimumLength + " characters long.\n\n";
				}
			}
		}
		if(ok)
		{
			//Check for valid dates if the field is not empty.
			if(e.validDate=='y' && getFieldValue(e).length>0)
			{
				if (isNaN(e.dateFormat))
					e.dateFormat = 1;
				switch (e.dateFormat)
				{
					case 1:
						dateFormatString = "mm/dd/yyyy";	//For display in error message only (not used in actual validation)
						//Trust me, this regular expression checks for mm/dd/yyyy format.
						//spaces before and after ok (but not in middle). The RegExp doesn't 
						//know if it's a valid date, though (only checks format).
						var reMMDDYYY = /^\s*(\d{1,2})\/(\d{1,2})\/(\d{4})\s*$/;
						if (reMMDDYYY.test(e.value))
						{
							//Get the month, day, and year substrings.
							var month = RegExp.$1;
							var day = RegExp.$2;
							var year = RegExp.$3;
							
							//Check to make sure they compose a valid date.
							if (isDate(month,day,year))
							{
								//alert("date Ok");
							}
							else
							{
								ok = false;
								invalidDatePrompt += errorItemStart+e.friendlyName+errorItemEnd;
							}
						}
						else
						{
							ok = false;
							invalidDatePrompt += errorItemStart+e.friendlyName+errorItemEnd;
						}
					break;
					
					case 2:
						dateFormatString = "";	//For display in error message only (not used in actual validation)
					
						//var month = eval("f." + e.monthFieldName + ".value");
						//var day = eval("f." + e.dayFieldName + ".value");
						//var year = eval("f." + e.yearFieldName + ".value");
						var month = getSelectValue(eval("f." + e.monthFieldName));
						var day = getSelectValue(eval("f." + e.dayFieldName));
						var year = getSelectValue(eval("f." + e.yearFieldName));

						//Check to make sure they compose a valid date.
						if (isDate(month,day,year))
						{
							// window.alert("date Ok");
						}
						else
						{
							ok = false;
							invalidDatePrompt += errorItemStart+e.friendlyName+errorItemEnd;
						}
					case 3:
						dateFormatString = "";	//For display in error message only (not used in actual validation)
					
						var month = eval("f." + e.monthFieldName + ".value");
						var day = eval("f." + e.dayFieldName + ".value");
						var year = eval("f." + e.yearFieldName + ".value");

						//Check to make sure they compose a valid date.
						if (isDate(month,day,year))
						{
							// window.alert("This is a Valid Date=" + month + "/" + day + "/" + year);
						}
						else
						{
							// window.alert("This is an inValid Date=" + month + "/" + day + "/" + year);
							ok = false;
							invalidDatePrompt += errorItemStart+e.friendlyName+errorItemEnd;
						}
				}
			}
		}
		if(ok)
		{
			if(e.maxValue>0)
			{				
//				window.alert("length = "+len);
				if(e.value>e.maxValue)
				{
					maxValue = e.maxValue
					numberTooLargePrompt += errorItemStart+e.friendlyName+" (must not exceed "+maxValue+")"+errorItemEnd;
					if (focusMe==null) focusMe=e;
					ok = false;
				}
			}
		}
		if(ok)
		{
			if(e.minValue>0 || e.minValue==0)
			{				
//				window.alert("e.value = "+e.value);
				if(e.value<e.minValue)
				{
					minValue = e.minValue
					numberTooSmallPrompt += errorItemStart+e.friendlyName+" (must not be less than "+minValue+")"+errorItemEnd;
					if (focusMe==null) focusMe=e;
					ok = false;
				}
			}
		}

		lastChecked = name;
		
		// If there is an error with this element, see if we should highlight the label
/*
		if(!ok)
		{
			highlightElement(e);
		}
		else
		{
			unhighlightElement(e);
		}
*/	
	}


	var msg = '';
	if (prompt.length > 0) 
	{
		if (msg.length > 0) msg += errorCategorySeparator;
		msg = ('The following fields were missed:'+errorListStart+prompt+errorListEnd);
	}

	if(validNumberPrompt.length > 0) 
	{
		if (msg.length > 0) msg += errorCategorySeparator;
		msg += ('The following fields were invalid numbers:'+errorListStart+validNumberPrompt+errorListEnd);
		valid = false;
	}

	if(positiveNumberPrompt.length > 0) 
	{
		if (msg.length > 0) msg += errorCategorySeparator;
		msg += ('The following fields need to be positive numbers:'+errorListStart+positiveNumberPrompt+errorListEnd);
		valid = false;
	}

	if(invalidDecimalPrompt.length > 0) 
	{
		if (msg.length > 0) msg += errorCategorySeparator;
		msg += ('The following numbers have an invalid number of decimal places, maximum allowed is '+maxDecimal+':'+errorListStart+invalidDecimalPrompt+errorListEnd);
		valid = false;
	}

	if(invalidNumberOfDigitsPrompt.length > 0) 
	{
		if (msg.length > 0) msg += errorCategorySeparator;
		msg += ('The following numbers are too large, the maximum number of digits allowed is '+maxDigits+':'+errorListStart+invalidNumberOfDigitsPrompt+errorListEnd);
		valid = false;
	}

	if(invalidPercentPrompt.length > 0) 
	{
		if (msg.length > 0) msg += errorCategorySeparator;
		msg += (invalidPercentPrompt+errorListEnd);
		valid = false;
	}	
	

	if(invalidEmailPrompt.length > 0) 
	{
		if (msg.length > 0) msg += errorCategorySeparator;
		msg += ('The following fields contain an invalid email address.  They must be in the format abc@xyz.com :'+errorListStart+invalidEmailPrompt+errorListEnd);
		valid = false;
	}
	
	if(equalFieldsPrompt.length > 0) 
	{
		if (msg.length > 0) msg += errorCategorySeparator;
		msg += equalFieldsPrompt;
		valid = false;
	}
	

	if(numberTooLargePrompt.length > 0) 
	{
		if (msg.length > 0) msg += errorCategorySeparator;
		msg += ('The following numbers are too large:'+errorListStart+numberTooLargePrompt+errorListEnd);
		valid = false;
	}

	if(numberTooSmallPrompt.length > 0) 
	{
		if (msg.length > 0) msg += errorCategorySeparator;
		msg += ('The following numbers are too small:'+errorListStart+numberTooSmallPrompt+errorListEnd);
		valid = false;
	}

	if(invalidDatePrompt.length > 0) 
	{
		if (msg.length > 0) msg += errorCategorySeparator;
		if (dateFormatString.length > 0)
			dfs = ' (must be a valid date in format '+dateFormatString+')';
		else
			dfs = '';
		msg += ('The following dates are invalid' + dfs + ':'+errorListStart+invalidDatePrompt+errorListEnd);
		valid = false;
	}
	
	if(invalidLengthPrompt.length > 0) 
	{
		if (msg.length > 0) msg += errorCategorySeparator;
		msg += ('The following fields of data are too long:'+errorListStart+invalidLengthPrompt+errorListEnd);
		valid = false;
	}


	if(msg.length > 0)
	{
		msg += ('\nPlease correct the errors and re-submit.');
		if (focusMe != null) focusMe.focus();
//		window.alert(msg);
//		return false;
	}

//	return true;
	return msg;
}

function checkDate(month, date, year) 
{ 
//	window.alert("date = "+date+" Month = "+month);
	var err=0; 
	if (month == "2")
	{ 
		if((year/4)!=parseInt(year/4)) 
		{ 
			if((date=="29") || (date=="30") || (date=="31")) { return false; }
			else { return true;}
		} 
		else 
		{ 
			if((date=="30") || (date=="31")) { return false; }
			else { return true;}
		} 
	} 
	
	if (month == "4")
	{ 
		if(date=="31") { return false; }
		else { return true;}
	} 

	if (month == "6")
	{ 
		if(date=="31") { return false; }
		else { return true;}
	} 
	
	if (month == "9")
	{ 
		if(date=="31") { return false; }
		else { return true;}
	} 

	if (month == "11")
	{ 
		if(date=="31") { return false; }
		else { return true;}
	} 

	return true;
} 

function ToFmt(x){
 this.x=x;
 this.fmt00 = fmt00;
 this.fmtF = fmtF;
 this.fmtE=fmtE;
 this.fmtI=fmtI;
 this.spacer="";
 this.setSpacer=setSpacer;
}

function fmt00(){
 if (parseInt(this.x) < 0) var neg = true;
 if (Math.abs(parseInt(this.x)) < 10){
  this.x = "0"+ Math.abs(this.x);
 }
 if (neg) this.x = "-"+this.x;
 return this.x;
}

function fmtF(w,d){
 var width=w;
 var dpls=d;
 var lt1=false;
 var len=this.x.toString().length;
 var junk;
 var res="";
// First check for valid format request
 if ( width < (dpls+2)){
  window.alert("Illegal format specified : w = " + d +
               " w = " + d +
                "\nUsage: [ToFmt].fmtF(w,d)" +
                "\nWidth (w) of field must be " +
                "greater or equal to the number " +
                "\nof digits to the right of the decimal point (d) + 2");
  junk = filljunk(width);
  return junk;
 }
// Work with absolute value
 var absx=Math.abs(this.x);
// Nasty fix to deal with numbers < 1 and problems with leading zeros!
 if ((absx < 1) && (absx > 0)){
  lt1 = true;
  absx+=10;
 }
// Get postion of decimal point
 var pt_pos = absx.toString().indexOf(".");
 if ( pt_pos == -1){
  res+= absx;
  res+= ".";
  for (var i = 0; i < dpls; i++){
   res += 0;
  }  
 }
 else{
  res = Math.round(absx * Math.pow(10,dpls));
  res=res.toString();
  if (res.length == 
      Math.round(Math.floor(absx * Math.pow(10,dpls))).toString().length){ 
   res = res.substring(0,pt_pos) + "." + 
         res.substring(pt_pos,res.length);
  }
  else{
   pt_pos++;
   res = res.substring(0,pt_pos) + "." + 
          res.substring(pt_pos,res.length);
  } 
// Remove leading 1 from  numbers < 1 (Nasty fix!)
  if (lt1) {
   res=res.substring(1,res.length);
  }
 }
 // Final formatting statements
 // Reinsert - sign for negative numbers
 if (this.x < 0)res = "-"+res;
 // Check whether the result fits in the width of the field specified
 if (res.length > width){
  res=filljunk(width);
 }
 // If necessary, pad from the left with the spacer string
 else if (res.length < width){
  var res_bl="";
  for (var i = 0; i < (width - res.length); i++){
   res_bl += this.spacer ;
  } 
  res = res_bl + res;
 }
 return res;
}

function fmtE(w,d){
 var width=w;
 var dpls=d;
 var e="E+";
 var len=this.x.toString().length;
 var pow10;
 var xp10;
 var junk;
 var res="";
// First check for valid format request
 if ( width < (dpls+5)){
  window.alert("Illegal format specified : w = " + d +
               " w = " + d +
                "\nUsage: [ToFmt].fmtE(w,d)" +
                "\nWidth (w) of field must be " +
                "greater or equal to the number " +
                "\nof digits to the right of the decimal point (d) + 6");
  junk = filljunk(w);
  return junk;
 }
// Work with absolute value
 var absx=Math.abs(this.x);
// Get postion of decimal point
 var pt_pos = absx.toString().indexOf(".");
// For x=0
 if (absx == 0){
  res +="0.";
  for (var i=0; i< dpls; i++){
   res += "0";
  }
  res  += "E+00";
 }
// For abs(x) >= 1 
 else if (absx >= 1.0){
  pow10=1;
  xp10 = absx;
  while (xp10 >= 1.){
   pow10++;
   xp10 /= 10;
  }
  res = Math.round(xp10 * Math.pow(10,dpls));
  res=res.toString();
  if (res.length == 
      Math.round(Math.floor(xp10 * Math.pow(10,dpls))).toString().length){ 
    pow10--;
  }
  res = "0." + res.substring(0,dpls) + e + (new ToFmt(pow10)).fmt00();
 }
// For abs(x) < 1
 else if (absx < 1.0){
  pow10=1;
  xp10 = absx;
  while (xp10 < 1.){
   pow10--;
   xp10 *= 10;
  }
  res = Math.round(xp10/10 * Math.pow(10,dpls));
  res=res.toString();
  if (res.length != 
      Math.round(Math.floor(xp10/10 * 
Math.pow(10,dpls))).toString().length){ 
    pow10++;
  }
  if (pow10 < 0) e = "E-";
  res = "0." + res.substring(0,dpls) + e + (new 
ToFmt(Math.abs(pow10))).fmt00();
 }
 
 if (this.x < 0)res = "-"+res;
 if (res.length > width){
  res=filljunk(width);
 }
 else if (res.length < width){
  var res_bl="";
  for (var i = 0; i < (width - res.length); i++){
   res_bl += this.spacer ;
  } 
  res = res_bl + res;
 }
 return res;
 
}

function fmtI(w){
 var width=w;
 var lt0=false;
 var len=this.x.toString().length;
 var junk;
 var res="";
// Work with absolute value
 var absx = Math.abs(this.x);

// Test for < 0
 if (parseInt(this.x) < 0){
  lt0 = true;
 }
 res = Math.round(Math.floor((absx))).toString();
 if (lt0){
  res = "-"+res;
 }
 if (res.length > width){
  res=filljunk(width);
 }
 else if (res.length < width){
  var res_bl="";
  for (var i = 0; i < (width - res.length); i++){
   res_bl += this.spacer ;
  } 
  res = res_bl + res;
 }
 return res;
}

function filljunk(lenf)
{
	// Fills field of length lenf with asterisks
	var str="";
	for (var i=0; i < lenf; i++)
		str +="*";

	return str;
}

function setSpacer(spc)
{
 var spc;
 this.spacer=spc;
 return this.spacer;
}

function cleanCommas(v)
{
	var a = v.split(',');
	return a.join('');
}

function prompt(msg) 
{
	window.status = msg 
}

function changeClass(elementId, newClass)
{
	//alert("changeClass:elementId="+elementId+",class="+newClass)
	eval(elementId).className = newClass;
}

function getPageLeft(obj, offset)
{
	//return obj.pageX + offset;
	return 0;
}

function getPageTop(obj, offset)
{
	//return obj.pageY + offset;
	return 0;
}

function getElem(form, id)
{
	e = form.elements[id];
	if (e != null)
	{
		e.normalId =  id+'0';
		e.errorId = id+'1';
		setPosition(e.normalId, e.errorId, 0, 0);
	}
	
	return e;
}

function openErrorWindow(formIndex)
{
	var errorMsg = document.forms[formIndex].errorText.value;
	//alert(errorMsg);
	window.open("formError.asp?msg="+escape(errorMsg), 'ciqErrorWin','width=650,height=250,scrollbars=yes,status=no,toolbar=no,menubar=0,address=0,resizable=yes')
	
	//return false;
}

//Takes strings, returns boolean.
function isDate(month, day, year)
{
	//alert("isDate:day:"+day+" month:"+month+" year:"+year);
	
	//parse each string into a number. Return false if any is not a number
	intMonth = parseInt(month,10);
	if (isNaN(intMonth)) return false;
	intDay = parseInt(day,10);
	if (isNaN(intDay)) return false;
	intYear = parseInt(year,10);
	if (isNaN(intYear)) return false;
	
	//alert("isDate:10");
	
	//make sure the year is in a reasonable range.
	if (intYear<1900 || intYear>2099) return false;
	//make sure month is in possible range.
	if (intMonth<1 || intMonth>12) return false;
	//make sure day is within that month's range (needs year to check 2/29).
	if (!dayInMonth(intDay, intMonth, intYear)) return false;
	
	//If all the above tests passed, it's a valid date.
	return true;
}

//Takes ints only, returns boolean
function dayInMonth(day, month, year)
{
	var maxDays;
	//alert("dayinmonth:day:"+day+" month:"+month+" year:"+year);
	switch (month)
	{
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			//Months with 31 days.
			//alert ("31"+(day>=1 && day<=31));
			maxDays=31;
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			//Months with 30 days.
			//alert ("30"+(day>=1 && day<=31));
			maxDays=30;
			break;
		case 2:
			//February.
			//alert ("28/29"+(day>=1 && day<=31));
			//for efficiency, let's only call leap year stuff if it's the 29th.
			if (day==29)
				maxDays = febDays(year);
			else
				maxDays = 28;
			break;
		default :
			//Not a valid month...
			//alert ("default");
			return false;
	}
	return (day>=1 && day<=maxDays);
}

//Takes an int only in year, returns boolean.
function isLeapYear(year)
{
	//Divisible by 4?
	if ((year%4)==0)
	{
		//Yes. Divisible by 100?
		if ((year%100)==0)
		{
			//Yes. Devisible by 400?
			if ((year%400)==0)
			{
				//Yes, leap year. (e.g., 2000)
				return true;
			}
			else
			{
				//by 400?: No, not leap year (e.g., 1900)
				return false;
			}
		}
		else
		{
			//by 100? No, leap year (e.g., 2004)
			return true;
		}
	}
	else
	{
		//By 4?: No, not leap year (e.g., 2001)
		return false;
	}
}
//Takes an int only in year, returns int.
function febDays(year)
{
	if (isLeapYear(year))
		return 29;
	else
		return 28;
}
//Takes a radio object, returns String or null
function radioValue(radio)
{
	for (var i=0; i<radio.length; i++)
	{
		if (radio[i].checked)
			return radio[i].value;
	}
	return null;
}
//Takes select object, string, boolean
function setSelectValue(field, value, numeric)
{
	var test = "";
	if (numeric)
		test = "parseInt(field.options[i].value,10) == parseInt(value,10)";
	else
		test = "field.options[i].value == value";
	for (var i = 0; i < field.length; i++)
	{
		if (eval(test))
		{
			field.selectedIndex = i;
			break;
		}
	}
}
function getSelectValue(field)
{
	return field.options[field.selectedIndex].value;
}

function getFieldValue(field)
{
	switch (field.type)
	{
		case "hidden":
		case "text":
		case "textarea":
		case "password":
			return field.value;
			break;
		case "select-one":
			return getSelectValue(field);
			break;
		case "select-multiple":
			return getSelectValues(field);	//Not implemented yet.
			break;
		case "checkbox":
			return field.checked?field.value:"";
			break;
		case "radio":
			return getRadioValue(field);	//Not implemented yet.
			break;
	}
}

function clearForm(form)
{
	var f = form;
	for(var i=0; i<f.length; i++)
	{
		var field = f.elements[i];
		switch (field.type)
		{
			case "hidden":
				break;
			case "text":
			case "textarea":
			case "password":
				field.value = "";
				break;
			case "select-one":
				field.options[0].selected = true;
				break;
			case "select-multiple":
				//alert("skipping select multiple");
				clearSelectMultiple(field);
				break;
			case "checkbox":
				field.checked = false;
				break;
			case "radio":
				field.checked = false;
				break;
		}
	}
}

function clearSelectMultiple(field)
{
	//In netscape, this does not totally clear it.  The first one is still selected.
	field.selectedIndex = 0;
	field.options[0].selected = false;
	/* 
	//This was causing problems for me in Netscape for some reason. (dae)
	//In fact, it wasn't giving me a javascript error, it was actually crashing
	//the browser.
	for (var i = 0; i < field.length; i++)
	{
		alert("i="+i);
		alert("i="+i+". selected before = "+field.options[i].selected);
		field.options[i].selected = false;
		alert("i="+i+". selected after = "+field.options[i].selected);
	}
	*/
	
}

function clearRadio(field)
{
	for (var i = 0; i < field.length; i++)
	{
		if (field[i].checked)
		{
			field[i].checked = false;
			break;
		}
	}
}

function focusFirst()
{
	if (document.forms.length > 0) 
	{
		var f = document.forms[0];
		
		for(var i=0; i<f.length; i++)
		{
			var e = document.forms[0].elements[i];
	//		window.alert(e.type);
			if((e.type == 'select-one') || (e.type == 'text') || (e.type == 'password') || (e.type == 'textarea') || (e.type == 'select-multiple') || (e.type == 'checkbox') || (e.type == 'radio'))
			{
				e.focus();
				break;
			}
		}
	}
}
//-->
