

/////////////////////////////////////////////
// ... Javascript library file for UTSW ...//
/////////////////////////////////////////////


//...
//... Function to Check if a string field is null
//...
	function isblank(s)
	{
		for(var i = 0; i < s.length; i++) {
			var c = s.charAt(i);
			if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
		}
		return true;
	}

//...
//... Function to Check if a string field is null
//...
	function isNumber(num)
	{
		for (var i=0; i<num.length; i++)
			if ( num.charAt(i) < '0' || num.charAt(i) > '9' )
			return false;
		return true;
	}

//...
//... Function to check or uncheck all checkboxes
//...
	function checkAll(checkFlag,ch) {
		if (! (typeof ch == 'undefined')) {
			if (checkFlag.checked == true) {
				if (!ch==null || !ch.length) {
					ch.checked = true;
				} else {
					for (i = 0; i < ch.length; i++) {
						ch[i].checked = true;
					}
				}
			} else {
				if (!ch==null || !ch.length) {
					ch.checked = false;
				} else {
					for (i = 0; i < ch.length; i++) {
						ch[i].checked = false;
					}
				}
			}
		}
	}


// ...
// ... Code for displaying stencils when smaller image is selected
//...

	function changeImage(imageName) {
	  eval('document.ImageMgt.masterImg.src=document.ImageMgt.'+ imageName + '.src');
	  eval('document.ImageMgt.fpSelectedImageId.value = document.ImageMgt.'+ imageName + '_id.value');
	  eval('document.ImageMgt.fpSelectedImageTitle.value = document.ImageMgt.' +imageName + '_title.value');
	  eval('document.ImageMgt.masterImgId.value = document.ImageMgt.'+ imageName + '_id.value');
	  eval('document.ImageMgt.masterImgPath.value = document.ImageMgt.'+ imageName + '_path.value');
	}

//...
//...  Move the row up in the list box
//...
	function moveUp(listBox)
	{
	  var index = listBox.selectedIndex;

	  // If no rows were selected, display error message and return
	  if (index < 0)
	  {
		alert("Please select row to move.");
		return;
	  }

	  if (index == 0)
	  {
		return;
	  }

	  // Swap places with the row above.  This supports only one
	  // selected row at a time (no multiple selections
	  var description = listBox.options[index].text;
	  var id = listBox.options[index].value;
	  var thisEntry = new Option(description, id);

	  description = listBox.options[index-1].text;
	  id = listBox.options[index-1].value;
	  var entryAbove = new Option(description, id);

	  listBox.options[index-1] = thisEntry;
	  listBox.options[index] = entryAbove;

	  listBox.options[index-1].selected = true;
	}

	//...
	//...  Move the row down in the list box
	//...
	function moveDown(listBox)
	{
	  var index = listBox.selectedIndex;

	  // If no rows were selected, display error message and return
	  if (index < 0)
	  {
		alert("Please select row to move.");
		return;
	  }

	  if (index == listBox.length-1)
	  {
		return;
	  }

	  // Swap places with the row below.
	  var description = listBox.options[index].text;
	  var id = listBox.options[index].value;
	  var thisEntry = new Option(description, id);

	  description = listBox.options[index+1].text;
	  id = listBox.options[index+1].value;
	  var entryAbove = new Option(description, id);

	  listBox.options[index+1] = thisEntry;
	  listBox.options[index] = entryAbove;

	  listBox.options[index+1].selected = true;
	}

	//...
	//... This function updates the form variable holding the current option order.
	//...
	function updateSequenceList (sequenceList, sequenceIdList)
	{
		// update the order of the items into the "FORM_ELEMENT_NAME" form element

		// initialize the variable
		sequenceIdList.value = '';

		// save the list
		for (var i = 0; i < sequenceList.length; i++)
		{
			sequenceIdList.value += sequenceList[i].value;
			sequenceIdList.value += ' ';
		}
	}
