
//isMac = ( navigator.appVersion.indexOf( "Mac" )!=-1 ) ? 1 : 0;
//NS4 = ( document.layers ) ? 1 : 0;
//IE4 = ( document.all && !isMac ) ? 1 : 0;
//ver4 = ( NS4 || IE4 ) ? 1 : 0;


function check_digits(pFd)
{
  if (!isDigits(pFd.value))
    {
        alert("Please enter digits in field.");

        pFd.focus();
        pFd.select();
        return false;
    }
    return true;
}

//-----------------------------------------------------------------------
// Generic JavaScript Function:		check_money_format(pAmtFd)
// Description: set money field's default
//
//-----------------------------------------------------------------------
function check_money_format(pAmtFd)
{
  var pAmt = pAmtFd.value;

  if (pAmt.indexOf("-") >= 0)
  {
    alert("Enter full dollar amount with no signs.");
    pAmtFd.value = "0.00";
    pAmtFd.focus();
    pAmtFd.select();
    return false;
  }
  else if (!isDigits(removeChar(pAmt, ".")))
  {
    //alert("Please enter a number in money field.");
    alert("Only numeric and decimal point values accepted in $ fields");
    pAmtFd.value = "0.00";
    pAmtFd.focus();
//    pAmtFd.select();
    return false;
  }
  else
  {
    pAmtFd.value = money_format(pAmt);
  }

  return true;
}

