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




function ValidateEmail(src) {
     var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
     var regex = new RegExp(emailReg);
     return regex.test(src);
  }
  
function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function
