<!--

/**  Function: null clearInput(ele, val)
*    ---------------------------------------------------------------- 
*    Purpose:           clear an input
*    Arguments:         ele			- str, the name of the element to clear
*						val			- str, the default value that should be cleared
*    Returns/Assigns:   none
*/

function clearInput(ele, val){
	if(ele.value == val){
		ele.value='';
	}
}


/**  Function: null openWin(windowURL, windowName, windowFeatures)
*    ---------------------------------------------------------------- 
*    Purpose:           opens a new window and sets its properties
*    Arguments:         windowURL			- str, the url
*						windowName			- str, the window name
*						windowFeatures		- str, the features of the window
*    Returns/Assigns:   none
*/

function openWin(windowURL, windowName, windowFeatures){
	window.open(windowURL, windowName, windowFeatures);
}





/**  Function: null writeEmail(user, domain, subject, text)
*    ---------------------------------------------------------------- 
*    Purpose:           writes an email address in a mailto link
*						if no 'text' is supplied it just writes the <a href="mailto:user@domain">
*						if 'text' is supplied it writes <a href="mailto:user@domain">text</a>
*						if 'subject' is supplied it writes <a href="mailto:user@domain?subject=subject">text</a>
*    Arguments:         user			- str, the username for the email address
*						domain			- str, the domain name of the email address
*						subject			- str, any subject line required
*						text			- str, text for the link
*    Returns/Assigns:   writes a mailto link
*/

function writeEmail(user, domain, subject, text){
	// open up a mailto and combine the user and domain into an email address
	document.write('<a href="mailto:' + user + '@' + domain);
	if(subject){
		// if there's a subject tack it on
		document.write('?subject=' + subject);
	}
	document.write('">');
	if(text){
		// if there's text for the link add it and close the link
		document.write(text + '</a>');
	}
}

function jumpto(formname, fieldname) {
	var newIndex = document[formname].elements[fieldname].selectedIndex;
	cururl = document[formname].elements[fieldname].value; 
	window.location.assign(cururl); 
}

/**  Function: null toggleExplorer(ele)
*    ---------------------------------------------------------------- 
*    Purpose:           toggle the display / hide property of an element with an explore + / - image
*    Arguments:         ele			- str, the name of the element
*    Returns/Assigns:   none
*/

function toggleExplorer(ele){
	var el = document.getElementById(ele);
	var img = document.getElementById('img' + ele);
	if(el.style.display == 'none'){
		el.style.display = '';
		img.src = 'images/explorer_minus.gif';
	}else{
		el.style.display = 'none';
		img.src = 'images/explorer_plus.gif';
	}
}


function calculateCheckboxQuantity(base_item) {
  quantity = 0;
  for (i = 0; ; i++) {
    id = base_item + '_' + i;
    elem = getObj(id);
    if (elem == null) {
      break;
    } else {
    	if(elem.checked) {
    		quantity = quantity +1;
    	}
    }
  }
  return quantity;
}

/*
* Browser-safe get object. Tries all three approaches to get an object
* by its element Id.
*
* Param:               objId - String - id of element to retrieve.
* Param:               formId - String - id of form (optional).
* Returns:             element or null if not found.
*/
function getObj(objId, formId) {
  var fullId = objId;
  if (formId != null && formId.length > 0) {
    fullId = formId + ':' + objId;
  }
  //alert('getting object: ' + fullId);
  var elem = null;
  if (document.getElementById) {
    elem = document.getElementById(fullId);
  } else if (document.all) {
    elem = document.all[fullId];
  } else if (document.layers) {
    elem = document.layers[fullId];
  }
  return elem;
 }
 
function toggleDisplay(ele){
	var el = document.getElementById(ele);
	if(el.style.display == 'none'){
		el.style.display = '';
	}else{
		el.style.display = 'none';
	}
}
// -->