function money_format(pAmt)
{
    var retVal = "0.00";

    if (isDigits(removeChar(pAmt, ".")))
    {
	if (pAmt.length == 0)
	{
		pAmt = "0.00";
	}else if (pAmt.indexOf(".") < 0)
	{
		pAmt += ".00";
	}else if (pAmt.indexOf(".") == 0)
	{
		pAmt = "0" + pAmt;
	}
	retVal = formatToDecimal(pAmt,2);
    }

    return retVal;
}
//-----------------------------------------------------------------------
// Generic JavaScript Function:		pq_header(pStr, pWidth)
// Description:
//
//-----------------------------------------------------------------------
function pq_header(pStr, pWidth)
{
	var strTmp = "";

	strTmp = "<table class=bg border=1  cellspacing=0 cellpadding=0 width='"+pWidth+"' >";

	strTmp += "<tr><td class=header height='30' align='center' valign='middle'>";
	strTmp += pStr+"</td></tr></table>";

	return strTmp;
}
//-----------------------------------------------------------------------
// Generic JavaScript Function:		showAlert(pStr)
// Description: alert a message
//
//-----------------------------------------------------------------------
function showAlert(pStr)
{
	alert(pStr);
}
//-----------------------------------------------------------------------
// Generic JavaScript Function:		checkLength( pLength, pTextArea )
// Description: check a textarea word count within its limit
//
//-----------------------------------------------------------------------
function checkLength( pLength, pTextArea )
{
  if( pTextArea.value.length > pLength )
  {
    alert(
      " Please keep the length of this field to " + pLength +
      " or fewer characters. This field will be truncated to " +pLength+" characters now." );

    pTextArea.value = pTextArea.value.substring( 0, pLength );
  }
}
//-----------------------------------------------------------------------
// Special JavaScript Function:		pq_calc_total(pFormName)
// Description: balancing between employee and visa amount
//		to calculate the total amount
//-----------------------------------------------------------------------
function pq_calc_total(pFormName)
{
	//var totalAmt = eval(pFormName.afTotalAmount.value);

	if(pFormName.visaAmount.value.indexOf(".") == 0 && pFormName.visaAmount.value.length < 1) return;
	if(pFormName.employeeAmount.value.indexOf(".") == 0 && pFormName.employeeAmount.value.length < 1) return;
	var totalAmt  = (eval(pFormName.visaAmount.value)+eval(pFormName.employeeAmount.value));
	pFormName.totalAmount.value = formatToDecimal(totalAmt,2);

	//pFormName.employeeAmount.value = totalAmt -
	//return totalAmt;
}
//-----------------------------------------------------------------------
// Special JavaScript Function:		pq_calc_visa(pFormName)
// Description: balancing between employee and visa amount
//
//-----------------------------------------------------------------------
function pq_calc_visa(pFormName)
{
	var empAmt = pFormName.employeeAmount.value;
	if(isNaN(empAmt)) return;
	if(empAmt.charAt(0) == "0" && empAmt.charAt(1) == "0")return;
	var Amt  = (eval(pFormName.totalAmount.value) - eval(empAmt));
	pFormName.visaAmount.value = formatToDecimal(Amt,2);

	//pFormName.employeeAmount.value = totalAmt -
	//return totalAmt;
}
//-----------------------------------------------------------------------
// Special JavaScript Function:		pq_calc_employee(pFormName)
// Description: balancing between employee and visa amount
//
//-----------------------------------------------------------------------
function pq_calc_employee(pFormName)
{
	var visaAmt = pFormName.visaAmount.value;
	if(isNaN(visaAmt)) return;
	if(visaAmt.charAt(0) == "0" && visaAmt.charAt(1) == "0")return;

	var Amt  = (eval(pFormName.totalAmount.value) - eval(visaAmt));
	pFormName.employeeAmount.value = formatToDecimal(Amt,2);


}
//-----------------------------------------------------------------------
// Special JavaScript Function:	   payee_post(pFormName, pVendorID, pFwdType)
// Description: set hidden fields values of vendorID and FwdType
//
//-----------------------------------------------------------------------
function payee_post(pFormName, pVendorID, pFwdType)
{
	//alert(pVendorID+"<---->"+pFwdType);
	//pFormName.payeeReset.value = pReset;

	pFormName.vendorID.value = pVendorID;
	//alert("vendor id: "+pFormName.vendorID.value);
	pFormName.fwdType.value = pFwdType;

	//pFormName.vendorTaxIDExemptReason = pReason;
	//alert(pVendorID+"----"+pFwdType);
	//pFormName.submit();

}
//-----------------------------------------------------------------------
// Generic JavaScript Function:		payee_check_search(pFormName)
// Description: validation of payee search form
//
//-----------------------------------------------------------------------
function payee_check_search(pFormName)
{
	var id = "";
	var name = "";
	var ret ="false";

	id = pFormName.vendorID.value;
	name = pFormName.vendorName.value;


	if (id == "" && name == "")
	{
		alert("Please provide ID or Vendor Name to narrow your search.");

	} else
	{
		ret= "true";
	}
	return ret;
}
//-----------------------------------------------------------------------
// Generic JavaScript Function:		calc_af_total(pFormName)
// Description: calculate the total amount of all account fund lines
//
//-----------------------------------------------------------------------
function calc_af_total(pFormName)
{
	var total_amt = 0.0;
	var fName = "";
	for (var i=1; i< 50; i++)
	{
	    isign = 1;
            //amount field name
            fName = "afAmount" + i + "Req";
            //debit/credit field name
            dcName = "afDCFlag" + i;
            if(pFormName.elements[fName] == null) break;
            if(pFormName.elements[fName].value != "0.00" )
            {
                if(pFormName.elements[dcName].value == "C") isign = (-1) * isign;
                total_amt += isign * parseFloat(pFormName.elements[fName].value);
            }
	}

	pFormName.afTotalAmount.value = formatToDecimal(total_amt, 2);

	return total_amt;

}

//-----------------------------------------------------------------------
// Generic JavaScript Function:		check_must_fields(pFormName)
// Description: check at least required fields for form saving
//
//-----------------------------------------------------------------------

function pq_check_must_have_fields(pFormName)
{
	var strValue = "";

	if (pFormName.vendorNameReq.value.length == 0)
	{
		alert("Please select Payee.");
		return 1;
	}else if ((trimBlanks(pFormName.zipReq.value) == ""||
		!isDigits(trimBlanks(pFormName.zipReq.value)))&& ((pFormName.country.value == "USA")))
	{
		alert("Please enter payee zip code .");
		pFormName.NewPayee.focus();
		return 1;
	}

	return 0;

}

