var zip				= /^\d{9}$|^\d{5}$/;					// 94104 or 941041234
var zip2			= /^\d{5}[-]\d{4}$|^\d{5}$|^\d{9}$/;	// 12345-1234, 12345, 123451234
var ssn9			= /^\d{9}$/;							//123456789
var ssndash			= /^\d{3}([-])\d{2}\1\d{4}$|^\d{9}$/;	//123-45-6789
var email 			= /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]{2,3}$/i;	// user@domain.com
var emailinternet	= /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]{2,3}$/i;	// user@domain.com
var phone 			= /^\d{10}$/;							//accepts only 4155551212, no separators.
var phone2			= /^\d{3}([-])\d{3}\1\d{4}$|^\d{10}$/;	//accepts 415-5551212
var phone3			= /^\d{3}([-])\d{3}([-])\d{4}$/;
var currency		= /^([-])\d+$|^([-])\d+[\.]\d{1,2}$|^([-])\d+[\.]|^\d+$|^\d+[\.]\d{1,2}$|^\d+[\.]$/;
var date			= /^\d{1,2}([-\/])\d{1,2}\1(\d{4}$|\d{2}$)/;	//accepts dates with 2 or 4 digit years.
var date4			= /^\d{1,2}([-\/])\d{1,2}\1(\d{4}$)/;	//accepts dates only 4 digit year, ie 1/1/2000
var dateallnumber	= /^\d{8}$|^\d{6}$/;					//accepts dates with no separator, 2 or 4 year, ie 013001 or 01302001
var state			= /^[a-z]{2}$/i;						//ca, CA
var number			= /^\d+$/;								//numbers only
var letter			= /^[a-z]+$/i;							//letters only
var yn				= /^[y,n]$/i;							//y or n only
var gender			= /^[f,m,u]$/i;							//f=female, m=male, u=unknown

var netid                   = /^[a-zA-Z]{2}\d{4}$/;


//*****************************************************************

// Global Variable
var radiolist = "";
var firstobjname = null;

//*****************************************************************
/*
Usage:
	Checks if a form field is formatted correctly by comparing the field value to the field definitions.

	Input:
		field_format: name of the format definitions above
		field_value: the value of the actual field from the form
	Example:
		isformat ('ssn', this.form.ssn.value);
*/

