<!--	


/*
   dlgSettings
Creates settings string for standard dialog box, given width and height
*/
function dlgSettings(height, width)
{
	return "dialogHeight:" + height + "px;dialogWidth:" + width + "px;resizable:no;scroll:no;status:no;unadorned:yes;help:yes";
}


/*
   ValidateNumber
Validates the number in the given control.  If it is not valid, a popup window 
is displayed to the user, the text is selected and the change of focus is canceled.
*/
function ValidateNumber(ctrlNumber)
{
	var dtDate, sDate, sInputDate;
	
	
	if (ctrlNumber.value != null && ctrlNumber.value != '' && isNaN(ctrlNumber.value))
	{
		alert('You must enter a valid number for this field!');
		ctrlNumber.focus();
		ctrlNumber.select();
		window.event.returnValue = false;
	}
	else
	{
	   window.returnValue = true;
	}
}


var errInvalidDate = 'Invalid Date.\nPlease enter the date one of the following formats:\n' +
				'\n\tDD/MM/YY\n\tDD MMM YYYY\n\tDD-MMM-YYYY\n\tDDMMYY\n\tDDMMYYYY\n\tMMM DD, YYYY\n'

/*
   ValidDate
Validates the given string as a cvalid date and formats it to the locale defined format.  The
time is stripped off if bKeepTime is not true.
*/
function ValidDate(sInputDate, bKeepTime)
{
	var sRetDate = new String();
	var dtDate;

	if (sInputDate == '' || sInputDate == null)
	{
		return '';
	}

	// This is to enable the entering of dates in the format '23-JUL-1990'
	var re = /-/ig;
	sInputDate = sInputDate.replace(re,' ');	
	re = /^\d{6}|\d{8}$/;
	if (sInputDate.match(re))
	{
		var r;
		re = /^(\d{2})(\d{2})(\d{2}.*)$/;
		r = sInputDate.match(re)
		sInputDate = r[2] + '/' + r[1] + '/' + r[3];
	}
	try {
		dtDate = new Date(sInputDate);
	}
	catch(e) {}
	if (isNaN(dtDate)) throw errInvalidDate;
	sRetDate = new String(dtDate.toLocaleString());
	if (bKeepTime != true)
	{
		var nIndex;
		nIndex = sRetDate.indexOf(':') - 3;
		sRetDate = sRetDate.substr(0,nIndex);
	}
	return sRetDate;		
}


/*
   ValidateDate
This function ensures that the date in the given control is valid, formats it to the defined
locale date (the server defined locale date) and keeops the time if keeptime is true.  If the
date is invalid, a message is displayed to the user showing the valid formats, the text is 
selected and the background color of the field is turned to red.  The change focus event is 
canceled to prevent the user from leaving the field while an invalid date is in it.
*/
function ValidateDate(ctrlDate, keepTime)
{
	var dtDate, sDate, sInputDate;
	var bKeepTime = false;
	
	if (ValidateDate.arguments.length > 1)
	{
		bKeepTime = keepTime;
	}
	
	try
	{
		// This is to enable the entering of dates in the format '23-JUL-1990'
		sDate = ValidDate(ctrlDate.value, bKeepTime)
		ctrlDate.style.backgroundColor = '';
		ctrlDate.value = sDate;
	}
	catch(err)
	{
		if (err == errInvalidDate)
		{
			alert(err);
			//ctrlDate.style.backgroundColor = 'red';
			//ctrlDate.style.Color = 'white';
			ctrlDate.focus();
			ctrlDate.select();
			//window.event.returnValue = true;
			return err;
		}
		else
		{
			// not ours. let it go...
			throw err;
		}
	}	
}


/*
   PromptUser
PromptUser will prompt the user for the information specified in the infoFor parameter
(see prompt.htm for options) andwill return the information retreived from the user
in eeither a query string format or (if bInArray) is true) in an associate (named) array. 
*/
function PromptUser(infoFor, bInArray)
{
	var sOptions = 'center:yes;status:no;dialogHeight:200px;dialogWidth:385px;resizable:no;';	

   if (PromptUser.arguments.length < 2)
      bInArray = false;
      
	return window.showModalDialog('/tools/prompt.htm', Array(infoFor, bInArray), sOptions);
	
}



/*
   Trim
*/
function Trim(sVal)
{
   var re = /\s+$/;
   var nIndex = sVal.search(re);
   if (nIndex >= 0)
      sVal = sVal.slice(0, nIndex);
   re = /\S/;
   nIndex = sVal.search(re);
   if (nIndex >= 0)
      sVal = sVal.slice(nIndex);
   return sVal;
}


