/*
place the following line in the header of the page that you want to include this file in
<script src="/includes/shared.js" type="text/javascript"></script>
all content written by Thomas Paine
all rights reserved
*/


function imageWindow(url,caption,width,height) {
  leftPos = ''
  topPos = ''
  toolbars = false
  scrollbars = true
  url = '/imageEnlarge.asp?imageUrl=' + url + '&caption=' + caption
  //width = width + 20
  //height = height + 50
  windowName = width + 'x' + height
  openCustomWindow(url,windowName,width,height,leftPos,topPos,toolbars,scrollbars)
}

function autoTab(input, len) {
/************************************************
DESCRIPTION: Automatically jumps the focus to the next field  
  in the tab sequence when a specified number of character is entered.  

PARAMETERS: 
  input - Text INPUT field to be tested.  
  len   - length of input before autotabbing.

  To use, include the following code as an inline event handler
  in an INPUT text field:
	 onKeyUp="return autoTab(this, n);"  
  where n is a number specifying len. 
    
RETURNS: 
  True if tab is made.

*************************************************/
	if(input.value.length >= len) 
	{
	input.value = input.value.slice(0, len);
	input.form[(getIndex(input)+1) % input.form.length].focus();
	}

	function getIndex(input) 
	{
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
		if (input.form[i] == input) index = i;
		else i++;
		return index;
	}
	return true;
}

function promptLink(message,valueName,defaultValue,link) {
  /*
  used to show a prompt box before proceeding.
  the value entered is passed to the link as the valueName
  used on:
    /database/util/userResults.asp
  */

  value = (prompt(message,defaultValue)) 
  window.location.href = link + '&' + valueName + '=' + value
}

function confirmLink(message,link,link2) {
  /*
  used to show a confirmation box before proceeding.
  if users hits cancel and link2 is empty, nothing happens
  used on:
    /database/util/userResults.asp
  */

  if (confirm(message)) 
    window.location.href = link
  else if (link2 != '' && link2 != null)
    window.location.href = link2
}


bName=navigator.appName;
function openCustomWindow(url,name,width,height,leftPos,topPos,toolbars,scrollbars) {
  //function used for opening a window, uses passed parameters
  //name is the name of the window
  //toolbars and scrollbars are boolean fields that determine whether those should be shown on window
  
  toolbarTxt = "toolbar=no,status=no"
  if (toolbars) {
    toolbarTxt = "toolbar=yes,status=yes"
  }
  scrollbarTxt = "scrollbars=no,resizable=yes"
  if (scrollbars) {
    scrollbarTxt = "scrollbars=yes,resizable=yes"
  }
  leftPosTxt = ''
  topPosTxt = ''
  if (!isNaN(leftPos) && !isNaN(topPos)) {
    if (bName != 'Netscape') {
      leftPos = leftPos + 10
      topPos = topPos + 10
    }
    topPosTxt = 'top=' + topPos
    leftPosTxt = 'left=' + leftPos
  }
  windowSpecs = topPosTxt + ',' + leftPosTxt + ',width=' + width + ',height=' + height + ',' + scrollbarTxt + ',' + toolbarTxt
  window.open(url,name, windowSpecs)
}

function promptDelete(msg,deleteURL) {
  if (confirm(msg)) {
    window.location.href = deleteURL
    //setTimeout('location.reload()','100')
  }
}

tab = 1
function setTabIndex(id) {
  eval('frm.' + id + '.tabIndex = ' + tab++)
}