//-----------------------------------------------------------------------
// Generic JavaScript Function:		check_reqd_fields(pFormName)
// Description: check all required fields
//
//-----------------------------------------------------------------------
function check_reqd_fields(pForm)
{
	var fName = "";
	var strValue = "";

	var formCode = "";
	var formSubCode = "";

	formCode = pForm.formCode.value;
	formSubCode = pForm.formSubCode.value;
	//alert("form sub code: "+formSubCode);

	for (var i=0; i< pForm.elements.length; i++)
	{
            fName = pForm.elements[i].name;
            fType = pForm.elements[i].type;
            if(fType.indexOf("hidden") >= 0) continue;
            strValue = pForm.elements[i].value;
            strValue = trimBlanks(strValue);
            //check for account fund page req'd fields
             if(pForm.name.indexOf("pqAccountFund") >= 0)
            {
                //general account fund handling form
                //check any account fund line for completeness
                if(fName.indexOf("afAmount") >= 0)
                {
                    var hasFilledValue = false;
                    var hasEmptyValue = false;
                    var reqFieldIndex = i;
                    for (var j=0; j<9; j++)
                    {
                        //if(j == 2) continue;
                        k = i - j + 2;
                        row_fName = pForm.elements[k].name;
			if(j == 8 && row_fName.indexOf("Account") < 0)
			{
				k = i - 8;
				row_fName = pForm.elements[k].name;
                        }
                        row_fType = pForm.elements[k].type;
                        if(row_fType.indexOf("hidden") >= 0) continue;
                        if(row_fName.indexOf("Req") < 2) continue;
                        row_fValue = trimBlanks(pForm.elements[k].value);
                        if(k == i)
                        {
                            if(row_fValue == "0.00")
                            {
                                hasEmptyValue = true;
                                reqFieldIndex = k;
                            }else
                            {
                                hasFilledValue = true;
                            }
                        }else
                        {
                            if(row_fValue.length > 0)
                            {
                                hasFilledValue = true;
                            }else{
                                hasEmptyValue = true;
                                reqFieldIndex = k;
                            }
                        }
                    }
                    if(hasFilledValue && hasEmptyValue)
                    {
                        alert("Please enter required fields.");
                        pForm.elements[reqFieldIndex].focus();
                        pForm.elements[reqFieldIndex].select();
                        return false;
                    }
                }
                if(fName.indexOf("afAmount") >= 0 && !isDigits(removeChar(strValue, ".")))
                {
                    alert("Please enter number in money field.");
                    pForm.elements[i].focus();
                    pForm.elements[i].select();
                    return false;
                }else if(fName.indexOf("afDate") >= 0)
                {

                    if((pForm.elements[i-8].value.length > 0 && pForm.elements[i-7].value.length > 0 &&
                        pForm.elements[i-5].value.length > 0 && pForm.elements[i-4].value.length > 0 &&
                        pForm.elements[i-2].value.length > 0) && !isValidDate(pForm.elements[i]))
                    {
                        alert("Enter a date in mm/dd/yyyy format.");
                        pForm.elements[i].focus();
                        pForm.elements[i].select();
                        return false;
                    }else if( isFutureDate(pForm.elements[i]) && formCode != 'RG' && formSubCode!="AP" )
                    {
                            alert("Invalid future date entered. ");
                           
                            pForm.elements[i].focus();
                            pForm.elements[i].select();
                            return false;
                    }
                }
            //the following check for pq form req'd field
            }else if(fName.indexOf("Req")>0)
            {
                if(fName.indexOf("Date") > 0)
                {
                     //alert("datefiled: "+pForm.elements[i].value);
                    if(!isValidDate(pForm.elements[i]))
                    {
                        alert("Enter a date in mm/dd/yyyy format.");
                        pForm.elements[i].focus();
                        pForm.elements[i].select();
                        return false;
                    }else if( isFutureDate(pForm.elements[i]) && formCode != 'RG' && formSubCode!="AP")
                    {
                        alert("Invalid future date entered.");
                        pForm.elements[i].focus();
                        pForm.elements[i].select();
                        return false;
                    }
                }else if(fName.indexOf("afAmount") >= 0 )
                {
                    if (!isDigits(removeChar(strValue, ".")))
                    {
                        alert("Please enter number in money field.");
                        pForm.elements[i].focus();
                        pForm.elements[i].select();
                        return false;
                    }else if (parseFloat(strValue) < 0.001)
                    {
                        alert("Please enter Account Fund amount.");
                        pForm.elements[i].focus();
                        pForm.elements[i].select();
                        return false;
                    }
                }else if(fName.indexOf("afAccount") >= 0 )
                {
                    if (strValue.length == 0)
                    {
                        alert("Please enter Account Code.");
                        pForm.elements[i].focus();
                        pForm.elements[i].select();
                        return false;
                    }
                }else if(fName.indexOf("afFund") >= 0 )
                {
                    if (strValue.length == 0)
                    {
                        alert("Please enter Fund Code.");
                        pForm.elements[i].focus();
                        pForm.elements[i].select();
                        return false;
                    }
                }else if(fName.indexOf("afSub") >= 0 )
                {
                    if (strValue.length == 0)
                    {
                        alert("Please enter Sub Code.");
                        pForm.elements[i].focus();
                        pForm.elements[i].select();
                        return false;
                    }
                } else if(fName.indexOf("afObject") >= 0 )
                {
                    if (strValue.length == 0)
                    {
                        alert("Please enter Object Code.");
                        pForm.elements[i].focus();
                        pForm.elements[i].select();
                        return false;
                    }
                }else
                {
                        if(strValue.length == 0)
                        {
                            alert("Please complete this Required Field");
                            pForm.elements[i].focus();
                            pForm.elements[i].select();
                            return false;
                        }
                 }
            }else if(fName.indexOf("visaAmount") >= 0)
            {
                //check if any credit entered for Debit total
                if(!(eval(pForm.totalAmount.value) < 0))
                {
                    pForm.visaAmount.value = money_format(pForm.visaAmount.value);
                    pForm.employeeAmount.value = money_format(pForm.employeeAmount.value);
                }
                var strTmp="";
                var amtTmp = 0.00;
                amtTmp = eval(pForm.visaAmount.value) + eval(pForm.employeeAmount.value);
                strTmp = "This Payee has a UCI Corporate Visa Card.\n";
                strTmp = strTmp + "Please Enter Pay UCI Corporate Visa amount and/or\n";
                strTmp = strTmp + "Pay Employee amount. These amounts must equal\n";
                strTmp = strTmp + "the Total Amount in the Payment Distribution section.";
		diff = Math.abs(amtTmp) - Math.abs(eval(pForm.totalAmount.value));
                if (Math.abs(diff) > 0.005)
                {
                    alert(strTmp);
                    pForm.elements[i].focus();
                    pForm.elements[i].select();
                    return false;
                 }
            }
            else if (fName.indexOf("checkDueDate") >= 0)
            {
               if (!isFutureDate(pForm.elements[i]))
               {
                  alert("Please enter future Payment Date");
                  pForm.elements[i].focus();
                  pForm.elements[i].select();
                  return false;
               }
            }
	}

	return true;
}