/*
   serverName
*/
function serverName()
{
   var sURL = new String(document.location.href.slice(7));
   var re = /\/{1}/;
   var index = sURL.search(re);
   var sName = new String();
   if (index >= 0)
      sName = sURL.substring(0, index)
   else
      sName = sURL;
      
   return sName;
   
}


/*
   fullPath
*/
function fullPath()
{
   var sURL = new String(document.location.href.slice(7));
   var re = /\/{1}/;
   var index = sURL.search(re);   
   var sName = new String();
   
   if (index >= 0 || index < sURL.length)
   {
      sName = sURL.substring(index);
   }
   else
   {
      sName = '/';
   }
   
   return sName;
   
}


/*
   queryString
*/
function queryString(win)
{
	if (arguments.length == 0) win = window;
	
   var sURL = new String(win.document.location.href.slice(7));
   var re = /\?{1}/;
   var index = sURL.search(re);   
   var sName = new String();
   
   if (index >= 0 || index < sURL.length)
   {
      sName = sURL.substring(index + 1);
   }
   else
   {
      sName = '';
   }
   
   return sName;
   
}

/*
   fileName
*/
function fileName()
{
   var sURL = new String(document.location.href.slice(7));
   var re = /\/[^\/]*$/;
   var index = sURL.search(re);

   if (index >= 0 || (index + 1) < sURL.length)
   {
      sName = sURL.substring(index);
   }
   else
   {
      sName = '';
   }
   
   return sName;
   
}


/*
   pathName
*/
function pathName()
{
   var sURL = new String(document.location.href.slice(7));
   var re = /\/{1}/;
   var index = sURL.search(re);
   var sName = new String();
   
   if (index >= 0 || (index) < sURL.length)
   {
      sName = sURL.substring(index);
   }
   else
   {
      sName = '';
   }

   re = /\/[^\/]*$/;
   index = sName.search(re);

   if (index >= 0 || (index + 1) < sName.length)
   {
      sName = sName.substring(0, index + 1);
   }

   return sName;
   
}


/*
   lastDay
*/
function lastDay(nMonth, year)
{
   var dayArray = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
   
   if (nMonth == 1)
   {
      if ((year % 4) == 0)
      {
         if (((year % 100) != 0) || ((year % 400) == 0))
         {
            return dayArray[nMonth] + 1;
         }
      }
   }
   return dayArray[nMonth];
}



/*
   AboutBox
*/
function AboutBox()
{
	var sOptions = "center:yes;status:no;dialogHeight:340px;dialogWidth:400px;resizable:no;";
	
	vRetVal = window.showModalDialog("/about.asp", null, sOptions);	
	
}

function validateForm(oForm)
{
	var bValid = true;
	var lIndex = 0;
	var elem = null;

	for (lIndex = 0; lIndex < oForm.elements.length; lIndex++)
	{
		elem = oForm.elements.item(lIndex);
		try {
			if (elem.required == '1') {
				if (elem.value == '' || elem.value == null) {				
					ShowPopup(elem.title + ' is required.', jsOKOnly | jsCritical, 'Validation Error');
					bValid = false;
					break;
				}
			}		
		}
		catch(e) {alert(e.description)}
	}
	
	window.event.returnValue = bValid;
}

function formatNumber(num, decimalNum, bolLeadingZero, bolParens,bolCommas)
{
	//	JavaScript Functions Written by:
	//		Scott Mitchell
	//		mitchell@4guysfromrolla.com
	//		http://www.4GuysFromRolla.com
	
	if (isNaN(parseInt(num))) return "NaN";
	
	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;	//Get sign of number

	
	// Adjust number so only the specified number of number after
	// the decimal point are shown.
	tmpNum *=Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum));
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *=iSign;		//Readjust for sign
	
	//create a string object to do our formatting on
	var tmpNumStr = new String(tmpNum);
	
	// See if we need to strip out the leading zero or not
	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1, tmpNumStr.length);
		else
			tmpNumStr = "-" + tmpNumStr.substring(2, tmpNumStr.length);
	
	// See if we need to put in the commas
	if (bolCommas && num >=1000 || num <= -1000) {
		var iStart = tmpNumStr.indexOf(".");
		if (iStart < 0)
		{
			iStart = tmpNumStr.length;
		}			
		iStart -=3;
		if (num < 0)
		{
			while (iStart >1) {
				tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart, tmpNumStr.length)
				iStart -=3;
			}
		}	
		else
		{
			while (iStart >=1) {
				tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart, tmpNumStr.length)
				iStart -=3;
			}
		}	
	}
	
	// See if we need to use parenthesis
	if (num < 0)
	{
		if (Boolean(bolParens))
		{
		//alert(bolParens)
			tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";
		}
	}		
	return tmpNumStr;	// Return the formatted string					 
}



//-->