 function clearMe(formfield){
  if (formfield.defaultValue==formfield.value){
   formfield.value = ""}

  }
 function returnMe(formfield){
   if (formfield.value==""){
   formfield.value = formfield.defaultValue}
  }



function SendCommand(sender, command)
{
	// get the command form
	var commandForm = document.getElementById("commandform");
	// get the parent form of the calling button
	var submitForm = sender.form;

	// put the command name in the hidden element
	var commandName = document.getElementById("commandname");
	commandName.value = command;

	// loop through the elements of the form to be submitted
	for(i=0;i<submitForm.elements.length;i++)
	{
		// if the current element isn't the calling button
		if(submitForm[i].id != sender.id)
		{
			// set a boolean flag to indicate if form element is ok to send
			var appendChild = true;
			// create a new hidden element
			var dynamicField = document.createElement("input");
			dynamicField.setAttribute("type", "hidden")

			// set the dynamic element's id and name
			dynamicField.setAttribute("id", submitForm[i].id);
			dynamicField.setAttribute("name", submitForm[i].id);

			// look at the type of the current form element
			// get it's value based on the type
			switch(submitForm[i].type.toLowerCase())
			{
				case "text":
					dynamicField.setAttribute("value", submitForm[i].value);					
					appendChild = true;
				break;
				case "textarea":
					dynamicField.setAttribute("value", submitForm[i].value);				
					appendChild = true;
				break;
				case "checkbox":
					dynamicField.setAttribute("value", submitForm[i].checked);				
					appendChild = true;
				break;
				case "radio":
					// radio button groups seem to be a problem here
					// if the radio button is checked then get it's value
					// otherwise it doesn't want to be submitted
					if(submitForm[i].checked)
					{
						dynamicField.setAttribute("value", submitForm[i].value)
						appendChild = true;
					}else{
						appendChild = false;
					}
				break;
				case "select-one":
					dynamicField.setAttribute("value", submitForm[i].options[submitForm[i].selectedIndex].value);					
					appendChild = true;
				break;
				case "select-multiple":
					// generate a string based on which options are selected
					var selectedOptions = "";
					for(c=0;c<submitForm[i].length;c++)
					{
						if(submitForm[i][c].selected)
						{
							selectedOptions = selectedOptions + submitForm[i][c].value + ",";
						}
					}
					// if the string has a length then
					// strip off the last character as it will be a ","
					if(selectedOptions.length > 0){selectedOptions = selectedOptions.substring(0,selectedOptions.length - 1);}
					dynamicField.setAttribute("value", selectedOptions);					
					appendChild = true;
				break;
				case "hidden":
					dynamicField.setAttribute("value", submitForm[i].value);				
					appendChild = true;
				break;

			}
			// add the dynamic hidden form field to the command form
			if(appendChild){commandForm.appendChild(dynamicField);}
		}
	}
	// send the form
	commandForm.submit();
}