//-----------------------------------------------------------------------
// Generic JavaScript Function:		openWindow( pURL, x, y, pIsMenuShown )
// Description: open a child window with history
//
//-----------------------------------------------------------------------
function openWindow( pURL, x, y, pIsMenuShown )
{
  if( x == null )
    x = 750;

  if( y == null )
    y = 525;

  if( pIsMenuShown == null || pIsMenuShown != "yes" )
    pIsMenuShown = "no";

  if( window.BLISSWindow && !BLISSWindow.closed )
  {
    BLISSWindow.location = pURL;
    BLISSWindow.focus();
    window.BLISSWindow.opener = this;
  }
  else
  {
    windowConstraints = "toolbar=no,location=no,directories=no,status=yes" +
      ",menubar=" + pIsMenuShown +
      ",scrollbars=yes" +
      ",resizable=" + pIsMenuShown +
      ",width=" + x + ",height=" + y;

    BLISSWindow = window.open( pURL, "BLISSWindow", windowConstraints );
    BLISSWindow.moveTo( 17, 17 );
  }
}
//-----------------------------------------------------------------------
// Generic JavaScript Function:		openPQWindow( pURL)
// Description: open a child window without history
//
//-----------------------------------------------------------------------
function openPQWindow( pURL)
{

  if( window.PQWindow && !PQWindow.closed )
  {
    PQWindow.location.replace(pURL);
    PQWindow.focus();
    window.PQWindow.opener = this;
  }
  else
  {
    windowConstraints = "toolbar=yes,location=no,directories=no,status=yes" +
  ",menubar=yes" +
  ",scrollbars=yes" +
  ",resizable= yes" +
  ",width=850"  + ",height=525" ;

    PQWindow = window.open( pURL, "PQWindow" ,windowConstraints);
  }
}

