// Function to check for data changes in a form before canceling
function cancel()
{
   if (document.referrer == '') 
   {
		history.back();
   } 
   else 
   {
		location.href = document.referrer;
   }
   return;
}

// Function to highlight the current value in a Drop Down List Box
function selectListValue(list, value)
{
   for (var ctr=0;ctr<list.length;ctr++)
   {
      if (list.options[ctr].value==value)
      {
         list.options[ctr].selected=true;
      }
   }
}

// Function to limit number of characters entered into a textarea
function textLimiter(field, maxlimit)
 {
  if (field.value.length > maxlimit)
  { 
  // if too long alert and trim it
  alert('Please limit your entry to ' + maxlimit + ' characters.');
  field.value = field.value.substring(0, maxlimit);
  }
}

// Function for setting focus to a particular form field
function setFocus(field) {
   field.focus();
   field.select();
}

//Function for spawning pop-up pdf document window page 
function newDocumentWindow(selObj)
{
    var url = selObj.options[selObj.selectedIndex].value;
	if (url.length > 0)
	{
    	  var newWin = window.open(url, "reportWin", 'titlebar=yes,resizable=yes,scrollbars=yes,status=yes');
  	  newWin.focus();
	//document.location.href=url;
	}
}