function isformat(field_format, field_value){
	/*	for apostrophes, it will be replaced with \' so that
		it will be treated as a literal. Otherwise, the exec
		method will err due to an unintended end of string, ie 'm'ccormack'.
	*/
	
	field_value = field_value.replace( /\'/g, "\\'");
	
	// create string that will compare the allowed field definitions to the actual field value
	var str = field_format + ".exec('" + field_value + "')";
	var ok = eval(str);
	
	if (!ok)
		return false;
	else
		return true;
}

//*****************************************************************
/*
Usage:
	Checks if a form field is empty.
	
	Input:
		eachobj: the specific individual form element
		formobj: the form itself
	Output:
		returns True or False
	Example:
		isempty (this.form.ssn, this.form);
*/

function isempty(eachobj, formobj){

//radio and checkbox form elements are checked with same function for value
	if (eachobj.type == 'radio' || eachobj.type == 'checkbox') {
	//if (eachobj.type == 'radio') {
		//if the current element name is in the radiolist string variable, that means it was checked already and can be skipped.

		if (radiolist.indexOf(eachobj.name) == -1){
			//alert("radiolist: " + radiolist);
			//return false;
			
			// otherwise, add the current element name to radiolist.
			radiolist = radiolist + eachobj.name + ',';
//			alert(getRadioValue (eachobj, formobj));
			
			// refer to getRadioValue function to see if it's checked and get the value if so.
			if (getRadioValue (eachobj, formobj) != null){
//				alert("got radio");
				return false;
			}
			else {
//				alert("no radio");
				return true;
			}
		}		
	}
			
	if (eachobj.type.indexOf('select') != -1){
		if (eachobj.selectedIndex == -1)
			return true;
		else
			if (eachobj.options[eachobj.selectedIndex].value == '' || eachobj.options[eachobj.selectedIndex].value == 'Please Select One')
				return true;
	}

	if (eachobj.type == 'text' || 
		eachobj.type == 'textarea' ||
        eachobj.type == 'password' || 
		eachobj.type == 'file' ) { 
			var value = eachobj.value
			
			if (value == '' || value == 'undefined') return true;
			for (var i=0; i<value.length; i++) {
				var ch = value.charAt(i);
				if (ch != ' ' && ch != '\t') return false;
			}
			return true;
    }
	
} //end function


//*****************************************************************
/*
Usage:
	Checks if a radio/checkbox group is checked and if so, it returns the value.
	
	Input:
		eachobj: the specific individual form element
		formobj: the form itself
	Example:
		getRadioValue (this.form.ssn, this.form);
*/
function getRadioValue (eachobj, formobj) {


	var value = null;
	var group = formobj[eachobj.name];

	//if it's a group, it'll loop through the array to find the checked value
	if (group.length) {
	  for (var b = 0; b < group.length; b++)
	    if (group[b].checked)
	      value = group[b].value;
	}
	else
		//if it's a single selection, it'll confirm if it's checked and get the value.
		if (group.checked)
			value = group.value;

	return value;
}
//*****************************************************************
/*
Usage:
	Checks if a radio/checkbox group is checked and if so, it returns the value.
	
	Input:
		eachobj: the specific individual form element
	Example:
		getRadioValue2 (this.form.ssn);
*/
function getRadioValue2(checkbox) {

	var value = null;
	var group = checkbox;

	//if it's a group, it'll loop through the array to find the checked value
	if (group.length) {
	  for (var b = 0; b < group.length; b++)
	    if (group[b].checked)
	      if (value != null)
		  	value = value + "," + group[b].value;
		  else
		  	value = group[b].value;
	}
	else
		//if it's a single selection, it'll confirm if it's checked and get the value.
		if (group.checked)
			value = group.value;

	return value;
}

//****************************  MAIN FUNCTION *************************************
/*
Usage:
	Checks if all the form fields for required fields and the proper formatting.
	As it loops through all the form elements, it will check with the rlist array for required field and formatting.
	
	Input:
		formobj: the form itself
		
		the form page will need the following array:
		var rlist = [
			{fieldname: 'issueownerid', displayname: 'Issue Owner', require: 'yes', format: ''},
			{fieldname: 'dateissue', displayname: 'Date of Issue', require: 'yes', format: 'date'},
			{fieldname: 'amount', displayname: 'Amount', require: '', format: 'currency'},
			{fieldname: 'letter', displayname: 'Letter Sent', require: 'yes', format: ''},
			{fieldname: 'size', displayname: 'Size', require: 'yes', format: ''}
			];

	Example:
		<form action="indexbyform.cfm" method="post" name="addissue" onSubmit="return checkform(this)">

*/

function checkform(formobj, otherchecks){	

//	alert(radiolist);
	
	var rmsg	= "";
	var fmsg	= "";
	var fname	= "";
	var first_empty_require	= "";
	var first_error_format	= "";

	for (i=0;i<formobj.length;i++) {
		var eachobj=formobj.elements[i];

		//SKIP FORM ELEMENTS WITH NO NAME ATTRIBUTE OR ARE HIDDEN.
		if(eachobj.name.length == 0 || eachobj.type == "hidden") continue;

		if(isempty(eachobj, formobj)){
			//eachobj.value = '';
		
			for (var c=0; c<rlist.length; c++) {
				//str = rlist[c].fieldname.indexOf(eachobj.name);
				//if (str != -1) {
				if (eachobj.name == rlist[c].fieldname) {
					if (rlist[c].require == "yes"){
						rmsg = rmsg + rlist[c].displayname + "\n";
						if (!first_empty_require) {
							first_empty_require = eachobj.name;
							first_empty_require_object = eachobj;
							//alert("first require fieldname: " + first_empty_require);
						}
					}
				}
				continue;
			} //end for c
		} //end if isempty
		else {
			for (var c=0; c<rlist.length; c++) {
				if ( (eachobj.name == rlist[c].fieldname)
					&& (eachobj.type == 'text' || eachobj.type == 'textarea') ){
					if (rlist[c].format.length > 0){
						var rlist_format = rlist[c].format;
						var rlist_displayname = rlist[c].displayname;
						//alert( "rlist format: " + rlist_format);
					
						if (isformat(rlist_format, eachobj.value) == false){
							fmsg = fmsg + rlist_displayname + "\n";

							if (!first_error_format) {
								first_error_format = eachobj.name;
                                                                first_error_format_object = eachobj;
								//alert("first require fieldname: " + first_empty_require);
							}
						}
					}
				}
			}
			
		} //end if isempty else
	} //end for i

	// need to reset radiolist to empty since this is a global variable.
	radiolist = "";
	
	if (rmsg.length != 0 || fmsg.length != 0){
		if (rmsg.length != 0){
			alert("REQUIRED FIELDS:\n\n" + rmsg);
			
//			alert (first_empty_require_object.type);
			
		
			first_empty_require_object.focus();
			
			first_empty_require = "";
			first_empty_require_object = "";
			firstobjname = null;
			return false;
		}
		if (fmsg.length != 0){
			alert("PLEASE CHECK FORMAT FOR:\n\n" + fmsg);
			first_error_format_object.focus();
			first_error_format_object.select();
			first_error_format = "";
			firstobjname = null;
			return false;
		}
               
               return false;
	}
        else
        {
	
	 firstobjname = null;
	 return true;
        }
	
} //end function checkform


//***************************************************************************
function isblankform(formobj){
	var isblank = "true";
	
	
	//alert(formobj.elements[0].name);
	for (i=0;i<formobj.length;i++) {
		var eachobj=formobj.elements[i];
		
		//if (eachobj.type != "hidden") alert(formobj.elements[i].name);
		
		//SKIP FORM ELEMENTS WITH NO NAME ATTRIBUTE OR ARE HIDDEN.
		if(	eachobj.name.length == 0 || eachobj.type == "hidden" || 
			eachobj.type == "button" || eachobj.type == "submit") continue;

		if (!firstobjname){
			firstobjname = formobj.elements[i].name;
			//alert(firstobjname);
		}
		
		if(!(isempty(eachobj, formobj))){
			//alert(eachobj.name);
			return false;
		}
	}

	return true;
		
} //end function isblankform

/***********************************************
DELETES SPACES FROM A STRING PASSED FROM A FORM
USAGE: TYPE ONCLICK="DELETESPACES(THIS)" OR ONCLICK="DELETESPACES(FORM.OBJECTNAME)"
*/
function deletespaces(object){
re = / /g;		// finds the pattern of a single space, /g=globally in the string.
str = object.value;
newstr = str.replace(re, "");
object.value=newstr;
}


/******************************************************
LIMITS THE AMOUNT OF TEXT IN A TEXTAREA FORM ELEMENT.
USAGE: 
	<textarea cols=30 rows=4 name="shortdesc" 
		onKeyUp="textCounter(this.form.textfield,this.form.counterfield,100);"	>
	</textarea><br>
	<input readonly type=hidden name=counterfield size=3 maxlength=3 value="100" class="basictext-1">
*/
function textCounter(field, counterfield, maxlen, warning) {
	if (field.value.length > maxlen) {	
		// if too long...trim it!
		field.value = field.value.substring(0, maxlen);
		field.focus();
		if (warning)
			alert("This field is limited to " + maxlen + " characters");
	}
	
	counterfield.value = field.value.length;
}


/*********************************************************/
function round (n, d) {
  n = n - 0;
  d = d || 2;
  var f = Math.pow(10, d);
  n = Math.round(n * f) / f;
  n += Math.pow(10, - (d + 1));
  n += '';
  return d == 0 ? n.substring(0, n.indexOf('.')) :
      n.substring(0, n.indexOf('.') + d + 1);
}


/*********************************************************/
function add2text(eachobj, chr, maxlength, position){
	var newtext = eachobj.value;
	
	if (position == 'prefix'){
		for (var i = eachobj.value.length; i < maxlength; i++){
			newtext = chr + newtext;
		}
	}
	else {
		if (position == 'suffix'){
			for (var i = eachobj.value.length; i < maxlength; i++){
			newtext = newtext + chr;
			}
		}
		else {
			//alert(eachobj.value.length + chr + maxlength + position + "    add2text result: " + newtext);
			return newtext;
		}
	}
	
	//alert(eachobj.value.length + chr + maxlength + position + "    add2text result: " + newtext);
	
	return newtext;
}
	
	
/*********************************************************/
function checkdate(objName) {
	var datefield = objName;
	
	if (chkdate(objName) == false) {
		if (datefield.type != 'hidden'){
			datefield.select();
			datefield.focus();
		}
		alert("That date is invalid. Please try again.");
		return false;
	}
	else {
		return true;
	}
}

function chkdate(objName) {
	var strDatestyle = "US"; //United States date style Month Day Year
	//var strDatestyle = "EU"; //European date style Day Month Year
	var runTime = new Date();
	var strCurrentYear = runTime.getYear();
	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 < 2) || (strDateArray.length > 3)) {
				err = 1;
				alert('X');
				return false;
			}
		else {
			strDay = strDateArray[0];
			strMonth = strDateArray[1];
			if (strDateArray.length == 2) 
				strYear = strCurrentYear
			else
				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 == null) {
	  return false;
	}
	
	if (strYear.length == 1) {
		strYear = '0' + strYear
	}
	
	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;
		}
		
		if (LeapYear(intYear) == true) {
			if (intday > 29) {
				err = 9;
				return false;
			}
		}
		else {
			if (intday > 28) {
				err = 10;
				return false;
			}
		}
	}
	
	/*
	if (strDatestyle == "US") {
		datefield.value = strMonthArray[intMonth-1] + " " + intday+" " + strYear;
	}
	else {
		datefield.value = intday + "/" + strMonthArray[intMonth-1] + "/" + strYear;
	}
	*/
	return true;
}