//-----------------------------------------------------------------------
// Generic JavaScript Function:		closePQWindow( pURL)
// Description: open a child window without history
//
//-----------------------------------------------------------------------
function closePQWindow()
{
  if( window.PQWindow && !PQWindow.closed )
  {
    PQWindow.close();
  }
}
//-----------------------------------------------------------------------
// Generic JavaScript Function:		openPQPrintWindow( pURL)
// Description: open a child print window without history
//
//-----------------------------------------------------------------------
function openPQPrintWindow( pURL)
{

  if( window.PQPrintWindow && !PQPrintWindow.closed )
  {
    PQPrintWindow.location.replace(pURL);
    //PQPrintWindow.refresh();
    PQPrintWindow.focus();
    window.PQPrintWindow.opener = this;
  }
  else
  {

    	x = 850;
    	y = 525;

        windowConstraints = "toolbar=no,location=no,directories=no,status=yes" +
                            ",scrollbars=yes" +
                            ",resizable=yes" +
                            ",width=" + x + ",height=" + y;

        PQPrintWindow = window.open( pURL, "PQPrintWindow" , windowConstraints);
  }
}
//-----------------------------------------------------------------------
// Generic JavaScript Function:		openPQHelpWindow( pURL)
// Description: open a child help window (with history)
//
//-----------------------------------------------------------------------
function openPQHelpWindow( pURL)
{

  if( window.PQHelpWindow && !PQHelpWindow.closed )
  {
    PQHelpWindow.location = pURL;
    PQHelpWindow.focus();
    //PQHelpWindow.refresh();
    window.PQHelpWindow.opener = this;
  }
  else
  {
    x = 850;
    y = 525;

    windowConstraints = "toolbar=no,location=no,directories=no,status=yes" +
                        ",scrollbars=yes" +
			",resizable=yes" +
                        ",width=" + x + ",height=" + y;
    PQHelpWindow = window.open( pURL, "PQHelpWindow" , windowConstraints);
  }
}

//-----------------------------------------------------------------------
// Generic JavaScript Function:		openPQInfoWindow( pURL)
// Description: open a child Info window (with menu bar shown)
//
//-----------------------------------------------------------------------
function openPQInfoWindow( pURL)
{

  if( window.PQInfoWindow && !PQInfoWindow.closed )
  {
    PQInfoWindow.location = pURL;
    PQInfoWindow.focus();
    //PQHelpWindow.refresh();
    window.PQInfoWindow.opener = this;
  }
  else
  {
    x = 850;
    y = 525;

    windowConstraints = "toolbar=yes,location=yes,directories=yes,status=yes" +
                        ",scrollbars=yes" +
                        ",resizable=yes" +
                        ",width=" + x + ",height=" + y;
    PQInfoWindow = window.open( pURL, "PQInfoWindow" , windowConstraints);
  }
}

//-----------------------------------------------------------------------
// Generic JavaScript Function:		openPQImageWindow( pURL)
// Description: open a child image window (with history)
//
//-----------------------------------------------------------------------
function openPQImageWindow( pURL)
{

  if( window.PQImageWindow && !PQImageWindow.closed )
  {
    PQImageWindow.location = pURL;
    PQImageWindow.focus();
    //PQHelpWindow.refresh();
    window.PQImageWindow.opener = this;
  }
  else
  {
    x = 850;
    y = 525;

    windowConstraints = "toolbar=no,location=no,directories=no,status=yes" +
                        ",scrollbars=yes" +
			",resizable=yes" ;
    PQImageWindow = window.open( pURL, "PQImageWindow" , windowConstraints);
  }
}


//-----------------------------------------------------------------------
// Generic JavaScript Function:		openPQSearchWindow( pURL)
// Description: open a child help window (with history)
//
//-----------------------------------------------------------------------
function openPQSearchWindow( pURL)
{

  if( window.PQSearchWindow && !PQSearchWindow.closed )
  {
    PQSearchWindow.location = pURL;
    PQSearchWindow.focus();
    window.PQSearchWindow.opener = this;
  }
  else
  {
    x = 600;
    y = 300;

    windowConstraints = "toolbar=no,location=no,directories=no,status=yes" +
                        ",scrollbars=yes" +
			",resizable=yes" +
                        ",width=" + x + ",height=" + y;
    PQSearchWindow = window.open( pURL, "PQSearchWindow" , windowConstraints);
  }
}

