<!--

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)

{

	return validateRequired(formName, true);

}



function validateRequired(formName, onlyValidation)

{

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 invalidAlphaNumPrompt = '';

var invalidMinNumberOfDigitsPrompt = '';

var invalidPercentPrompt = '';

var numberTooLargePrompt = '';

var numberTooSmallPrompt = '';

var maxDecimal = 0;

var maxDigits = 0;

var minDigits = 0;

var maxValue = 0;

var dateFormatString = "";

var f = document.forms[formName];

var len = 0;

var notChecked = true;



// 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 = "";



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')

		{

			if(lastChecked != name)

			{

//cls not needed?				e = document.forms[0].elements[name]

				len = e.length;

				if(isNaN(len)) len = 0;

				if(len>0)

				{

					e = document.forms[0].elements[name][0];

					if (e.required=='y')

					{



						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')

		{

			notChecked = true;

			if(lastChecked != name)

			{

//cls not needed?				e = document.forms[0].elements[name]

				len = e.length;

				if(isNaN(len)) len = 0;

				if(len>0)

				{

					e = document.forms[0].elements[name][0];

					if (e.required=='y')

					{

						//alert(notChecked);

						for(z=0; z<document.forms[0].elements[name].length; z++)

						{

							if(document.forms[0].elements[name][z].checked == true) notChecked=false;

						}

						//alert(notChecked);

						if(notChecked) 

						{

							prompt += errorItemStart+e.friendlyName+errorItemEnd;

							if (focusMe==null) focusMe=e;

							ok = false;

						}

					}

				}

			}

		}

		else if (e.required=='y')

		{

			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') || (e.type == 'hidden'))

			{

				if( (e.value.length == 0) || ((e.spaceAllowed=='n') && (trim(e.value)==0)) )

				{

					prompt += errorItemStart+e.friendlyName+errorItemEnd;

					if( (focusMe==null) && (e.type != 'hidden') ) 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.minDecimalPlaces>0) && (e.value.length>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.minDecimalPlaces) 

					{

						minDecimal = e.minDecimalPlaces;

						invalidDecimalPrompt += errorItemStart+e.friendlyName+errorItemEnd;

						if (focusMe==null) focusMe=e;

						ok = false;

					}

				}

				else

				{

					minDecimal = e.minDecimalPlaces;

					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.minDigits>0) && (e.value.length>0))

			{

				len = e.value.length;

//				window.alert("length = "+len);

				if(len<e.minDigits)

				{

					minDigits = e.minDigits

					invalidMinNumberOfDigitsPrompt += 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)

		{

//			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)

		{

			//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.alphanum=='y' && getFieldValue(e).length>0)

			{

				if(!alphanumeric(e.value))

				{

					invalidAlphaNumPrompt += errorItemStart+e.friendlyName+errorItemEnd;

					if (focusMe==null) focusMe=e;

					ok = false;

				}

			}

		}

		

		if(ok)

		{

			//Check for valid dates if the field is not empty.

			if(e.validDate=='y' && getFieldValue(e).length>0)

			{

				var month;

				var day;

				var year;

				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.

							month = RegExp.$1;

							day = RegExp.$2;

							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)

					

						month = eval("f." + e.monthFieldName + ".value");

						day = eval("f." + e.dayFieldName + ".value");

						year = eval("f." + e.yearFieldName + ".value");



						//Check to make sure they compose a valid date.

						if (isDate(month,day,year))

						{

							// alert("This is a Valid Date=" + month + "/" + day + "/" + year);

						}

						else

						{

							// alert("This is an inValid Date=" + month + "/" + day + "/" + year);

							ok = false;

							invalidDatePrompt += errorItemStart+e.friendlyName+errorItemEnd;

						}

						break;

					case 3:

						dateFormatString = "";	//For display in error message only (not used in actual validation)

					

						month = eval("f." + e.monthFieldName + ".value");

						day = eval("f." + e.dayFieldName + ".value");

						year = eval("f." + e.yearFieldName + ".value");



						//Check to make sure they compose a valid date.

						if (isDate(month,day,year))

						{

							// alert("This is a Valid Date=" + month + "/" + day + "/" + year);

						}

						else

						{

							// alert("This is an inValid Date=" + month + "/" + day + "/" + year);

							ok = false;

							invalidDatePrompt += errorItemStart+e.friendlyName+errorItemEnd;

						}

						break;

				}

			}

		}

		if(ok)

		{

			if((e.maxValue>0) && (e.value.length>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) && (e.value.length>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(invalidAlphaNumPrompt.length > 0) 

	{

		if (msg.length > 0) msg += errorCategorySeparator;

		msg += ('The following field(s) should contain only numbers and letters with no spaces :'+errorListStart+invalidAlphaNumPrompt+errorListEnd);

		valid = false;

	}

	

	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(invalidMinNumberOfDigitsPrompt.length > 0) 

	{

		if (msg.length > 0) msg += errorCategorySeparator;

		msg += ('The following numbers are too small, the minimum number of digits allowed is '+minDigits+':'+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(msg.length > 0)

	{

		if(onlyValidation)

		{

			msg += ('Please correct the errors and re-submit.');

		}

		if (focusMe != null) focusMe.focus();

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

} 



/*

ToFmt object

Constructor Example



 var a = new ToFmt(x);



where x is a numerical variable or number.

Methods



fmt00()

    Tags leading zero onto integers 0 - 9. Particularly useful for displaying results from methods of the Date object. 

fmtF(w,d):

    Formats in a style similar to Fortran's Fw.d, where w is the width of the field and d is the number of figures after the decimal point. The result is rounded either up or down to be correct to the number of digits requested. The result is aligned to the right of the field. The default padding character is a space " ". This can be modified using the setSpacer(string) method of ToFmt. If the result will not fit in the field , the field will be returned containing w asterisks. 

fmtE(w,d)

    Formats in a style similar to Fortran's Ew.d, where w is the width of the field and d is the number of figures after the decimal point. The result is rounded either up or down to be correct to the number of digits requested. The result is aligned to the right of the field. The default padding character is a space " ". This can be modified using the setSpacer(string) method of ToFmt. If the result will not fit in the field , the field will be returned containing w asterisks. 

fmtI(w)

    Formats in a style similar to Fortran's Iw, where w is the width of the field. Floating point values are truncated (rounded down) for integer representation. The result is aligned to the right of the field. The default padding character is a space " ". This can be modified using the setSpacer(string) method of ToFmt. If the result will not fit in the field , the field will be returned containing w asterisks. 

setSpacer(string)

    Method enables the space padding character to be set. The default is set for a blank space, which would be lost in standard HTML. You may wish to try "&nbsp;" as the spacer character in your HTML output. This will not allow for column alignment unless you use a fixed width font, but will otherwise let your numbers breathe a bit. 

    

Ex:

	var a = new ToFmt(document.fm1.fta1.value);

    document.fm1.fta2.value=a.fmt00();

    document.fm2.fta2.value=a.fmtF(13,5);

    document.fm2.fta3.value=a.fmtE(13,6);

    document.fm2.fta4.value=a.fmtI(6);

*/

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 ix = 0; ix < (width - res.length); ix++){

   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 ix = 0; ix < (width - res.length); ix++){

   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)

{

	var result = "";

	switch (field.type)

	{

		case "hidden":

		case "text":

		case "textarea":

		case "password":

			result = field.value;

			break;

		case "select-one":

			result = getSelectValue(field);

			break;

		case "select-multiple":

			result = getSelectValues(field);	//Not implemented yet.

			break;

		case "checkbox":

			result = field.checked?field.value:"";

			break;

		case "radio":

			result = getRadioValue(field);	//Not implemented yet.

			break;

	}

	return result;

}



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;

			}

		}

	}

}



function ltrim ( s )

{

	return s.replace( /^\s*/, "" )

}



function rtrim ( s )

{

	return s.replace( /\s*$/, "" );

}



function trim ( s )

{

	return rtrim(ltrim(s));

}



/**

*	Calculate the delta between passed in dates

**/

function computeBizDelta(date1, date2) 

{

//  var date1 = new Date();

//    date1.setYear  (document.exf1.y1.value);

//	  date1.setMonth (document.exf1.m1.value);

//	  date1.setDate  (document.exf1.d1.value);



//  var date2 = new Date();

//    date2.setYear  (document.exf1.y2.value);

//	  date2.setMonth (document.exf1.m2.value);

//	  date2.setDate  (document.exf1.d2.value);



  var delta = date1.getTime() - date2.getTime();



      delta = delta / ( 1000 * 60 * 60 * 24 );  // units are now days.

      if (delta < 0) delta = -delta;

	  delta = Math.round(delta);

	  

  var bizdelta = ((parseInt(delta) / 7) * 5) + (parseInt(delta)%7);

      bizdelta = Math.round(bizdelta);

	  

//  document.exf1.delta.value = delta;

//  document.exf1.bizdelta.value=bizdelta;

	return bizdelta;

}



// ===================================================================

// Author: Matt Kruse <matt@mattkruse.com>

// WWW: http://www.mattkruse.com/

//

// NOTICE: You may use this code for any purpose, commercial or

// private, without any further permission from the author. You may

// remove this notice from your final code if you wish, however it is

// appreciated by the author if at least my web site address is kept.

//

// You may *NOT* re-distribute this code in any way except through its

// use. That means, you can include it in your product, or your web

// site, or any other form where the code is actually being used. You

// may not put the plain javascript up on your site for download or

// include it in your javascript libraries for download. 

// If you wish to share this code with others, please just point them

// to the URL instead.

// Please DO NOT link directly to my .js files from your site. Copy

// the files to your server and use them there. Thank you.

// ===================================================================



// HISTORY

// ------------------------------------------------------------------

// May 17, 2003: Fixed bug in parseDate() for dates <1970

// March 11, 2003: Added parseDate() function

// March 11, 2003: Added "NNN" formatting option. Doesn't match up

//                 perfectly with SimpleDateFormat formats, but 

//                 backwards-compatability was required.



// ------------------------------------------------------------------

// These functions use the same 'format' strings as the 

// java.text.SimpleDateFormat class, with minor exceptions.

// The format string consists of the following abbreviations:

// 

// Field        | Full Form          | Short Form

// -------------+--------------------+-----------------------

// Year         | yyyy (4 digits)    | yy (2 digits), y (2 or 4 digits)

// Month        | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)

//              | NNN (abbr.)        |

// Day of Month | dd (2 digits)      | d (1 or 2 digits)

// Day of Week  | EE (name)          | E (abbr)

// Hour (1-12)  | hh (2 digits)      | h (1 or 2 digits)

// Hour (0-23)  | HH (2 digits)      | H (1 or 2 digits)

// Hour (0-11)  | KK (2 digits)      | K (1 or 2 digits)

// Hour (1-24)  | kk (2 digits)      | k (1 or 2 digits)

// Minute       | mm (2 digits)      | m (1 or 2 digits)

// Second       | ss (2 digits)      | s (1 or 2 digits)

// AM/PM        | a                  |

//

// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!

// Examples:

//  "MMM d, y" matches: January 01, 2000

//                      Dec 1, 1900

//                      Nov 20, 00

//  "M/d/yy"   matches: 01/20/00

//                      9/2/00

//  "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"

// ------------------------------------------------------------------



var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');

var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');

function LZ(x) {return(x<0||x>9?"":"0")+x}



// ------------------------------------------------------------------

// isDate2 ( date_string, format_string )

// Returns true if date string matches format of format string and

// is a valid date. Else returns false.

// It is recommended that you trim whitespace around the value before

// passing it to this function, as whitespace is NOT ignored!

// ------------------------------------------------------------------

function isDate2(val,format) {

	var date=getDateFromFormat(val,format);

	if (date==0) { return false; }

	return true;

	}



// -------------------------------------------------------------------

// compareDates(date1,date1format,date2,date2format)

//   Compare two date strings to see which is greater.

//   Returns:

//   1 if date1 is greater than date2

//   0 if date2 is greater than date1 of if they are the same

//  -1 if either of the dates is in an invalid format

// -------------------------------------------------------------------

function compareDateStrings(date1,dateformat1,date2,dateformat2) {

	var d1=getDateFromFormat(date1,dateformat1);

	var d2=getDateFromFormat(date2,dateformat2);

	//alert(d1);

	//alert(d2);

	if (d1==0 || d2==0) {

		return -1;

		}

	else if (d1 > d2) {

		return 1;

		}

	return 0;

	}



// -------------------------------------------------------------------

// compareDates(date1,date2)

//   Compare two valid dates to see which is greater.

//   Returns:

//   1 if date1 is greater than date2

//   0 if date2 is greater than date1 of if they are the same

// -------------------------------------------------------------------	

function compareDates(date1,date2) {

	if (date1.getTime() > date2.getTime()) {

		return 1;

		}

	return 0;

	}





// ------------------------------------------------------------------

// formatDate (date_object, format)

// Returns a date in the output format specified.

// The format string uses the same abbreviations as in getDateFromFormat()

// ------------------------------------------------------------------

function formatDate(date,format) {

	format=format+"";

	var result="";

	var i_format=0;

	var c="";

	var token="";

	var y=date.getYear()+"";

	var M=date.getMonth()+1;

	var d=date.getDate();

	var E=date.getDay();

	var H=date.getHours();

	var m=date.getMinutes();

	var s=date.getSeconds();

	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;

	// Convert real date parts into formatted versions

	var value=new Object();

	if (y.length < 4) {y=""+(y-0+1900);}

	value["y"]=""+y;

	value["yyyy"]=y;

	value["yy"]=y.substring(2,4);

	value["M"]=M;

	value["MM"]=LZ(M);

	value["MMM"]=MONTH_NAMES[M-1];

	value["NNN"]=MONTH_NAMES[M+11];

	value["d"]=d;

	value["dd"]=LZ(d);

	value["E"]=DAY_NAMES[E+7];

	value["EE"]=DAY_NAMES[E];

	value["H"]=H;

	value["HH"]=LZ(H);

	if (H==0){value["h"]=12;}

	else if (H>12){value["h"]=H-12;}

	else {value["h"]=H;}

	value["hh"]=LZ(value["h"]);

	if (H>11){value["K"]=H-12;} else {value["K"]=H;}

	value["k"]=H+1;

	value["KK"]=LZ(value["K"]);

	value["kk"]=LZ(value["k"]);

	if (H > 11) { value["a"]="PM"; }

	else { value["a"]="AM"; }

	value["m"]=m;

	value["mm"]=LZ(m);

	value["s"]=s;

	value["ss"]=LZ(s);

	while (i_format < format.length) {

		c=format.charAt(i_format);

		token="";

		while ((format.charAt(i_format)==c) && (i_format < format.length)) {

			token += format.charAt(i_format++);

			}

		if (value[token] != null) { result=result + value[token]; }

		else { result=result + token; }

		}

	return result;

	}

	

// ------------------------------------------------------------------

// Utility functions for parsing in getDateFromFormat()

// ------------------------------------------------------------------

function _isInteger(val) {

	var digits="1234567890";

	for (var i=0; i < val.length; i++) {

		if (digits.indexOf(val.charAt(i))==-1) { return false; }

		}

	return true;

	}

function _getInt(str,i,minlength,maxlength) {

	for (var x=maxlength; x>=minlength; x--) {

		var token=str.substring(i,i+x);

		if (token.length < minlength) { return null; }

		if (_isInteger(token)) { return token; }

		}

	return null;

	}

	

// ------------------------------------------------------------------

// getDateFromFormat( date_string , format_string )

//

// This function takes a date string and a format string. It matches

// If the date string matches the format string, it returns the 

// getTime() of the date. If it does not match, it returns 0.

// ------------------------------------------------------------------

function getDateFromFormat(val,format) {

	val=val+"";

	format=format+"";

	var i_val=0;

	var i_format=0;

	var c="";

	var token="";

	var token2="";

	var x,y;

	var now=new Date();

	var year=now.getYear();

	var month=now.getMonth()+1;

	var date=1;

	var hh=now.getHours();

	var mm=now.getMinutes();

	var ss=now.getSeconds();

	var ampm="";

	

	while (i_format < format.length) {

		// Get next token from format string

		c=format.charAt(i_format);

		token="";

		while ((format.charAt(i_format)==c) && (i_format < format.length)) {

			token += format.charAt(i_format++);

			}

		// Extract contents of value based on format token

		if (token=="yyyy" || token=="yy" || token=="y") {

			if (token=="yyyy") { x=4;y=4; }

			if (token=="yy")   { x=2;y=2; }

			if (token=="y")    { x=2;y=4; }

			year=_getInt(val,i_val,x,y);

			if (year==null) { return 0; }

			i_val += year.length;

			if (year.length==2) {

				if (year > 70) { year=1900+(year-0); }

				else { year=2000+(year-0); }

				}

			}

		else if (token=="MMM"||token=="NNN"){

			month=0;

			for (var i=0; i<MONTH_NAMES.length; i++) {

				var month_name=MONTH_NAMES[i];

				if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {

					if (token=="MMM"||(token=="NNN"&&i>11)) {

						month=i+1;

						if (month>12) { month -= 12; }

						i_val += month_name.length;

						break;

						}

					}

				}

			if ((month < 1)||(month>12)){return 0;}

			}

		else if (token=="EE"||token=="E"){

			for (var i=0; i<DAY_NAMES.length; i++) {

				var day_name=DAY_NAMES[i];

				if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {

					i_val += day_name.length;

					break;

					}

				}

			}

		else if (token=="MM"||token=="M") {

			month=_getInt(val,i_val,token.length,2);

			if(month==null||(month<1)||(month>12)){return 0;}

			i_val+=month.length;}

		else if (token=="dd"||token=="d") {

			date=_getInt(val,i_val,token.length,2);

			if(date==null||(date<1)||(date>31)){return 0;}

			i_val+=date.length;}

		else if (token=="hh"||token=="h") {

			hh=_getInt(val,i_val,token.length,2);

			if(hh==null||(hh<1)||(hh>12)){return 0;}

			i_val+=hh.length;}

		else if (token=="HH"||token=="H") {

			hh=_getInt(val,i_val,token.length,2);

			if(hh==null||(hh<0)||(hh>23)){return 0;}

			i_val+=hh.length;}

		else if (token=="KK"||token=="K") {

			hh=_getInt(val,i_val,token.length,2);

			if(hh==null||(hh<0)||(hh>11)){return 0;}

			i_val+=hh.length;}

		else if (token=="kk"||token=="k") {

			hh=_getInt(val,i_val,token.length,2);

			if(hh==null||(hh<1)||(hh>24)){return 0;}

			i_val+=hh.length;hh--;}

		else if (token=="mm"||token=="m") {

			mm=_getInt(val,i_val,token.length,2);

			if(mm==null||(mm<0)||(mm>59)){return 0;}

			i_val+=mm.length;}

		else if (token=="ss"||token=="s") {

			ss=_getInt(val,i_val,token.length,2);

			if(ss==null||(ss<0)||(ss>59)){return 0;}

			i_val+=ss.length;}

		else if (token=="a") {

			if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}

			else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}

			else {return 0;}

			i_val+=2;}

		else {

			if (val.substring(i_val,i_val+token.length)!=token) {return 0;}

			else {i_val+=token.length;}

			}

		}

	// If there are any trailing characters left in the value, it doesn't match

	if (i_val != val.length) { return 0; }

	// Is date valid for month?

	if (month==2) {

		// Check for leap year

		if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year

			if (date > 29){ return 0; }

			}

		else { if (date > 28) { return 0; } }

		}

	if ((month==4)||(month==6)||(month==9)||(month==11)) {

		if (date > 30) { return 0; }

		}

	// Correct hours value

	if (hh<12 && ampm=="PM") { hh=hh-0+12; }

	else if (hh>11 && ampm=="AM") { hh-=12; }

	var newdate=new Date(year,month-1,date,hh,mm,ss);

	return newdate.getTime();

	}



// ------------------------------------------------------------------

// parseDate( date_string [, prefer_euro_format] )

//

// This function takes a date string and tries to match it to a

// number of possible date formats to get the value. It will try to

// match against the following international formats, in this order:

// y-M-d   MMM d, y   MMM d,y   y-MMM-d   d-MMM-y  MMM d

// M/d/y   M-d-y      M.d.y     MMM-d     M/d      M-d

// d/M/y   d-M-y      d.M.y     d-MMM     d/M      d-M

// A second argument may be passed to instruct the method to search

// for formats like d/M/y (european format) before M/d/y (American).

// Returns a Date object or null if no patterns match.

// ------------------------------------------------------------------

function parseDate(val) {

	var preferEuro=(arguments.length==2)?arguments[1]:false;

	generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');

	monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');

	dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');

	var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');

	var d=null;

	for (var i=0; i<checkList.length; i++) {

		var l=window[checkList[i]];

		for (var j=0; j<l.length; j++) {

			d=getDateFromFormat(val,l[j]);

			if (d!=0) { return new Date(d); }

			}

		}

	return null;

	}



function alphanumeric(alphane)

{

	var numaric = alphane;

	for(var j=0; j<numaric.length; j++)

		{

		  var alphaa = numaric.charAt(j);

		  var hh = alphaa.charCodeAt(0);

		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123))

		  {

		  }

		else	{

			 return false;

		  }

		}

 return true;

}





//-->