var win;
var win2;
var winind;
var temp;

String.prototype.trim = function() {
  // skip leading and trailing whitespace
  // and return everything in between
  return this.replace(/^\s*(\b.*\b|)\s*$/, "$1");
}

function isInteger(s) {
return (s.toString().search(/^-?[0-9]+$/) == 0);
}

function isNumber(s) {
 return(!isNaN(s*1))
}

function SetSelect(HTMLName, Name,Row,Column,Select)
{
   document.LANSA._SELECT.value=Select;
   SetNameLocation(Name,Row,Column);
   document.LANSA._CALFLD.value=HTMLName;
}

function SetNameLocation(Name,Row,Column)
{
   document.LANSA._NAME.value=Name;
   document.LANSA._ROW.value=Row;
   document.LANSA._COLUMN.value=Column;
   document.LANSA._CALFLD.value=Name;
}

function CallCalendar()
{
   if (document.LANSA._CALFLD.value != "&NULL")
   {
      var opt = "width=340,height=385,directories=no,toolbar=no,";
      opt += "menubar=no,scrollbars=no,resizable=yes";
      htm = document.LANSA.KPIIMAGES.value + "lcalen.htm"
      win = window.open(htm, "calendar", opt);
      win.opener=window;
   }
}

function SetDate(day, month, year)
{
   var Field=document.LANSA._CALFLD.value;

   if (year < 2000)
   {
    YearRet=year-1900;
   }
   else
   {
   YearRet=year-2000;
   }

   if (day < 10)
   {
    DayRet= "0" +day;
   }
   else
   {
    DayRet= day;
   }

   if (month < 10)
   {
    var RDate="0"+month+"/"+DayRet+"/";
   }
   else
   {
    var RDate=month+"/"+DayRet+"/";
   }

   if (YearRet<10)
     RDate+="0"+YearRet;
   else
     RDate+=YearRet;

   if (document.LANSA.ZOTHFRM.value != '')
    document[document.LANSA.ZOTHFRM.value][Field].value=RDate;
   else
    document.LANSA[Field].value=RDate;
}

function isValidNumeric(theObj, integers,decimals,decimalPoint)
{
   var FieldValue = theObj.value;
   var returnString = "";
   var befdecCount = 0;
   var PastDec = false;
   var aftdecCount = 0;
   for (var i = 0; i < FieldValue.length; i++)
   {
      if (isDigit(FieldValue.charAt(i)))
      {
         if (PastDec)
         {
            aftdecCount++
            if (aftdecCount <= decimals)
               returnString += FieldValue.charAt(i)
         }
         else
         {
            befdecCount++
            if (befdecCount <= integers)
               returnString += FieldValue.charAt(i)
         }
      }
      else
      {
         if (FieldValue.charAt(i) == decimalPoint)
            PastDec = true
         returnString += FieldValue.charAt(i);
      }
   }
   if ((befdecCount > integers) || (aftdecCount > decimals))
   {
      alert("Allowable digits before decimal point = " + integers +
              "\nAllowable digits after decimal point = " + decimals +
              "\nData will be truncated accordingly.")
      theObj.value = returnString
         return false
   }
   return true
}

function isDigit(theDigit)
{
   digitArray = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')
   for (var j = 0; j < digitArray.length; j++)
      if (theDigit == digitArray[j])
         return true
   return false
}

function SetFocus()
{
   if ( document.LANSA.SA_NOFOCU.value == 'Y' )
    return

   var NumElements=document.LANSA.elements.length;

   for (i=0; i<NumElements;i++)
   {
      if (document.LANSA.elements[i].type=="select-one"	||
          document.LANSA.elements[i].type=="checkbox"	||
          document.LANSA.elements[i].type=="radio"	||
          document.LANSA.elements[i].type=="textarea"	||
          document.LANSA.elements[i].type=="file"	||
          document.LANSA.elements[i].type=="text")
      {
      if ( (document.LANSA.elements[i].disabled!=true) && (document.LANSA.elements[i].name!='ZDUMMY') )
         {  
         document.LANSA.elements[i].focus();
         break;
         }
      }
   }
}

function preload(imgObj,imgSrc)
{
   if (document.images)
   {
      eval(imgObj+' = new Image()');
      eval(imgObj+'.src = "'+imgSrc+'"');
   }
}

function changeImage(layer,imgObj, imgName)
{
   if (document.images)
   {
      if (document.layers && layer!=null)
         eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src');
      else
         document.images[imgName].src = eval(imgObj+".src");
   }
}

function CheckNUpdate(Fld, Value)
{
   var NumElements=document.LANSA.elements.length;

   for (i=0; i<NumElements;i++)
   {
      if (document.LANSA.elements[i].name==Fld)
      {
         document.LANSA.elements[i].value=Value;
         break;
      }
   }
}

function FieldExists(Fld)
{
   var NumElements=document.LANSA.elements.length;

   for (i=0; i<NumElements;i++)
   {
      if (document.LANSA.elements[i].name==Fld)
         return true;
   }
  return false;
}

function SetState(obj, RFld, chkValue, unchkValue)
{
  if (obj.checked)
     document.LANSA[RFld].value=chkValue;
  else
     document.LANSA[RFld].value=unchkValue;
}

function GetFieldValue(RFld)
{
  var NumElements=document.LANSA.elements.length;

  for (i=0; i<NumElements;i++)
  {
    if (document.LANSA.elements[i].name==RFld)
         return document.LANSA.elements[i].value;
  }
  return null;
}