function LeapYear(intYear) {
	if (intYear % 100 == 0) {
		if (intYear % 400 == 0) { return true; }
	}
	else {
		if ((intYear % 4) == 0) { return true; }
	}
	
	return false;
}


/*********************************************************/	
/*
Usage:
	Checks all the form fields for empty fields.
	If empty, it will replace with an empty string ie ''.
	This may occur when user enter spaces or tabs.
	
Input:
	formobj: the form itself

*/

function nullify(formobj){

	for (i=0;i<formobj.length;i++) {
		var eachobj=formobj.elements[i];

		//SKIP FORM ELEMENTS WITH NO NAME ATTRIBUTE OR ARE HIDDEN.
		if(eachobj.name.length == 0 || eachobj.type == "hidden") continue;

		if(isempty(eachobj, formobj)){
			eachobj.value = '';
		}
	}
			
} //end function nullify

//***************************************************************************
/*
Usage:	Converts all form fields of type 'text' to capital letters.

Input:	formobj: the form itself
*/

	function allfieldscaps(formobj){
		for (i=0;i<formobj.length;i++) {
			var eachobj=formobj.elements[i];

			//if the field type is text, capitalize all letters otherwise, skip them.
			if(eachobj.type == "text")
				eachobj.value = eachobj.value.toUpperCase();
		} //end for i
	} //end of function allfieldscaps
	
