function openWin(url, type)
{
   if(type == "big")
     newWin = window.open(url,'big','resizable=yes,scrollbars=yes,status=yes,toolbar=yes,menubar=yes,location=yes,width=800,height=600');
   else if(type == "small")
     newWin = window.open(url,'small','resizable=yes,scrollbars=yes,menubar=yes,width=400,height=225,alwaysRaised=yes');
   else
     newWin = window.open(url,'big','resizable=yes,scrollbars=yes,status=yes,toolbar=yes,menubar=yes,location=yes,width=800,height=600');

   newWin.opener = self;
   newWin.focus();
}


/******************************************************************************
 * Name: getID
 *
 * Purpose: Return the proper document.whatever reference based upon the
 *          browser being used.  Mozilla and IE use different references to the
 *          elements on the page.  This function is primarily used with the
 *          showOption() function which deals with span elements.
 *
 * Inputs: id - A string which is the name of element you wish to get the
 *              reference to.
 *****************************************************************************/
function getID(id)
{
   if (document.getElementById)
   {
      return document.getElementById(id);
   }
   else if (document.all)
   {
      return document.all[id];
   }
/*
   else if (document.layers)
   {
      //return = document.layers[id];
   }
*/
}

/******************************************************************************
 * Name: trim
 *
 * Purpose: This function adds a method to any String object that trims leading
 *          and trailing white space off of the string
 *          How to Use: document.form.element.value.trim()
 *
 * Inputs: None
 *
 * Outputs: None
 *****************************************************************************/
String.prototype.trim = function()
{
   //Skip leading and trailing whitespace and return everything in between
   return this.replace(/^\s*(\b.*\b|)\s*$/, "$1");
}

/******************************************************************************
 * Name: toggleSpan
 *
 * Purpose: Toggle the view of the given span id
 *
 * Inputs: spId
 *
 * Outputs: None
 *****************************************************************************/
function toggleSpan(spId)
{
   var spnDef = getID(spId);
   if(spnDef.style.display == "block")
   {
      spnDef.style.display = "none";
   }
   else
   {
      spnDef.style.display = "block";
   }
}

/******************************************************************************
 * Name: isUniqueOrder
 *
 * Purpose: Make sure that all the dropdown boxes in an array of dropdowns are
 *				all unique. (No 2 dropdowns have the same selected value)
 *
 * Inputs:	arrElement - the document.form.elementName to the array of dropdowns
 *				arrSize - The number of dropdown boxes
 *
 * Outputs: None
 *****************************************************************************/
function isUniqueOrder(arrElement, arrSize)
{
	var rntVal = true;

	for(var i = 0; i < arrSize; ++i)
	{
		for(var j = 0; j < arrSize; ++j)
		{
			if((arrElement[i].value == arrElement[j].value) && (i != j))
			{
				rntVal = false;
				break;
			}
		}
		if(rntVal == false)
		{
			break;
		}
	}
	return rntVal;

}

/******************************************************************************
 * Name: chkGroupIsChecked
 *
 * Purpose: Make sure that at least one of the checkboxes in the given element is checked
 *
 * Inputs:	arrChk - The checkbox document.form.element to check for a checked
 *          value.  It is important that the name of all the checkbox elements
 *          are the same and that they have the [] as part of the name.
 *          i.e. <input... name="chkMyCheckbox[]" .../> This allows javascript
 *          to work with the checkboxes as if they are an array
 *
 *          arrSize ?
 *
 * Outputs: Bool - Indicating if there is at least one checkbox that is checked
 *****************************************************************************/
function chkGroupIsChecked(arrChk)
{
	var indx = 0;
	var bolChecked = false;
	var arrSize = arrChk.length;

	while(!bolChecked && (indx < arrSize))
	{
		bolChecked = arrChk[indx].checked;
		++indx;
	}

	return bolChecked;
}

/******************************************************************************
 * Name: checkLength
 *
 * Purpose: This function enforces a limit on textareas
 *
 * Inputs: txtField -  The textarea object to be checked
 *         intLength - The maximum length of the textarea
 *****************************************************************************/
function checkLength(txtField, intLength)
{
   if(txtField.value.length > intLength)
   {
      txtField.value = txtField.value.substring(0, intLength);
      txtField.focus();
   }
}

/******************************************************************************
 * Name: radioButtonCheck
 *
 * Prupose: This function takes a radio button form element and returns true if
 *          one of the buttons in the group has been selected, returns false
 *          otherwise.
 *
 * Input: myRadio - The radio button object.  This needs to include the document
 *                  and the form objects.  Ex. of how to call this function
 *                  radioButtonCheck(document.form.radioButtonId)
 *
 * Output: Bool - Indicates if one of the radio button options has been checked
 *****************************************************************************/
function radioButtonCheck(myRadio)
{
   var radioChecked = false;

   for(i = 0; i < myRadio.length; ++i)
   {
      //If a radio button has been selected then we're ok
      if(myRadio[i].checked)
      {
         radioChecked = true;
      }
   }
   return radioChecked;
}

/******************************************************************************
 * Name: getCheckedRbValue
 *
 * Prupose: Return the value of the checked radio button for the give radiobutton group
 *
 * Input: myRadio - The radio button object.  This needs to include the document
 *                  and the form objects.  Ex. of how to call this function
 *                  getCheckedRbValue(document.form.radioButtonId)
 *
 * Output: rntVal - String representing the value of the selected radiobutton
 *****************************************************************************/
function getCheckedRbValue(myRadio)
{
   var radioChecked = false;
   var rntVal = "";

   for(i = 0; i < myRadio.length; ++i)
   {
      //If a radio button has been selected then we're ok
      if(myRadio[i].checked)
      {
         radioChecked = true;
         rntVal = myRadio[i].value;
      }
   }
	return rntVal;
}