function SetCBState(obj, RFld, CY, CN)
{
   if (obj.checked)
      document.LANSA[RFld].value=CY;
   else
      document.LANSA[RFld].value=CN;
}

function StartFunction(URL)
{
  var win;
  win=window.open("","TESTFNC");
  if (win != null)
    win.location=URL;
  win.focus();
}

function ECSelect(proc,fun,ECparm)
{
  document.LANSA.action += '+FUNCPARMS+ECPARM(A0500):' + ECparm;
  HandleEvent(proc, fun);
}

function open_window(URL,h,w)
{
if (h == null)
 h = 400;

if (w == null)
 w = 650;

window.open(URL,"newWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=" + w + ",height=" + h + "");
}

function SPP(Proc,Func,FieldName1,FieldValue1,FieldName2,FieldValue2,height,width,ParmFieldName3,RowFieldName3,ParmFieldName4,RowFieldName4,ParmFieldName5,RowFieldName5,ParmFieldName6,RowFieldName6) {
ParmFieldValue3 = GetRowFieldValue(FieldValue2,RowFieldName3);
ParmFieldValue4 = GetRowFieldValue(FieldValue2,RowFieldName4);
ParmFieldValue5 = GetRowFieldValue(FieldValue2,RowFieldName5);
ParmFieldValue6 = GetRowFieldValue(FieldValue2,RowFieldName6);
 
ShowPartial('',Proc,Func,'INITIAL',FieldName1,FieldValue1,FieldName2,FieldValue2,height,width,ParmFieldName3,ParmFieldValue3,ParmFieldName4,ParmFieldValue4,ParmFieldName5,ParmFieldValue5,ParmFieldName6,ParmFieldValue6);
}

function GetRowFieldValue(Row,RowFieldName)  {
if (RowFieldName != null) {
 Field = '__' + RowFieldName + ' -' + Row + ' D';
 return document.LANSA[Field].value;
 }
 else
  return null;
}