//-----------------------------------------------------------------------
// Special JavaScript Function:		setTotalAmountValue(pForm)
// Description: calculate total amount of account fund lines
//		due to the changes of the first line
//-----------------------------------------------------------------------
function setTotalAmountValue(pForm)
{
	var totalAmt;
	if(pForm.afDCFlag1.value =='C')
	{
            //C: Credit, treat it as negative number
            totalAmt = formatToDecimal((parseFloat(pForm.afPreTotal.value,2) + (-1)*parseFloat(pForm.afAmount1Req.value,2)),2);
	}
	else
	{
            totalAmt = formatToDecimal((parseFloat(pForm.afPreTotal.value) + parseFloat(pForm.afAmount1Req.value)),2);
	}
        pForm.afTotalAmount.value = totalAmt;
        pForm.afTotalDue.value = totalAmt;
        if(pForm.totalAmount != null && pForm.visaAmount != null)
        {
            pForm.totalAmount.value = totalAmt;
            if(parseFloat(totalAmt) < 0)
            {
                if(pForm.visaAmount.type != "hidden")
                {
                    pForm.visaAmount.value = "0.00";
                    pForm.employeeAmount.value = totalAmt;
                    pForm.visaAmount.readOnly = true;
                    pForm.employeeAmount.readOnly = true;
                }
            }else
            {
                if(pForm.visaAmount.type != "hidden" && pForm.visaAmount.readOnly)
                {
                    pForm.visaAmount.value = "0.00";
                    pForm.employeeAmount.value = "0.00";
                    pForm.visaAmount.readOnly = false;
                    pForm.employeeAmount.readOnly = false;
                }
            }
        }
}
//-----------------------------------------------------------------------
// Special JavaScript Function:		check_acctfund(pForm, pField)
// Description: check account number or fund number by applying special business
//              rules for particular forms
//-----------------------------------------------------------------------
function check_acctfund(pForm, pField)
{
	var fundCode ;
	var formCode;
	var fieldName;
	var resultCode = true;

	formCode = pForm.formCode.value;
	fieldName = pField.name;


        if (!check_digits(pField))
        {
          return false;
        }

	if(fieldName.indexOf("Fund") > 0 && formCode != "FN")
	{
               /***   remove the foundation fund check per Lorri % Mandy 1/5/05 jane

		if (pField.value == "69985" || pField.value == "67101")
		{
	            alert("!!! STOP !!!\nProcess Foundation Funds 69985 and 67101 via a Paper Form 5.");

	            pField.focus();
	            pField.select();
	            pField.value= "";

                    resultCode = false;
		} ***/

	} else if(fieldName.indexOf("Account") > 0)
	{
		var firstChar = ""
		firstChar = trimBlanks(pField.value).charAt(0)
		if(formCode == "RF")
		{
			if(firstChar.length != 0 && (firstChar != '1' && firstChar != '2'))
			{
                		alert("Only Balance sheet or Revenue accounts may be used on a Refund.");
				pField.focus();
				pField.select();
				pField.value= "";
				resultCode = false;
			}
		}else
		{
			if(firstChar.length != 0 && (firstChar == '1' || firstChar == '2'))
			{
                		alert("Balance sheet or Revenue accounts may not be used on this form.");
				pField.focus();
				pField.select();
				pField.value= "";
				resultCode = false;
			}
		}
	}

	return resultCode;

}
//-----------------------------------------------------------------------
// Special JavaScript Function:		check af_amount(pForm, pAFamt, pDCFlag)
// Description: check single line of the amount whether exceed the limits.
//
//-----------------------------------------------------------------------
function check_af_amount(pForm, pAFamt, pDCFlag)
{

        if (!check_money_format(pAFamt))
	{
	    return 0;
	}

        var formCode;
        var formSubCode;

        formCode = pForm.formCode.value;
        formSubCode = pForm.formSubCode.value;
        //alert ("amt: "+pAFamt.value);

        // only check Debit amt for SM - Cashier Form whether greater than 100.00
        if (formCode == "SM" && formSubCode == "CC" && pDCFlag == "D")
        {
            if (parseFloat(pAFamt.value) > 100)
            {
              alert("Individual Account/Fund line Amout $"+pAFamt.value+" is greater than $100.00.\n\nPlease correct.\n");
              pAFamt.focus();
              pAFamt.select();
//            pFund.value= "";

              return 0;
            }
        }
}