//***************************************************************************
/*
Description:	Trims leading and trailing spaces.

Usage:	trimSpaces(string);

Input:	string variable
*/
	
function trimSpaces (str) {
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

//***************************************************************************
/*
Description:	1. returns the selected array number of radio group
				2. returns value of selected radio value

Usage:	getSelectedRadio(document.form.radio_field);
		getSelectedRadioValue(document.form.radio_field);
		
Input:	radio object
*/

function getSelectedRadio(buttonGroup) {
	// returns the array number of the selected radio button or -1 if no button is selected
	if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
		for (var i=0; i<buttonGroup.length; i++) {
	    	if (buttonGroup[i].checked) {
	        	return i
	       }
	    }
	 } 
	 else {
	    if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
	 }
	 // if we get to this point, no radio button is selected
	 return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
// returns the value of the selected radio button or "" if no button is selected
var i = getSelectedRadio(buttonGroup);
	if (i == -1) {
	   return "";
	} else {
	   if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
	      return buttonGroup[i].value;
	   } else { // The button group is just the one button, and it is checked
	      return buttonGroup.value;
	   }
	}
} // Ends the "getSelectedRadioValue" function


//***************************************************************************
/*
Description:	uncheck all checkboxes

Usage:	uncheckAll(document.form.checkbox_field);

Input:	checkbox object
*/

function uncheckAll(field)
	{
	if (field.length)
		for (i = 0; i < field.length; i++)
			field[i].checked = false ;
	else
		field.checked = false;
}


//***************************************************************************
/*
Description:	check all checkboxes (ie select all)

Usage:	checkAll(document.form.checkbox_field);

Input:	checkbox object
*/

function checkAll(field)
	{	
	if (field.length)
		for (i = 0; i < field.length; i++)
			field[i].checked = true ;
	else
		field.checked = true;
}

//***************************************************************************
function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

//***************************************************************************
function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function

//***************************************************************************

function getSelectedCheckbox(buttonGroup) {
   // Go through all the check boxes. return an array of all the ones
   // that are selected (their position numbers). if no boxes were checked,
   // returned array will be empty (length will be zero)
   var retArr = new Array();
   var lastElement = 0;
   if (buttonGroup[0]) { // if the button group is an array (one check box is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            retArr.length = lastElement;
            retArr[lastElement] = i;
            lastElement++;
         }
      }
   } else { // There is only one check box (it's not an array)
      if (buttonGroup.checked) { // if the one check box is checked
         retArr.length = lastElement;
         retArr[lastElement] = 0; // return zero as the only array value
      }
   }
   return retArr;
} // Ends the "getSelectedCheckbox" function

