function ResetFormToBlank(aform)
{
	var ans = confirm("Are you sure you want to reset the form?");
	if (ans)  // YES
	{
		var i = 0;
		for (i=0; i < aform.elements.length; i++)
		{	
			if (aform.elements[i].type == 'text')
			{ 
				aform.elements[i].value = ""; 
			}
			else if (aform.elements[i].type == 'select-one') 
			{
			    /*
			    var foundSelected = false;
			    for (j=0; j < aform.elements[i].options.length; j++)
			    {
			        if (aform.elements[i].options[j].defaultSelected)
			        {
			            aform.elements[i].options[j].selectedIndex = j;
			            foundSelected = true;
			        }
			    }
			    if (!foundSelected)
			    {
			    */
				    aform.elements[i].selectedIndex = 0;
				/*
				}
				*/
			} 
			else if (aform.elements[i].type == 'checkbox') 
			{
				aform.elements[i].checked = false;
			} 
		}
	}

}

function isSelected(selectObj)
{ 
// function isSelected
// Description: Returns the whether or not an element of a select box or radio object
//              has been selected
// Syntax:  isSelected(selectObj)
// Inputs: selectObj - select box object or radio object that you want to check
// Returns:  true if an element of the select box or radio object has been selected
//           false if no element of the select box or radio object has been selected
// Example: 
//    If you had a form named form1, and a select box object or radio object named select1, 
//    the following would return whether or not an element of that object has been selected:
//             return (isSelected(document.form1.select1)
 	var i, theType='0', selected = false;
 	if (selectObj.type == 'radio')
  		theType = 'singleRadio';
  	if (selectObj.type == 'select-one')
   		theType = 'aSelect';
  	if (selectObj.type == 'select-multiple')
    	theType = 'mSelect';
  	if (theType == '0')
    	theType = 'multRadio';
  	if (theType == 'singleRadio')
  	{
   		 return selectObj.checked;
  	}
	for (i = 0; i < selectObj.length; i++)
	{  
		if (theType == 'aSelect' || theType == 'mSelect')
		{
	  		if (selectObj.options[i].selected && (selectObj.options[i].value != '') )
      		{  
	    		selected = true
        		break
      		}
		}
    	else
		{
	    	if (selectObj[i].checked)
    	  	{  
	    		selected = true
	        	break
    	  	}
		}
  	}
  	return (selected)
}

function selectCheck(selectObj, selectAlert)
{ 
// function selectCheck
// Description: Checks a select box or radio object to make sure an element is selected.  
//              If not, an alert box is displayed, and the focus is set to that select box or
//              radio object.
// Syntax:  selectCheck(selectObj, selectAlert)
// Inputs: selectObj - select box object or radio object that you want to work with
//         selectAlert- Optional Parameter.  Message to be displayed to user if no element 
//                      has been selected.  Defaults to "Please select an option"
// Returns: true if an element of the select box or radio object has been selected
//          false if no element of the select box or radio object has been selected 
// Example: selselectObjectCheck(document.form1.select1, "Please choose a State")
	var retval = true, theType='0';
  	if (selectObj.type == 'radio')
    	theType = 'singleRadio';
  	if (selectObj.type == 'select-one')
    	theType = 'aSelect';
  	if (selectObj.type == 'select-multiple')
    	theType = 'mSelect';
  	if (theType == '0')
    	theType = 'multRadio';
  	if (selectAlert == null)
    	selectAlert = "Please select an option";
  	if ( !isSelected(selectObj) )
  	{  
     	alert(selectAlert);
     	if (theType != 'singleRadio' && theType != 'multRadio')
	       	selectObj.focus();
    	retval = false;
	}
	else
	{
//     	if (theType != 'singleRadio' || theType != 'multRadio')
//		   	selectObj.focus();
     	retval = true;
  	}
  	return (retval)
}

function getSelected(selectObj)
{ 
// function getSelected
// Description: Returns the value of the selected element in the select box or radio object.  
//              The value refers to the value set in the <option> tag. i.e., "2" is the value 
//              in the following tag: 
//                      <option value="2">Type 2</option>
// Syntax:  getSelected(selectObj)
// Inputs: selectObj - select box object or radio object that you want to work with
// Returns:  null if no element is selected.
//           The value of the selected element if an element is selected.
// Example: return getSelected(document.form1.select1)

	var i, theType='0', retvalue = null;
  	if (selectObj.type == 'radio')
    	theType = 'singleRadio';
  	if (selectObj.type == 'select-one')
    	theType = 'aSelect';
  	if (theType == '0')
    	theType = 'multRadio';
  	if (theType == 'singleRadio')
	{
	    if (selectObj.checked)
	      	return selectObj.value;
		else
		  	return null;
	}
  	for (i = 0; i < selectObj.length; i++)
  	{  
    	if (theType == 'aSelect')
 		{	 
   			if (selectObj.options[i].selected)
      		{  
     			retvalue = selectObj.options[i].value;
        		break
      		}
 		}
 		else
 		{
   			if (selectObj[i].checked)
        	{  
		    	retvalue = selectObj[i].value
          		break
        	}
 		}  
  	}  
	return (retvalue)
}

// function makeSelected
//
// Description: Automatically selects an element of the select box or radio object
//
// Syntax:  makeSelected(selectObj, selectValue)
//     
// Inputs: selectObj - select box object or radio object that you want to work with
//         selectValue - value of the element in the select box or radio object that you want 
//                       to make selected. i.e. "2" is the value of the following tag:
//                            <option value="2">Type 2</option>
//       
// Returns:  none
//
// Example: 
//
//    If you had a form named form1, and a select box object or radio object named select1 
//    with an element with a value of "3", the following will make that element selected:
//
//             makeSelected(document.form1.select1, '3')
function makeSelected(selectObj, selectValue)
{  
  var i, theType='0';
  if (selectObj.type == 'radio')
    theType = 'singleRadio';
  if (selectObj.type == 'select-one')
    theType = 'aSelect';
  if (selectObj.type == 'select-multiple')
   	theType = 'mSelect';
  if (theType == '0')
    theType = 'multRadio';
  if (theType == 'singleRadio')
    if (selectObj.value == selectValue)
	{
      selectObj.checked = true 
      return;
    }
  for (i = 0; i < selectObj.length; i++)
   {   
     if(theType == 'aSelect' || theType == 'mSelect')
	 {
       if (selectObj.options[i].value == selectValue)
       {   
	     selectObj.options[i].selected = 1
         break
       }
	 }
	 else
	 {
	   if (selectObj[i].value == selectValue)
       {   
	     selectObj[i].checked = true
         break;
       }
	 }  
   }
}