//-----------------------------------------------------------------------
// Generic JavaScript Function:		tabIndexInit(form)
// Description: re-assign tab index within the given form
//		and apply the font color properties
//-----------------------------------------------------------------------
function tabIndexInit(form)
{
        var MS4 = ((parseInt(navigator.appVersion)>=4)&&(navigator.appName.indexOf("Microsoft")!=-1))? 1:0;
        //var s = "";
        var j = 100;
        if(MS4 == 1)
        {
                for (var i=0; i< form.elements.length; i++)
                {
                   //fName = form.elements[i].name;
                    fType = form.elements[i].type;
                   //s = s + fName + " " + fType + form.elements[i].tabIndex + "\n";
                    if(fType.indexOf("text") >= 0 && form.elements[i].tabIndex >= 0)
                    {
                        form.elements[i].style.color="navy";
                        if(!form.elements[i].readOnly)
                        {
                                form.elements[i].tabIndex = j++;
                        }
                    }else if(fType.indexOf("select") >= 0)
                    {
                        form.elements[i].style.color="navy";
                        //form.elements[i].style.backgroundColor="lightyellow";
                        form.elements[i].tabIndex = j++;
                    }else if(fType.indexOf("button") >= 0 || fType.indexOf("radio") >= 0 || fType.indexOf("submit") >= 0 || fType.indexOf("reset") >= 0)
                    {
                        form.elements[i].tabIndex = j++;
                    }else
                    {
                        form.elements[i].tabIndex = -1;
                    }
                    //s = s + j;
                }
        }else
        {
                for (var i=0; i< form.elements.length; i++)
                {
                   //fName = form.elements[i].name;
                    fType = form.elements[i].type;
                   //s = s + fName + " " + fType + form.elements[i].tabIndex + "\n";
                    if(fType.indexOf("text") >= 0 && form.elements[i].tabIndex >= -1 && form.elements[i].tabIndex != 0)
                    {
                        form.elements[i].style.color="navy";
                        form.elements[i].tabIndex = j++;
                    }else if(fType.indexOf("select") >= 0)
                    {
                        form.elements[i].style.color="navy";
                        //form.elements[i].style.backgroundColor="lightyellow";
                        form.elements[i].tabIndex = j++;
                    }else if(fType.indexOf("button") >= 0 || fType.indexOf("radio") >= 0 || fType.indexOf("submit") >= 0 || fType.indexOf("reset") >= 0)
                    {
                        form.elements[i].tabIndex = j++;
                    }else
                    {
                        form.elements[i].tabIndex = -5;
                    }
                    //s = s + j;
                }
        }
        //alert(s);
}
//-----------------------------------------------------------------------
// Special JavaScript Function:		refreshMainWindow(window)
// Description: "refresh" parent window (if it is still open)
//		by submitting the search action
//-----------------------------------------------------------------------
function refreshMainWindow(window)
{
    if(window.opener == null || window.opener.closed) return;
    if(window.opener.document.title.indexOf("Directory") >= 0)
      window.opener.document.searchForm.submit();
}
//-----------------------------------------------------------------------
// JavaScript Function:		reloadMainWindow(window)
// Description: will reload the directory page once etForm saved
//
//-----------------------------------------------------------------------
function reloadMainWindow(window)
{
        if(window.document.forms[0].fwdURL.value.indexOf("saveIndexFormData") > 0)
        {
          refreshMainWindow(window);
        }
}
//-----------------------------------------------------------------------
// JavaScript Function:		checkViewButton(form)
// Description: enable/disable preview coversheet button to direct user
//		to corresponding pages
//
//-----------------------------------------------------------------------
function checkViewButton(form){
	var s = form.pqID.value;
	if(s.length < 10)
	{
		form.buttonprint.disabled = true;
	}else
	{
		form.buttonprint.disabled = false;
	}
}