//***************************************************************************

function getSelectedCheckboxValue(buttonGroup) {
   // return an array of values selected in the check box group. if no boxes
   // were checked, returned array will be empty (length will be zero)
   var retArr = new Array(); // set up empty array for the return values
   var selectedItems = getSelectedCheckbox(buttonGroup);
   if (selectedItems.length != 0) { // if there was something selected
      retArr.length = selectedItems.length;
      for (var i=0; i<selectedItems.length; i++) {
         if (buttonGroup[selectedItems[i]]) { // Make sure it's an array
            retArr[i] = buttonGroup[selectedItems[i]].value;
         } else { // It's not an array (there's just one check box and it's selected)
            retArr[i] = buttonGroup.value;// return that value
         }
      }
   }
   return retArr;
} // Ends the "getSelectedCheckBoxValue" function

//*********************************************************************

var opened= 0;
var OpenWindow;
function popUp(url, winname) 
{ 
	if (opened == 0)
	{
	OpenWindow=window.open(url, winname);
	}
	
	if ((OpenWindow.blur) && (! OpenWindow.closed)) 
	{
	opened=1;
	OpenWindow.focus(); 
	OpenWindow.location.href=url; 
	}
	else
	{
	opened=0;
	}

}

/******************************************************************/

 function clearform(formobj){
	
	//alert(formobj.elements[0].name);
	for (i=0;i<formobj.length;i++) {
		var eachobj=formobj.elements[i];
		
		//if (eachobj.type != "hidden") alert(formobj.elements[i].name);
		
		//SKIP FORM ELEMENTS WITH NO NAME ATTRIBUTE OR ARE HIDDEN.
		if(	eachobj.name.length == 0 || eachobj.type == "hidden" || 
			eachobj.type == "button" || eachobj.type == "submit") continue;

/*
		if (!firstobjname){
			firstobjname = formobj.elements[i].name;
			alert(firstobjname);
		}
*/

		
		
		if (eachobj.type == 'radio' || eachobj.type == 'checkbox') {
		//if the current element name is in the radiolist string variable, that means it was checked already and can be skipped.
			uncheckAll(eachobj);
		}
		else{
			if(!(isempty(eachobj, formobj))){
			//alert(eachobj.name);
			eachobj.value = "";
			}
		}
	}

	return true;
		
} //end function isblankform


function PCase(STRING){
var strReturn_Value = "";
var iTemp = STRING.length;
if(iTemp==0){
return"";
}
var UcaseNext = false;
strReturn_Value += STRING.charAt(0).toUpperCase();
for(var iCounter=1;iCounter < iTemp;iCounter++){
if(UcaseNext == true){
strReturn_Value += STRING.charAt(iCounter).toUpperCase();
}
else{
strReturn_Value += STRING.charAt(iCounter).toLowerCase();
}
var iChar = STRING.charCodeAt(iCounter);
if(iChar == 32 || iChar == 45 || iChar == 46){
UcaseNext = true;

}
else{
UcaseNext = false
}
if(iChar == 99 || iChar == 67){
if(STRING.charCodeAt(iCounter-1)==77 || STRING.charCodeAt(iCounter-1)==109){
UcaseNext = true;
}
}


} //End For

return strReturn_Value;
} //End Function

/******************************************************************/

function toProperCase(s)
	{
	  return s.toLowerCase().replace(/^(.)|\s(.)/g, 
			  function($1) { return $1.toUpperCase(); });
	}
	
/******************************************************************/
/*
Usage:
	Use mainly for cascade server to get the selected radio or checkbox value(s)

	Input:
		elementGroupName: radio group or checkbox group name
		formobj: fully qualified form name
        Output:
                string value
	Example:
		alert(csuebGetRadioCheckboxValue("HIGHDEG[]", document.form_reservation));
*/
function csuebGetRadioCheckboxValue(elementGroupName, formobj){

    var result = "";
	
    for (i=0;i<formobj.length;i++) {
        var eachobj=formobj.elements[i];

	    //SKIP FORM ELEMENTS WITH NO NAME ATTRIBUTE OR ARE HIDDEN.
	    if ( eachobj.name.length == 0 || eachobj.type == "hidden") continue;
	    
		if ((eachobj.type == 'radio' || eachobj.type == 'checkbox') && (eachobj.name == elementGroupName) )
		{
        	result = getSelectedRadioValue(eachobj)
       	} // end if radio or checkbox and matches element group name
	 } // end for formobj loop
	
	return result; 
}