function ShowPartial(FldName,Proc,Func,WebKey,FieldName1,FieldValue1,FieldName2,FieldValue2,height,width,FieldName3,FieldValue3,FieldName4,FieldValue4,FieldName5,FieldValue5,FieldName6,FieldValue6) {
if (window.name == 'win') {
 ShowPartial2(FldName,Proc,Func,WebKey,FieldName1,FieldValue1,FieldName2,FieldValue2,height,width);
 return;
}

savetarget = document.LANSA.target;
CloseNewWindow();
if ((WebKey == 'INITIAL') || (WebKey == 'PROMPT')) {
 if (FieldName1 == 'AKPIMFGNUM') 
   document.LANSA.AKPIMFGNUM.value=FieldValue1;
 else
   if (document.LANSA[FieldName1])
    document.LANSA[FieldName1].value = FieldValue1;

 if (FieldName2 == 'PPRTINFCNT') 
  document.LANSA.PPRTINFCNT.value=FieldValue2;
  else
   if (FieldName2 == 'AMFGSVCNUM') 
    document.LANSA.AMFGSVCNUM.value=FieldValue2;
   else   
    if (FieldName2 == 'AFF_COMPRD') 
     document.LANSA.AFF_COMPRD.value=FieldValue2;
    else
     if (document.LANSA[FieldName2])
      document.LANSA[FieldName2].value = FieldValue2;   
	  
 if (document.LANSA[FieldName3])
   document.LANSA[FieldName3].value = FieldValue3;
   
 if (document.LANSA[FieldName4])
   document.LANSA[FieldName4].value = FieldValue4;
   
 if (document.LANSA[FieldName5])
   document.LANSA[FieldName5].value = FieldValue5;
 
 if (document.LANSA[FieldName6])
   document.LANSA[FieldName6].value = FieldValue6;
}

 document.LANSA.AXFLD.value = FldName;

 if ( height == null )
   height=475;

 if ( width == null )
   width=550;

 win = window.open('',"win","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+width+",height="+height+",alwaysRaised=1");

 document.LANSA.target = 'win';

 document.LANSA.AWEBKEY.value=WebKey;
 HandleEvent(Proc,Func)
 if (window.focus) {win.focus()};
  document.LANSA.target = savetarget;
}

function OpenWindow(FldName,Proc,Func,WebKey,FieldName1,FieldValue1,FieldName2,FieldValue2,Width,Height)
{

 if ( Height == null )
   Height=475;

 savetarget = document.LANSA.target;
 CloseNewWindow();

 document.LANSA.AXFLD.value = FldName;

 win = window.open('',"win","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=" + Width + ",height=" + Height + ",alwaysRaised=1"); 

 document.LANSA.target = 'win';

 document.LANSA.AWEBKEY.value=WebKey;
 HandleEvent(Proc,Func)
 if (window.focus) {win.focus()};
  document.LANSA.target = savetarget;
}

function OpenWindow2(FldName,Proc,Func,WebKey,FieldName1,FieldValue1,FieldName2,FieldValue2,Width,Height)
{

 if ( Height == null )
   Height=475;

 savetarget = document.LANSA.target;
 CloseNewWindow2();
 win2 = window.open('',"win2","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=" + Width + ",height=" + Height + ",alwaysRaised=1"); 

 document.LANSA.target = 'win2';

 document.LANSA.AWEBKEY.value=WebKey;
 HandleEvent(Proc,Func)
 if (window.focus) {win2.focus()};
  document.LANSA.target = savetarget;
}

function OpenWindowWebTerm(FldName,SESSSN,Proc,Func,WebKey,FieldName1,FieldValue1,FieldName2,FieldValue2,Width,Height)
{
 mywindow = window.open('','HDPRTL','menubar=no,toolbar=yes,scrollbars=yes,status=yes,hotkeys=no,titlebar=no');
 mywindow.titlebar=false;
 mywindow.resizeTo(screen.availWidth,screen.availHeight);
 mywindow.moveTo(0,0);
 mywindow.location.href = '/CGI-BIN/LANSAWEB?PROCFUN+KPICALPR01+CTRENTF+DEV+ENG+FUNCPARMS+SESSSN(A0240):' + SESSSN ;
}

function OpenWindowSecure(FldName,Proc,Func,WebKey,FieldName1,FieldValue1,FieldName2,FieldValue2,Width,Height)
{
 if ( Height == null )
   Height=475;

 savetarget = document.LANSA.target;
 saveaction = document.LANSA.action;
 CloseNewWindow();
 win = window.open('',"win","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=" + Width + ",height=" + Height + ",alwaysRaised=1"); 

 document.LANSA.target = 'win';

 s=document.LANSA.action;
 pos=s.search(location.hostname);

 if (pos > -1)
  action = s.substring(pos+location.hostname.length); 
 else
  action = s; 

 document.LANSA.action = 'https://' + location.hostname + action;

 document.LANSA.AWEBKEY.value=WebKey;
 HandleEvent(Proc,Func)
 if (window.focus) {win.focus()};
  document.LANSA.target = savetarget;
  document.LANSA.action = saveaction;
}

function ShowPartial2(FldName,Proc,Func,WebKey,FieldName1,FieldValue1,FieldName2,FieldValue2,height,width)
{
savetarget = document.LANSA.target;
CloseNewWindow2();
if (WebKey == 'INITIAL'){
 if (FieldName1 == 'AKPIMFGNUM') {
   document.LANSA.AKPIMFGNUM.value=FieldValue1;
 }
}
 document.LANSA.AXFLD.value = FldName;

 if ( height == null )
   height=475;

 if ( width == null )
   width=550;
 
 win2 = window.open('',"win2","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+width+",height="+height+",alwaysRaised=1");

 document.LANSA.target = 'win2';

 document.LANSA.AWEBKEY.value=WebKey;
 HandleEvent(Proc,Func)
 if (window.focus) {win2.focus()};
  document.LANSA.target = savetarget;
}

function ShowCall(FldName,Proc,Func,WebKey)
{
savetarget = document.LANSA.target;
CloseNewWindow();
 win = window.open('',"win","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=652,height=475,alwaysRaised=1");

 document.LANSA.target = 'win';

 document.LANSA.AWEBKEY.value=WebKey;
 HandleEvent(Proc,Func)
 if (window.focus) {win.focus()};
  document.LANSA.target = savetarget;
}

function ShowCallWinInd(FldName,Proc,Func,WebKey)
{
savetarget = document.LANSA.target;
 winind = window.open('',"winind","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=652,height=475,alwaysRaised=1");

 document.LANSA.target = 'winind';

 document.LANSA.AWEBKEY.value=WebKey;
 HandleEvent(Proc,Func)
 if (window.focus) {winind.focus()};
  document.LANSA.target = savetarget;
}

function ReturnClaimCust(LastName,FirstName,Address,City,State,Zip,Phone)
{
   window.opener.FillClaimCust(LastName,FirstName,Address,City,State,Zip,Phone);
   window.close();
}

function FillClaimCust(LastName,FirstName,Address,City,State,Zip,Phone)
{
document.LANSA.ACNSLSTNAM.value = LastName;
document.LANSA.ACNSFSTNAM.value = FirstName;
document.LANSA.ACNSADR.value = Address;
document.LANSA.ACNSCTY.value = City;
document.LANSA.ACNSST.value = State;
document.LANSA.ACNSZIP.value = Zip;
document.LANSA.ACNSPHNNUM.value = Phone;
}

function ReturnAddtoCall(Proc,Func,Svc,Loc)
{
   window.close();
   if (CheckForCurrentPageOpener())
   {
    window.opener.document.LANSA.AWEBKEY.value='ADDTOCALL';
    window.opener.document.LANSA.AFF_ASSSVC.value=Svc;
    window.opener.document.LANSA.AFF_ASSLOC.value=Loc;
    OpenerHandleEvent(Proc,Func)
   }
}

function ReturnValues(FieldName1,FieldValue1,FieldName2,FieldValue2,FieldName3,FieldValue3,FieldName4,FieldValue4)
{
ReturnValue(FieldName1,FieldValue1);
ReturnValue(FieldName2,FieldValue2);
ReturnValue(FieldName3,FieldValue3);
ReturnValue(FieldName4,FieldValue4);
}

function ReturnValue(FieldName,FieldValue)
{
if (document.LANSA[FieldName])
   document.LANSA[FieldName].value = FieldValue;
}

function ReturnModel(Rvalue)
{
   window.opener.FillPartial(Rvalue);
   window.close();
}

function ReturnXFLD2(Rvalue,xFld)
{
   window.opener.FillPartial2(Rvalue,xFld);
}

function ReturnDIVFLD(Rvalue,DivFld)
{
   window.opener.FillDIV(Rvalue,DivFld);
}

function ReturnProductCategory(Func,PrdCat,PrdCatDsc)
{
   window.opener.FillPrdCat(Func,PrdCat,PrdCatDsc);
}

function FillPartial(ThisModel) {
if (document.LANSA.ZOTHFRM.value != '')
 document[document.LANSA.ZOTHFRM.value][document.LANSA.AXFLD.value].value = ThisModel;
else
 document.LANSA[document.LANSA.AXFLD.value].value = ThisModel;

if (document.LANSA.AXFLD.value == 'AATHNUM')
  checkAuthNum();
if (document.LANSA.AXFLD.value == 'AWRYCLK')
  checkCallNum();
if ( (document.LANSA.AXFLD.value == 'AMDLNUM') && (document.LANSA._OFUNCTION.value == 'CLMEEC1') )
  document.LANSA.AFF_HMDMDL.value = '';
if (document.LANSA.AXFLD.value == 'AEIACPLCDE')
  document.LANSA.AFF_HMDCPL.value = '';
if (document.LANSA.AXFLD.value == 'AEIARPR001')
  document.LANSA.AFF_HMDRPR.value = '';
}

function FillPartial2(ThisValue,xFld) {
switch(xFld)
{
case 2:
  document.LANSA[document.LANSA.AXFLD2.value].value = ThisValue;
  break;    
case 3:
  document.LANSA[document.LANSA.AXFLD3.value].value = ThisValue;
  break;
case 4:
  document.LANSA[document.LANSA.AXFLD4.value].value = ThisValue;
  break;
default:
  document.LANSA[document.LANSA.AXFLD2.value].value = ThisValue;
} 
}

function FillDIV(ThisValue,DivFld) {
switch(DivFld)
{
case 1:
  document.getElementById(document.LANSA.ADIVID.value).innerHTML = ThisValue;
  break;    
case 2:
  document.getElementById(document.LANSA.ADIVID2.value).innerHTML = ThisValue;
  break;
case 3:
  document.getElementById(document.LANSA.ADIVID3.value).innerHTML = ThisValue;
  break;
default:
  document.getElementById(document.LANSA.ADIVID.value).innerHTML = ThisValue;
} 

}

function FillPrdCat(Func,PrdCat,PrdCatDsc) {
   document.LANSA.AFF_SELPCT.value = PrdCat;
   document.LANSA.LFF_PCTDSC.value = PrdCatDsc;
   if (document.LANSA._OFUNCTION.value == 'CLMEEC1')
   {
    if (document.LANSA.APRDUSGMDL.value == 'Y')
      ProdCatDesc.innerHTML = PrdCatDsc;
    if (document.LANSA.AFF_SHWPCT.value == 'Y')
      ProdCatDescRpr.innerHTML = PrdCatDsc;
    if ( (document.LANSA.SA_FLG04.value != 'H') && (Func != 'MDLW01') && (document.LANSA.AFF_HMDMDL.value != 'Y') )
      document.LANSA.AMDLNUM.value = '';
    if ( (document.LANSA.SA_FLG19.value != 'H') && (Func != 'SYMW01') && (document.LANSA.AFF_HMDCPL.value != 'Y') )
      document.LANSA.AEIACPLCDE.value = '';
    if ( (document.LANSA.SA_FLG21.value != 'H') && (Func != 'RPRW01') && (document.LANSA.AFF_HMDRPR.value != 'Y') )
      document.LANSA.AEIARPR001.value = '';
   }
}

function checkAuthNum() {
if ( (document.LANSA.ACLMBYPCLV.value != 'Y') && (document.LANSA.AATHNUM.value != document.LANSA.AFF_ATHNUM.value) && (document.LANSA.AWRYCLK.value.trim() == '') )
   ClaimHandleEvent('KPIWEBPR01','CLMEEC1','ATHCHG');
}

function checkCallNum() {
if ( document.LANSA.AWRYCLK.value != document.LANSA.AFF_WRYCLK.value )
   ClaimHandleEvent('KPIWEBPR01','CLMEEC1','CALCHG');
}

function onReturnPressed(xevent, Proc, Func,WebKey)
	{
	var keyval = xevent.which;
	var keycod = xevent.keyCode;

	if((keyval == 13) || (keycod == 13)){
		MainDSPHandleEvent(Proc,Func,WebKey);
		}
	return true;
}

function CloseNewWindow() {

  if(win) {
    win.close();
  }
}

function CloseNewWindow2() {

  if(win2) {
    win2.close();
  }
}

function Start(page) {
OpenWin = this.open(page, "CtrlWindow", "toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes");
}

function MainDSPHandleEvent(Proc,Func,WebKey,HttpsSwitch) {
 document.LANSA.ADIVID.value='xxxxxxxxxxx';
 PageHandleEvent(Proc,Func,WebKey,HttpsSwitch);
}

function CheckForCurrentPageHandleEvent(Proc,Func,WebKey,HttpsSwitch) {
 if (CheckForCurrentPage())
  PageHandleEvent(Proc,Func,WebKey,HttpsSwitch); 
}

function PageHandleEvent(Proc,Func,WebKey,HttpsSwitch) {
 CloseNewWindow();
 document.LANSA.AWEBKEY.value=WebKey;

 if (HttpsSwitch == 'Y')
 {
  SetPageAction('Y');
 }
 else
 {
  if ( (document.LANSA.ASA_HTPSTM.value == 'Y') && (document.LANSA._OFUNCTION.value.trim() != Func.trim()) )
  {
   SetPageAction('N');
  }
 }

 HandleEvent(Proc,Func);
}

function SetPageAction(httpsFlag) { 
 s=document.LANSA.action;
 pos=s.search(location.hostname);

 if (pos > -1)
  action = s.substring(pos+location.hostname.length); 
 else
  action = s; 

 if (httpsFlag == 'Y') 
  path = "https://"; 
 else
  path = "http://"; 
 
 if (document.location.port != "")
  path = path + location.hostname + ":" + document.location.port + action; 
 else 
  path = path + location.hostname + action; 

 document.LANSA.action=path; 
} 

function HandleLogoff(Proc,Func,OrgInf)
{
   document.LANSA.LSA_ORGINF.value=OrgInf;
   PageHandleEvent(Proc,Func,'');
}

function SetValue()
{
  var s = document.LANSA.ACLMNUM.value;

  if (s.trim() != '') {
   document.LANSA.LCLMSTSCDE.value=' ';
   document.LANSA.SSA_FR6.value="";
   document.LANSA.SSA_TO6.value="";
  }
}

function SetWebField(Proc,Func,WebKey,FieldName1,FieldValue1,FieldName2,FieldValue2,FieldName3,FieldValue3)
{
  if (WebKey == 'SORTLIST'){
    if (FieldName1 == 'ASA_VIEW') {
      document.LANSA.ASA_VIEW.value=FieldValue1;
    }
  }

  if (WebKey == 'CHKCLM'){
    if (FieldName1 == 'PPERENDDAT') {
      document.LANSA.PPERENDDAT.value=FieldValue1;
    }
  }

  if ( (WebKey == 'SUBMIT') || (WebKey == 'DSPCLM') ) {
   if (FieldName1 == 'AMFGSVCNUM') {
     document.LANSA.AMFGSVCNUM.value=FieldValue1;
   }
   if (FieldName2 == 'ASVCLOCCDE') {
     document.LANSA.ASVCLOCCDE.value=FieldValue2;
   }
   if (FieldName1 == 'PCLMBTHNUM') {
     document.LANSA.PCLMBTHNUM.value=FieldValue1;
   }
   if (FieldName2 == 'PCLMSEQNUM') {
     document.LANSA.PCLMSEQNUM.value=FieldValue2;
   }
   if (FieldName3 == 'ACLMNUM') {
     document.LANSA.ACLMNUM.value=FieldValue3;
   }
  }

  if (WebKey == 'DLT'){
    if (FieldName1 == 'AMFGSVCNUM') {
     document.LANSA.AMFGSVCNUM.value=FieldValue1;
    }
    if (FieldName2 == 'ASVCLOCCDE') {
     document.LANSA.ASVCLOCCDE.value=FieldValue2;
    }
    if (FieldName1 == 'PCLMBTHNUM') {
      document.LANSA.PCLMBTHNUM.value=FieldValue1;
    }
    if (FieldName2 == 'PCLMSEQNUM') {
      document.LANSA.PCLMSEQNUM.value=FieldValue2;
    }
    if (FieldName3 == 'ACLMNUM') {
      document.LANSA.ACLMNUM.value=FieldValue3;
    }
  }

  if (WebKey == 'DELETE'){
    if (FieldName1 == 'PPRTINFCNT') {
      document.LANSA.PPRTINFCNT.value=FieldValue1;
    }
  }

  if (WebKey == 'DELETE'){
    ClaimHandleEvent(Proc,Func,WebKey)
  }
  else {
    document.LANSA.AWEBKEY.value=WebKey;
    HandleEvent(Proc,Func)
  }
}

function SetDD(obj, RFld, Val)
{
   var NumElements=document.LANSA.elements.length;

   for (i=0; i<NumElements;i++)
   {
      if (document.LANSA.elements[i].name==RFld)
      {
          document.LANSA.elements[i].value=this.value;
          break;
      }
   }
}

function SetCBHidden(obj, RFld, CY, CN)
{
if (obj.checked)
  document.LANSA[document.LANSA.RFld.value].value = CY;
else
  document.LANSA[document.LANSA.RFld.value].value = CN;
}
function BuildMultipleValues(obj, RFld, MaxItems, ValueSize)
{
var counter = 0;
document.LANSA[RFld].value = "";
for(var i = 0; i < obj.length; i++)
{
 if ((obj.options[i].selected == true))
 {
  counter++;
  if (counter <= MaxItems)
  {
   var tempfield = obj.options[i].value;
   for (var x = tempfield.length; x < ValueSize; x++)
   {
   tempfield = tempfield + " ";
   }
   document.LANSA[RFld].value = document.LANSA[RFld].value +  tempfield;
  }
 }
}

if (counter > MaxItems)
 alert("You have selected more than " + MaxItems +  " options in this listbox. Only the first " + MaxItems + " entries will be used.");
}

function SetValues(Obj, ValueFld, ItemLength, MaxItems)
{
var beginIndex = 0;
var currFieldValue = document.LANSA[ValueFld].value;
var y = 0;

if (document.LANSA[ValueFld].value != "")
{
 for ( var x=0; x < Number(MaxItems); x++)
 {
  currValue = currFieldValue.substring(y, y+Number(ItemLength)).trim();
  if (currValue != "")
  {
   y = y + Number(ItemLength);
   for (var i=0; i < document.LANSA[Obj].length; i++)
   {
    if (document.LANSA[Obj].options[i].value == currValue)
    {
     document.LANSA[Obj].options[i].selected = true;
    }
   }
  }
 }
}
}

function StartProcessingAnimation() 
{ 
document.images.prcimage.src = "/LANSAIMG/processing_2.gif"; 
} 

function FormInit()
{
if (document.LANSA.SA_URLRDR.value.trim() != '')
{
 location.href=document.LANSA.SA_URLRDR.value;
 return
}

if (document.LANSA.SA_URLPOP.value.trim() != '')
{
 open_window(document.LANSA.SA_URLPOP.value.trim(),document.LANSA.SA_POPHGT.value,document.LANSA.SA_POPWID.value);
 return
}

if ( (document.LANSA._OFUNCTION.value == 'FRSBDY') && (document.LANSA.ASA_PAGRSB.value == 'Y'))
  {
  MainDSPHandleEvent('KPIFRSPR01','FRSBDY','LOADFUNC');
  return
  }

if (document.LANSA.ASA_SHWPRM.value == 'Y')
  {
  MainDSPHandleEvent(document.LANSA.ASA_PRMPRC.value,document.LANSA.ASA_PRMFNC.value,document.LANSA.ASA_PRMOPT.value);
  window.setTimeout("StartProcessingAnimation()", 100); 
  return
  }

if (document.LANSA.ASA_PRTPAG.value == 'Y')
  window.print();

if (document.LANSA.AFF_RCRVEW.value == 'RCRSLTZ')
  SetRecruitCategories();

if (document.LANSA._OFUNCTION.value == 'SVYRPTS')
  SetRegionList();

if (document.LANSA._OFUNCTION.value == 'FMTSVCD')
  SetPrdLinList();

if (document.LANSA._OFUNCTION.value == 'RCRSTS')
{
 if (document.LANSA.ASA_MLDTPR.value != "")
  SetValuesFromList(document.LANSA.ASA_MLDTPR.value,document.LANSA.ASA_MLDHDN.value,document.LANSA.PSA_MLDLCN.value,document.LANSA.SSA_MLDLEN.value,document.LANSA.SSA_MLDMAX.value);

 if (document.LANSA.ASA_MLHTPR.value != "")
  SetValues(document.LANSA.ASA_MLHTPR.value,document.LANSA.ASA_MLHHDN.value,document.LANSA.SSA_MLHLEN.value,document.LANSA.SSA_MLHMAX.value);
}

if (document.LANSA._OFUNCTION.value == 'UPLOADP')
  document.UPLOAD['SA_UPFILE'].focus();
else
  if ( ((document.LANSA._OFUNCTION.value == 'CTCLDSP') && (document.LANSA.AFF_SHWDSP.value == 'Y')) || ((document.LANSA._OFUNCTION.value == 'CTCCVER') && (document.LANSA.LFF_CRICLS.value == 'none')) )
    temp = temp;
  else  
    {
    SetFocus();
    }
	
if ( (document.LANSA._OFUNCTION.value == 'CLMEEC1') && (document.LANSA.ASA_WEBCNT.value == 'CLMEEC1') )
  if ( (document.LANSA.LFF_PCTDSC.value != '') && (document.LANSA.LFF_PCTDSC.value != undefined) )
    {
    if (document.LANSA.APRDUSGMDL.value == 'Y')
      ProdCatDesc.innerHTML = document.LANSA.LFF_PCTDSC.value;
    if (document.LANSA.AFF_SHWPCT.value == 'Y')
      ProdCatDescRpr.innerHTML = document.LANSA.LFF_PCTDSC.value;
    }

if ( (document.LANSA.SA_SETLBS.value == 'Y') || (document.LANSA._OFUNCTION.value == 'CLMEEC1'))
  SetLabels();

if ( (document.LANSA._OFUNCTION.value == 'CLMERRC') && (document.LANSA.AFF_REFCLM.value == 'Y') )
  {
   window.opener.RefreshPage('WEBEDTC');
   window.close();
  }

if ( (document.LANSA._OFUNCTION.value == 'CTCNSCH') && (document.LANSA['ASA_APPID '].value == 'CT') )
  CTCNSCH_SetFields();

if ( (document.LANSA._OFUNCTION.value == 'CTCNSCH') && (document.LANSA['ASA_APPID '].value == 'WE') && (document.LANSA.ZSESSOT.value == 'M') )
  CTCNSCH_SetFields();

if ( (document.LANSA._OFUNCTION.value == 'CTCNSCH') && (document.LANSA['ASA_APPID '].value == 'SC') && (document.LANSA.ZSESSOT.value == 'M') )
  CTCNSCH_SetFields();

if ( (document.LANSA._OFUNCTION.value == 'CTCLDSP') && (document.LANSA.LFF_CCDSTL.value == 'none') )
  CompleteClaim.style.display='none';

if ( (document.LANSA._OFUNCTION.value == 'CTCLDSP') && (document.LANSA.AFF_SHWDSP.value == 'Y') && (document.LANSA.AFF_PRTMDE.value != 'Y') )
  CheckPrint();

if ( (document.LANSA._OFUNCTION.value == 'CTNOTES')  && (document.LANSA.AFF_REFCDP.value == 'Y') )
  {
   if (window.opener != null)
   {
    window.opener.RefreshPage();
    window.close();
   }
  }

if ( (document.LANSA._OFUNCTION.value == 'CTPTSOR') && (document.LANSA.AFF_REFCDP.value == 'Y') )
  {
   if (window.opener != null)
   {
    window.opener.RefreshPage('REFRESHNOFOCUS');
   }
  }

if ( (document.LANSA._OFUNCTION.value == 'CTRPECS') )
  {
    CTRPECS_ChangeSearchFields(document.LANSA.LFF_RPTTYP.value);
  }

if ( (document.LANSA.ASA_REFOPR.value == 'Y') )
  {
   window.opener.RefreshPage(document.LANSA.ASA_OPRKEY.value);
   window.close();
  } 

if ( (document.LANSA._OFUNCTION.value == 'CTCLDSP') && (document.LANSA.AFF_RBKREQ.value == 'Y') )
  {
  document.LANSA.AFF_RBKREQ.value = '';
  if( confirm('The changes you have made require you to choose a new appointment.  Do you want to choose a new appointment?') )
    MainDSPHandleEvent('KPICALPR01','CTCLDSS','REBOOK')
  }

if ( (document.LANSA._OFUNCTION.value == 'CLMNTES') && (document.LANSA.AFF_UPDCNF.value == 'Y') )
  CLMNTES_CheckUpdateFlag();

if ( document.LANSA._OFUNCTION.value == 'ARQLST' )
  ARQLST_SetFields();

if ( document.LANSA.ASA_PGHASH.value != '' )
 JumpWithinPage(document.LANSA.ASA_PGHASH.value);
 document.LANSA.ASA_PGHASH.value == '';

if ( document.LANSA._OFUNCTION.value == 'LTRUPL' )
  LTRUPL_SetFields();

if ( document.LANSA._OFUNCTION.value == 'EMLCNMT' )
 initEditor();

if ( (document.LANSA._OFUNCTION.value == 'CTPTSOR') && (document.LANSA.ASA_PAGVER.value == 'CONFM') )
  CTPTSOR_SetFields();

if ( (document.LANSA._OFUNCTION.value == 'CTPTSOR') && (document.LANSA.ASA_PAGVER.value == 'REVEW') && (document.LANSA.AFF_CORPEX.value == 'Y') && (document.LANSA.AFF_NEWORD.value == 'Y') )
  alert(kpimsg_script009);
}


function JumpWithinPage(hash)
{
location.hash = hash;
}


function CheckForCurrentPage()
{
if (document.LANSA.ASUBFLAG.value == 'S')
  {
    alert(kpimsg_script001);
    return false;
  }
else
  {
    document.LANSA.ASUBFLAG.value='S';
    return true;
  }
}

function CheckForCurrentPageOpener()
{
if (window.opener.document.LANSA.ASUBFLAG.value == 'S')
  {
    alert(kpimsg_script001);
    return false;
  }
else
  {
    window.opener.document.LANSA.ASUBFLAG.value='S';
    return true;
  }
}

function SubmitClaim(Proc,Func,WebKey)
{
 if ( (document.LANSA.AFF_CLMADJ.value == 'Y') && (document.LANSA.AFF_AJNADD.value != 'Y') ) {
  alert(kpimsg_script003); 
  return false;
 }

 ClaimHandleEvent(Proc,Func,WebKey);
}

function ClaimHandleEvent(Proc,Func,WebKey)
{
CloseNewWindow();
if (document.LANSA.ASUBFLAG.value == 'S') {
  alert(kpimsg_script001);
 }
 else {
  document.LANSA.ASUBFLAG.value='S';
  document.LANSA.AWEBKEY.value=WebKey;
  HandleEvent(Proc,Func)
 }
}

function PrinterHandleEvent(Proc,Func,WebKey)
{
CloseNewWindow();
if (document.LANSA.ASUBFLAG.value == 'S') {
  alert(kpimsg_script001);
 }
 else {
  document.LANSA.AFF_PRPLNK.value = 'Y';
  document.LANSA.AWEBKEY.value=WebKey;
  HandleEvent(Proc,Func)
 }
}

function hlon(object)
{
object.className='hlon';
}

function hloff(object)
{
object.className='hloff';
}

function OpenLANSAWindow(Proc,Func)
{
savetarget = document.LANSA.target;
CloseNewWindow();
winReport = window.open('',"winReport", "");
document.LANSA.target = 'winReport';
HandleEvent(Proc,Func)
if (window.focus) {winReport.focus()};
 document.LANSA.target = savetarget;
}
function SetModified(obj, flag)
{
document.LANSA[obj].value = flag;
}

function SetLabels(Dup,ChkNum) {
var txtTitle = "";

for (i=0; i<fieldLabelArray.length; i++)
 SetLabel(document.LANSA['ASA_MFGNO '].value,fieldLabelArray[i],fieldLabelArray[i],'N');


if(typeof fieldLabelArrayDup != 'undefined') { 
 for (i=0; i<fieldLabelArrayDup.length; i=i+2)
  SetLabel(document.LANSA['ASA_MFGNO '].value,fieldLabelArrayDup[i+1],fieldLabelArrayDup[i],'N');
 }
 
if(typeof fieldLabelArrayChkNum != 'undefined') {
 for (i=0; i<fieldLabelArrayChkNum.length; i=i+2)
  {
   if (document.getElementById('pinp_' + fieldLabelArrayChkNum[i]) != null)
    {
     txtTitle = document.getElementById('pinp_' + fieldLabelArrayChkNum[i]).title;
     if (txtTitle == txtAltEnter + ' 1.' || txtTitle == txtAltEnter + ' 2.' || txtTitle == txtAltEnter + ' 3.' ||
       txtTitle == txtAltEnter + ' 4.' || txtTitle == txtAltEnter + ' 5.' || txtTitle == txtAltEnter + ' 6.')
       SetLabel(document.LANSA['ASA_MFGNO '].value,fieldLabelArrayChkNum[i+1],fieldLabelArrayChkNum[i],'Y');   
    }
  }
 }
}

function SetLabel(mfg,fldnam,fldid,titleOnly) {
if (document.getElementById('plbl_' + fldid) != null && titleOnly != 'Y')
 {
 if (typeof window['flbl_' + fldnam + '_' + mfg] != 'undefined')
  {
  if (document.getElementById('plbl_' + fldid).type != 'button' && document.getElementById('plbl_' + fldid).type != 'hidden')
   document.getElementById('plbl_' + fldid).innerHTML = window['flbl_' + fldnam + '_' + mfg]; 
  else
   document.getElementById('plbl_' + fldid).value = window['flbl_' + fldnam + '_' + mfg]; 
 
  if (document.getElementById('pinp_' + fldid) != null)
   document.getElementById('pinp_' + fldid).title = txtAltEnter + ' ' + window['flbl_' + fldnam + '_' + mfg]; 
  }
 else
  if (typeof window['flbl_' + fldnam ] != 'undefined')
   {
   if (document.getElementById('plbl_' + fldid).type != 'button' && document.getElementById('plbl_' + fldid).type != 'hidden')
    document.getElementById('plbl_' + fldid).innerHTML = window['flbl_' + fldnam]; 
   else
    document.getElementById('plbl_' + fldid).value = window['flbl_' + fldnam]; 

   if (document.getElementById('pinp_' + fldid) != null)
    document.getElementById('pinp_' + fldid).title = txtAltEnter + ' ' + window['flbl_' + fldnam]; 
   }
 }
 else
 {
 if (typeof window['flbl_' + fldnam + '_' + mfg] != 'undefined')
  {
  if (document.getElementById('pinp_' + fldid) != null)
   document.getElementById('pinp_' + fldid).title = txtAltEnter + ' ' + window['flbl_' + fldnam + '_' + mfg]; 
  }
 else
  {
   if (document.getElementById('pinp_' + fldid) != null)
    document.getElementById('pinp_' + fldid).title = txtAltEnter + ' ' + window['flbl_' + fldnam]; 
  }
 }
}

function CountIt(TextEntered,maxlength)
{
var length;
var thisString;
thisString = TextEntered;
length = thisString.length;
if (length > (maxlength - 1))
{
alert("You have reached the limit of " + maxlength + " characters you can type." );
return false;
}
return true;
}

function SetValuesFromList(List,HiddenField,ListEntries, CodeLength,MaxItems)
{
var mvlLst = ''; 
var mvlHdn = '';
var mvlUPD = '';  
//List and HiddenField must be exactly 9 characters long

if (document.LANSA.AFF_UPDPAG.value == 'Y')
  for ( var x=0; x < ListEntries; x++)
   {
     if (x < 9)
       {
       mvlUPD = "__FF_UPDROW -000" + (x + 1) + " D"
       }
     else
       if (x < 99)
         {
         mvlUPD = "__FF_UPDROW -00" + (x + 1) + " D"
         }

   if (document.LANSA[mvlUPD].value == 'Y')
     {
     if (x < 9)
       {
       mvlList = "__" + List + " -000" + (x + 1) + " D"
       mvlHidden = "__" + HiddenField + " -000" + (x + 1) + " D"
       }
     else
       if (x < 99)
         {
         mvlList = "__" + List + " -00" + (x + 1) + " D"
         mvlHidden = "__" + HiddenField + " -00" + (x + 1) + " D"
         }
       SetValues(mvlList, mvlHidden, CodeLength, MaxItems)
     }
   }
}

function SetFieldValue(field,value)
{
document.LANSA[field].value = value;
}

function RefreshPage(WebKey)
{
 if (WebKey == null)
  WebKey = 'REFRESHPAGE';

 if (WebKey.trim() == '')
  WebKey = 'REFRESHPAGE';

 document.LANSA.AWEBKEY.value=WebKey;
 HandleEvent(document.LANSA._OPROCESS.value,document.LANSA._OFUNCTION.value)
}

function FindFrame(framename) {
    for (var i=0;i<parent.frames.length;i++) {
         if (parent.frames[i].name == framename)
             return true;
    }
    return false;
}

//WEB PAGING TEMPLATE FUNCTIONS
function SetToRedisplay(Proc,Func)
{
document.LANSA.AWEBKEY.value='REDISPLAY';
HandleEvent(Proc,Func);
}
function HandleWebKey(Proc,Func,WebKey)
{
document.LANSA.AWEBKEY.value=WebKey;
HandleEvent(Proc,Func);
}

function HandleWebView(Proc,Func,WebKey,SelView)
{
document.LANSA.AWEBKEY.value=WebKey;
document.LANSA.AW_SELVEW.value=SelView;
HandleEvent(Proc,Func);
}

function ChkMnuAuth(pos)
{
 if (document.LANSA.ASESMNO.value.substring(pos-1,pos) == 'Y')
  return true;
 else
  return false;
}

function SetOtherForm(Name)
{
   document.LANSA.ZOTHFRM.value=Name;
}