function submitTrack(actionName, ref) {
    document.forms[0].action.value = actionName;
    document.forms[0].reference.value = ref;
    result = validate();
    if (result != false) { 
//        show('msg-processing');
	document.forms[0].submit(); 
    }
}

function submitTrackWithConfirmation(actionName, question, ref) {
    if (confirm(question)) {
        document.forms[0].action.value = actionName;
        document.forms[0].reference.value = ref;
        result = validate();
        if (result != false) {
//	  show('msg-processing');
	  document.forms[0].submit(); 
	}
    }
}

function hrefWithConfirmation(target, question) {
    if (confirm(question)) {
//        show('msg-loading');
        document.location.href = target;
    }
}

function hreflink(target) {	
/* redirects to a link and pops up a 'loading' window */
/* XXX consider also writing to a 'non-interrupt' field to keep double-clicking from causing problems 
 */
//    show('msg-loading');
    document.location.href = target;
}

function populateDays(year, month, dayfield, datefield) {
  /* automatically sets days in selected month - adapted from http://javascript.internet.com/calendars/date-menu.html 
   * Original:  Ben McFarlin (mcfarlin@netscape.net) -->	
  */
  timeA = new Date(year, month, 1);
  timeDifference = timeA - 86400000;
  timeB = new Date(timeDifference);
  var daysInMonth = timeB.getDate();
  for (var i = 0; i < dayfield.length; i++) {
    dayfield.options[i] = null;
  }
  for (var i = 0; i < daysInMonth; i++) {
    dayfield.options[i] = new Option(i+1);
  }
  dayfield.options[0].selected = true;

  newDate = "1/" + month + "/" + year;
  datefield.value = newDate;
}

function setDateField(yearval, monthval, dayval, datefield) {
//alert("setDateField: " + yearval + ", " + monthval + ",  " + dayval);
    newDate = "" + monthval + "/" + dayval + "/" + yearval;
    datefield.value =  newDate;
}

function getSelectionText(field) {
	result = null;
	for (i=0; i<field.length; i++) {
		if (field.options[i].selected) {
			result = field.options[i].text;
		}
	}
	return result;
}

function getSelectionValue(field) {
	result = null;
	for (i=0; i<field.length; i++) {
		if (field.options[i].selected) {
			result = field.options[i].value;
		}
	}
	return result;
}

function setDateFieldFromFields(yearfield, monthfield, dayfield, datefield) {
//Handling a quirk with internet explorer that doesn't like direct access to options that have just been created 
    yearval = getSelectionValue(yearfield);
    monthval = getSelectionValue(monthfield);
    dayval = getSelectionText(dayfield);

    newDate = "" + dayval + "/" + monthval + "/" + yearval;

    datefield.value =  newDate;
}