
function SelectCatalognpw(Proc,Func,Catalg,Catlogo){
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ASELCAT.value=Catalg;
   document.LANSA.ASELLOGO.value=Catlogo;
   document.LANSA.ANOPW.value='Y'; 
   document.LANSA.ASELITEM.value=' '; 
   document.LANSA.ASELPOORD.value=' '; 


   document.LANSA.submit();
}

function SelectShipTo(URLTO)
{
aWindow=window.open(URLTO, "Selectshipto", "toolbar=no,scrollbars=yes,width=850,height=500,resize=no,menubar=no");
}


function SetShipTo(Sship,Aship)
{
// Get the total number of input elements on the page
var NumElements=document.LANSA.elements.length;

for (i=0; i<NumElements;i++)
{
if (document.LANSA.elements[i].name==Sship)
{
document.LANSA.elements[i].value=Aship;
break;
}
}
}




function SelectCatalogpw(Proc,Func,Catalg){
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ASELCAT.value=Catalg;
   document.LANSA.ANOPW.value=' '; 
   document.LANSA.ASELITEM.value=' '; 
   document.LANSA.ASELPOORD.value=' '; 

   document.LANSA.submit();
}


function HandleCartBook(Proc,Func,OEsea,OEsyr,OEsty,OEclr,OEpce,OEdim,OEline)
{
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ACART_SEA.value=OEsea;
   document.LANSA.ACART_SYR.value=OEsyr;
   document.LANSA.ACART_STY.value=OEsty;
   document.LANSA.ACART_CLR.value=OEclr;
   document.LANSA.ACART_PCE.value=OEpce;
   document.LANSA.ACART_DIM.value=OEdim;
   document.LANSA.ACART_LINE.value=OEline;
   document.LANSA.ACART_M.value='';
   document.LANSA.ACART_B.value='Y';

   document.LANSA.submit();
}


function CheckDeleteLine(Proc,Func,Delsea,Delsyr,Delsty,Delclr,Delpce,Deldim,Delline)   {
        if  (confirm("Are you sure you want to DELETE this Line Item ?"))
        DeleteLineItem(Proc,Func,Delsea,Delsyr,Delsty,Delclr,Delpce,Deldim,Delline);

}

function DeleteLineItem(Proc,Func,Delsea,Delsyr,Delsty,Delclr,Delpce,Deldim,Delline)
{
            document.LANSA._PROCESS.value=Proc;
            document.LANSA._FUNCTION.value=Func;
            document.LANSA.ACART_SEA.value=Delsea;
            document.LANSA.ACART_SYR.value=Delsyr;
            document.LANSA.ACART_STY.value=Delsty;
            document.LANSA.ACART_CLR.value=Delclr;
            document.LANSA.ACART_PCE.value=Delpce;
            document.LANSA.ACART_DIM.value=Deldim;
            document.LANSA.ACART_LINE.value=Delline;
            document.LANSA.ADELITEM.value='Y';

            document.LANSA.submit();
}


function ValidateUser(Proc,Func){
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AVALUSER.value='Y'; 

   document.LANSA.submit();
}

function SelectCatalogRecord(Proc,Func,Catalg,Catsea,Catsyr,Catsty){
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ACART_STY.value=Catsty;
   document.LANSA.ACART_SEA.value=Catsea;
   document.LANSA.ACART_SYR.value=Catsyr;
   document.LANSA.ASELCAT.value=Catalg;

   document.LANSA.submit();
}

function SelectSimilarStyle(Proc,Func,Catco,Catdiv,Catalg,Catsea,Catsyr,Catsty){
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AS_CO.value=Catco;
   document.LANSA.AS_DIV.value=Catdiv;
   document.LANSA.ACART_STY.value=Catsty;
   document.LANSA.ACART_SEA.value=Catsea;
   document.LANSA.ACART_SYR.value=Catsyr;
   document.LANSA.ASELCAT.value=Catalg;
   document.LANSA.AWEBC003.value=' ';

   document.LANSA.submit();
}

function CheckCancelOrder(Proc,Func,Corder)   {
        if  (confirm("Are you sure you want to Empty the Cart ?"))
        Cancelorder(Proc,Func);

}

function Cancelorder(Proc,Func)
{
            document.LANSA._PROCESS.value=Proc;
            document.LANSA._FUNCTION.value=Func;
            document.LANSA.ACLRCART.value='Y';

           document.LANSA.submit();
}


function UpdCart(Proc,Func){
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AUPDCART.value='Y';

   document.LANSA.submit();
}


function CheckSearch(Proc,Func){
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ACHKSEARCH.value='Y';

   document.LANSA.submit();
}


function onSearchStyle(xevent, proc, func){
	var keyval = xevent.which;
	var keycod = xevent.keyCode;

	if((keyval == 13) || (keycod == 13)){
		SelectStyle(proc,func);
	}
	return true;
}



function TransfertoCustomerPortal(Proc,Func){
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AWCCAT.value='Y';
   document.LANSA.AWCLOGO.value='Y';

   document.LANSA.submit();
}


function TransfertoCart(Proc,Func){
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AWCCAT.value='Y';
   document.LANSA.AWCLOGO.value='Y';

   document.LANSA.submit();
}


function ViewDocument(Proc,Func,Docid,plogu,pnopw,plogo,pnologo){
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ADOCNAME.value=Docid;
   document.LANSA.ALOGU.value=plogu;
   document.LANSA.ANOPW.value=pnopw;
   document.LANSA.AWCLOGO.value=plogo;
   document.LANSA.AWCNLOGO.value=pnologo;

   document.LANSA.submit();
}


function HandleForgotpw(Proc,Func,Getpw)
{
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AFORGOT.value=Getpw;
   document.LANSA.submit();
}


function SelectHome(Proc,Func){
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ASELHOME.value='Y';

   document.LANSA.submit();
}


function CatalogLogon(Proc,Func){
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ALOGU.value='Y';
   document.LANSA.ACATSIGNON.value='Y';

   document.LANSA.submit();
}


function SearchPoOrd(Proc,Func){
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ASELPOORD.value='Y';

   document.LANSA.submit();
}


function saveInfo(fieldname, fieldvalue)
{
var today = new Date();
// cookie expires in 28 days - note change 28 below to be how many days in the future you
// would like the cookie to expire
today.setTime(today.getTime()+ 28*24*60*60*1000);
// set the cookie
setCookie(fieldname,fieldvalue,today);
}


function getCookie(name) {

        var cookieFound = 0;
        var start = 0;
        var end = 0;
        var CookieString = document.cookie;
        var i =0;

        while (i <= CookieString.length) {

                start = i;
                end = start + name.length;
                if (CookieString.substring(start,end) == name) {
                        cookieFound = true;
                        break;
                }
                i++;
        }


        if (cookieFound) {
                start = end + 1;
                end = document.cookie.indexOf(";",start);

                if (end < start)
                        end = document.cookie.length;
                return document.cookie.substring(start,end);
        }
        return "";
}

 function setCookie(name, value, expires)
// usage: setCookie("name",value,date) or setCookie("name",value)
{
var cookieString = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "");
  document.cookie = cookieString;
}

function HandleQuicklink(Proc,Func)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AQUICKL.value='Y';

   document.LANSA.submit();
}

function HandleQuicklinks(Proc,Func)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AQUICKLS.value='Y';

   document.LANSA.submit();
}


function HandleColor(Proc,Func)
{
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;

   document.LANSA.submit();
}


function SelectArStatus(Proc,Func,Sts)
{
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AWSTATUS.value=Sts;

   document.LANSA.submit();
}


function DownloadFile(URLD)
{
aWindow=window.open(URLD, "DownloadDocument", "toolbar=no,scrollbars=no,width=700,height=500,resize=yes,menubar=no,titlebar=no");
}


function NewDocument(Docurl)
{
aWindow=window.open(Docurl, "NewDocument", "toolbar=yes,scrollbars=yes,width=995,height=800,resize=yes,menubar=yes,titlebar=no");
}


function ExtractUpcCodes(Proc,Func)
{
alert("Extract of UPC Codes has been submitted for Processing"); 

   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AEXTUPC.value='Y';

   document.LANSA.submit();
}


function PrintOrderInvoice(Proc,Func,Refno)
{
alert("Printing of Order Invoice has been submitted for Processing"); 

   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.APRTINV.value='Y';
   document.LANSA.ASORDER.value=Refno;

   document.LANSA.submit();
}

function PrintOrderMemo(Proc,Func,Refno)
{
alert("Printing of Credit Memo has been submitted for Processing"); 

   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.APRTMEM.value='Y';
   document.LANSA.ASORDER.value=Refno;

   document.LANSA.submit();
}



function LoadCart(Proc,Func,Cco,Cdiv,Cslsm)
{
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ACARTCO.value=Cco;
   document.LANSA.ACARTDIV.value=Cdiv; 
   document.LANSA.ACARTSLSM.value=Cslsm;
   document.LANSA.ALOADCART.value='Y';

   document.LANSA.submit();
}


function SelectStyle(Proc,Func,Selsty)
{
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ASELITEM.value='Y'; 
 
   document.LANSA.submit();
}

function HandleSignoff(Proc,Func)
{
   document.LANSA.AWBSIGNON.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ALOGU.value='';

   document.LANSA.submit();
}

function HandleTransferPo(Proc,Func,Tcustno,CustPo,Tsea,Tsyr,Tsead,Tord,Tslsm,Tsnme,Tlstdd)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.PCSOSLD.value=Tcustno;
   document.LANSA.AS_PO.value=CustPo;
   document.LANSA.AAUT_SEA.value=Tsea;
   document.LANSA.AAUT_SYR.value=Tsyr;
   document.LANSA.AAUT_SNME.value=Tsead;
   document.LANSA.ASORDER.value=Tord;
   document.LANSA.AS_SLSM.value=Tslsm;
   document.LANSA.AWK_SNAME.value=Tsnme;
   document.LANSA.ALSTDD.value=Tlstdd;

   document.LANSA.submit();
}


function HandleNewstat(Proc,Func,Newst)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ACHGSTAT.value=Newst;

   document.LANSA.submit();
}


function ChangeOrderStatus(Proc,Func)
{
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ACHGSTS.value='Y';

   document.LANSA.submit();
}

function HandleSort(Proc,Func,Sortc,Sorto)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AW_SORT.value=Sortc;
   document.LANSA.AS_SEQ.value=Sorto;
   document.LANSA.submit();
}

function DspKioskOrder(Proc,Func,Kco,Kdiv,Kuser,Kslsm,Kcart)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ACARTCO.value=Kco;
   document.LANSA.ACARTDIV.value=Kdiv;
   document.LANSA.ACARTSLSM.value=Kslsm;
   document.LANSA.ACARTUSER.value=Kuser;
   document.LANSA.ACARTID.value=Kcart;
   document.LANSA.submit();
}

function ChangeMarkup(Proc,Func,Mco,Mdiv,Msty,Mprod)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AMARKUPCO.value=Mco;
   document.LANSA.AMARKUPDIV.value=Mdiv;
   document.LANSA.AMARKUPSTY.value=Msty;
   document.LANSA.AMARKUPPRD.value=Mprod;
   document.LANSA.submit();
}

function HandleNewsAll(Proc,Func,Allt,Alls)
{
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AALLTYPE.value=Allt;
   document.LANSA.AALLSORT.value=Alls;

   document.LANSA.submit();
}

function HandleFlashDet(Proc,Func,Flasht,Flashs,Flashyy,Flashmm,Flashww,Flashdd,Flashsty)
{
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AALLTYPE.value=Flasht;
   document.LANSA.AALLSORT.value=Flashs;
   document.LANSA.ALSTYY.value=Flashyy;
   document.LANSA.ALSTMM.value=Flashmm;
   document.LANSA.ALSTWW.value=Flashww;
   document.LANSA.ALSTDD.value=Flashdd;
   document.LANSA.ALSTY.value=Flashsty;

   document.LANSA.submit();
}



function HandleAcct(Proc,Func,Acct)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.PCSOSLD.value=Acct;

   document.LANSA.submit();
}

function HandleOrdernum(Proc,Func,Ordernum)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ASORDER.value=Ordernum;

   document.LANSA.submit();
}


function HandleOrderline(Proc,Func,Orderline)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ASLINE.value=Orderline;

   document.LANSA.submit();
}



function HandleRefno(Proc,Func,Refno,Refline)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ASLINE.value=Refline;
   document.LANSA.submit();
}

function CheckDeleteOrder(Proc,Func,Dcartuser,Dcartco,Dcartdiv,Dcartslsm,Dcartid)   {
        if  (confirm("Are you sure you want to DELETE the Order ?"))
        DeleteOrder(Proc,Func,Dcartuser,Dcartco,Dcartdiv,Dcartslsm,Dcartid);

}

function DeleteOrder(Proc,Func,Dcartuser,Dcartco,Dcartdiv,Dcartslsm,Dcartid)
{
            document.LANSA.AWBENTRY.value='';
            document.LANSA._PROCESS.value=Proc;
            document.LANSA._FUNCTION.value=Func;
            document.LANSA.ACARTCO.value=Dcartco;
            document.LANSA.ACARTUSER.value=Dcartuser;
            document.LANSA.ACARTDIV.value=Dcartdiv;
            document.LANSA.ACARTSLSM.value=Dcartslsm;
            document.LANSA.ACARTID.value=Dcartid;
            document.LANSA.ACLRCART.value='Y';

            document.LANSA.submit();
}

function CheckDeleteMarkup(Proc,Func,Mupco,Mupdiv,Mupsty,Mupprod)   {
        if  (confirm("Are you sure you want to DELETE the Mark-Up Entry ?"))
        DeleteMarkup(Proc,Func,Mupco,Mupdiv,Mupsty,Mupprod);

}

function DeleteMarkup(Proc,Func,Mupco,Mupdiv,Mupsty,Mupprod)
{
            document.LANSA.AWBENTRY.value='';
            document.LANSA._PROCESS.value=Proc;
            document.LANSA._FUNCTION.value=Func;
            document.LANSA.AMARKUPCO.value=Mupco;
            document.LANSA.AMARKUPDIV.value=Mupdiv;
            document.LANSA.AMARKUPSTY.value=Mupsty;
            document.LANSA.AMARKUPPRD.value=Mupprod;
            document.LANSA.ADELMARKUP.value='Y';

            document.LANSA.submit();
}

function HandleWip(Proc,Func,Cutno)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AW_CUT.value=Cutno;

   document.LANSA.submit();
}


function HandleCustPo(Proc,Func,CustPo,CustDte,CustSlsm)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AS_PO.value=CustPo;
   document.LANSA.ALSTDD.value=CustDte;
   document.LANSA.AS_SLSM.value=CustSlsm;

   document.LANSA.submit();
}


function HandleCoDiv(Proc,Func,CoDiv)
{
    document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ACHG_CODIV.value=CoDiv;

   document.LANSA.submit();
}

function HandleBooking(Proc,Func,Bclr,Bpce,Bdim)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AS_CLR.value=Bclr;
   document.LANSA.AS_PCE.value=Bpce;
   document.LANSA.AS_DIM.value=Bdim;

   document.LANSA.submit();
}

function HandleReg(Proc,Func,Sreg,Sregds)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AS_REG.value=Sreg;
   document.LANSA.AS_RGDS.value=Sregds;

   document.LANSA.submit();
}
function HandleState(Proc,Func,Sstate,Sstds)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AS_ST.value=Sstate;
   document.LANSA.AS_STDS.value=Sstds;

   document.LANSA.submit();
}



function HandleYM(Proc,Func,Syy,Smm)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AS_SYY.value=Syy;
   document.LANSA.AS_SMM.value=Smm;


   document.LANSA.submit();
}

function HandleBooklist(Proc,Func,Bookstyle)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.AS_STY.value=Bookstyle;

   document.LANSA.submit();
}

// Function to handle Return key pressed


function onReturnPressed(xevent, proc, func){
	var keyval = xevent.which;
	var keycod = xevent.keyCode;

	if((keyval == 13) || (keycod == 13)){
		HandleEvent(proc,func);
	}
	return true;
}


// Function to handle Return key pressed

function onValidateSignon(xevent, proc, func){
	var keyval = xevent.which;
	var keycod = xevent.keyCode;

	if((keyval == 13) || (keycod == 13)){
		ValidateUser(proc,func);
	}
	return true;
}





function SetCBState(obj, RFld, chkvalue, unchkvalue)
{
var NumElements=document.LANSA.elements.length;

for (i=0; i<NumElements;i++)
{
if (document.LANSA.elements[i].name==RFld)
{
if (obj.checked) document.LANSA.elements[i].value=chkvalue
else document.LANSA.elements[i].value=unchkvalue;
break;
}
}
}

function SetFocus()
{
   var NumElements=document.LANSA.elements.length;

   for (i=0; i<NumElements;i++)
   {
      if ( document.LANSA.elements[i].type=='checkbox'   ||
          document.LANSA.elements[i].type=='textarea'   ||
          document.LANSA.elements[i].type=='text')
      {
          if (document.LANSA.elements[i].value!="")
            document.LANSA.elements[i].select();

          document.LANSA.elements[i].focus();
          break;
      }
   }
}


function HandleOrder(Proc,Func,Order)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.submit();
}



function HandlePO(Proc,Func,Po,Soldto)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.submit();
}

function movepic(img_name,img_src) {
document[img_name].src=img_src;
}


function HandleSales(Proc,Func)
{
   document.LANSA.AWBENTRY.value='';
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.submit();
}

function CallCust(Proc,Func)
{
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.ANEWSOLD.value='Y';
   
   document.LANSA.submit();
}

function SelectAcct(URLA)
{
aWindow=window.open(URLA, "Selectacct", "toolbar=no,scrollbars=yes,width=560,height=450,resize=no,menubar=no");
}

function SetAccount(Facct,Fship,Fnme,Fad1,Fad2,Fcty,Fst,Fzip,Aacct,Aship,Anme,Aad1,Aad2,Acty,Ast,Azip)
{
// Get the total number of input elements on the page
var NumElements=document.LANSA.elements.length;

for (i=0; i<NumElements;i++)
{
if (document.LANSA.elements[i].name==Facct)
{
document.LANSA.elements[i].value=Aacct;
}
if (document.LANSA.elements[i].name==Fship)
{
document.LANSA.elements[i].value=Aship;
}
if (document.LANSA.elements[i].name==Fnme)
{
document.LANSA.elements[i].value=Anme;
}
if (document.LANSA.elements[i].name==Fad1)
{
document.LANSA.elements[i].value=Aad1;
}
if (document.LANSA.elements[i].name==Fad2)
{
document.LANSA.elements[i].value=Aad2;
}
if (document.LANSA.elements[i].name==Fcty)
{
document.LANSA.elements[i].value=Acty;
}
if (document.LANSA.elements[i].name==Fst)
{
document.LANSA.elements[i].value=Ast;
}
if (document.LANSA.elements[i].name==Fzip)
{
document.LANSA.elements[i].value=Azip;
break;
}
}
}


function Closewindow()
{
window.close();
}


function openHelp(URL)
{
aWindow=window.open(URL, "HelpWindow", "toolbar=no,scrollbars=no,width=775,height=500,resize=no,menubar=no");
}

function SetButton(btnvalue)
{
   document.LANSA._BUTTON.value = btnvalue;
}
function HandleSubmit()
{
   document.LANSA.submit();
}
function pathOnly(InString)
{
   LastSlash=InString.lastIndexOf('/',InString.length-1);
   OutString=InString.substring(0,LastSlash+1);
   return(OutString);
}
function SetSelect(HTMLName, Name,Row,Column,Select)
{
   document.LANSA._SELECT.value=Select;
   SetNameLocation(Name,Row,Column);
   document.LANSA._CALFLD.value=HTMLName;
   return;
}
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;
   return;
}
function CallCalendar()
{
   if (document.LANSA._CALFLD.value != "&NULL")
   {
      var opt = "width=250,height=250,directories=no,toolbar=no,";
      opt += "menubar=no,scrollbars=no,resizable=yes";
      win = window.open("/images/lcalen.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 (month<10)
       month="0"+month;

if (day<10)
       day="0"+day;

   var RDate=month+"/"+day+"/"+year;

   var NumElements=document.LANSA.elements.length;

   for (i=0; i<NumElements;i++)
   {
      if (document.LANSA.elements[i].name==Field)
      {
         document.LANSA.elements[i].value=RDate;
         break;
      }
   }
}
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 isValidDBCS(theObj,KeybdShift,EBCDICLength)
{
   var FieldValue = theObj.value;
   var returnString = "";
   var totalDBCS = 0;
   var totalSBCS = 0;
   var totalLength = 0;
   var inDBCS = false;
   for (var i = 0; i < FieldValue.length; i++)
   {
      if (isDBCSChar(FieldValue.charAt(i)))
      {
         if (!inDBCS)
         {
            inDBCS = true
            totalLength+=2
         }
            totalLength += 2;
            if ((totalLength <= EBCDICLength) && (KeybdShift != 'A'))
            {
               returnString += FieldValue.charAt(i)
               returnString += FieldValue.charAt(i+1)
            }
            totalDBCS++
            i++
         }
         else
         {
            totalLength += 1;
            if ((totalLength <= EBCDICLength) && (KeybdShift != 'J'))
               returnString += FieldValue.charAt(i)
            if (inDBCS) inDBCS = false
            totalSBCS++
         }
      }
      if (totalLength > EBCDICLength)
      {
         alert("Converted length of characters entered is " + totalLength +
                 "\nwhich exceeds the maximum allowable length of " + EBCDICLength +
                 "\nData will be truncated accordingly.")
         theObj.value = returnString
         return false
      }
      if ((KeybdShift == 'J') && (totalSBCS > 0))
      {
         alert("Only DBCS characters are allowed in this field.\n" +
                 totalSBCS + " SBCS characters have been entered.\n" +
                 "SBCS characters will be removed.")
         theObj.value = returnString
         return false
      }
      if ((KeybdShift == 'E') && (totalSBCS > 0) && (totalDBCS > 0))
      {
         alert("Either all DBCS characters or all SBCS characters " +
                 "are allowed in this field.\n" +
                 totalSBCS + " SBCS characters have been entered.\n" +
                 totalDBCS + " DBCS characters have been entered.\n" +
                 "Please modify field data accordingly.")
         return false
      }
      if ((KeybdShift == 'A') && (totalDBCS > 0))
      {
         alert("Only SBCS characters are allowed in this field.\n" +
                 totalDBCS + " DBCS characters have been entered.\n" +
                 "DBCS characters will be removed.")
         theObj.value = returnString
         return false
      }
      return true
}
function isDBCSChar(theChar)
{
   if (((theChar >= '\x81') && (theChar <= '\x9F')) ||
       ((theChar >= '\xE0') && (theChar <= '\xFC')))
      return true
   return false
}

//************************************************//
// Default it to 1 if this is NULL
// Date Format 1 - YYYY/MM/DD
// Date Format 2 - MM/DD/YYYY
// Date Format 3 - DD/MM/YYYY
// Date Format 4 - DD/MM/YY
// Date Format 5 - MM/DD/YY
// Date Format 6 - YY/MM/DD
//************************************************//

var DateFormat;
var FieldName = "";

function isBrowserSupp() {
// Get the version of the browser
version = parseFloat( navigator.appVersion );
if ( ( version >= 2.0 ) && ( version < 2.1 ) && ( navigator.appName.indexOf( "Netscape" ) != -1 ) ) {
return false;
}
else {
return true;
}
}
function getDaysInMonth(mthIdx, YrStr)
{
  // all the rest have 31
  var maxDays=31

  // expect FEB. (of course)

  if (mthIdx==2)
    {
  if (isLeapYear(YrStr))
{ maxDays=29; }
    else  { maxDays=28; } }
  // thirty days hath...
  if (mthIdx==4 || mthIdx==6 || mthIdx==9 || mthIdx==11)
    {   maxDays=30; }
  return maxDays;
}
function isLeapYear(yrStr)
{
  var leapYear=false;

  if ((parseInt(yrStr, 10)%4) == 0)
  { leapYear=true; } return leapYear;
}


//Calendar Section
//calculation functions
function nextMonth(month)
{
  if (month==12)
{ return 1;}else{ return (month+1);}
}

function prevMonth(month)
{
  var prevMonth = (month-1)
  if (month==1) { prevMonth = 12;}return prevMonth
}

//increments or decrements month when it goes past JAN or DEC
function changeYear(direction,month,year)
{
  var theYear = year
  if (direction=="next")
  {if (month == 12) {
      theYear = (year+1)
    }
  }
  if (direction=="prev")
  {
    if (month == 1)
    {   theYear = (year-1) }
}return theYear

}

//opens a new window for the calendar
function createCalendar(Wwidth, Wheight, Wtop, Wleft,format, fieldname)
{
// Sets the global DateFormat and Fieldname here
DateFormat = format;
FieldName = fieldname;

// Build the Calendar Windows HTML
var opt = "width=" + Wwidth + ",height=" + Wheight + ",top=" + Wtop + ",left=" + Wleft + ",resizable=no,scrollbars=no";
  if (!isBrowserSupp())
  {
    alert("Your browser is outdated and does not support this feature")
   return;
  }
  if (navigator.appVersion.indexOf("Mac",0) != -1)
  {
 calendarWindow = window.open("","Calendar", opt);
 }
  else
  {
    calendarWindow = window.open("","Calendar", opt);
 }
var today = new Date();
var mthIdx = today.getMonth();
var mthVal = today.getMonth() + 1;
var yearVal = today.getYear();

// If year returned is 100 (in Netscape Version 4.0x and below)
// Subtract 100 to give you just 00

if (yearVal == 100) yearVal = yearVal - 100;

// If year is between 00 and 50, assume that the year is in the 2000 era.
// otheriwse assume year is in the 1900 era

if ((yearVal >= 00) && (yearVal <= 50))
{
// if year is 00, add 2000 to give you a 4 digit year
yearVal = yearVal + 2000;
}
else
{
if (yearVal.length <= 2)
{
// If year is NOT between 00 and 50, ad 1900 to assume its in the 1900 era.
  yearVal = yearVal + 1900;
}
}

//call the function to populate the window
generateCalendar(calendarWindow,mthVal,yearVal)
}

//generates the meat of the calendar
function generateCalendar(target,month,year)
{
 if (!isBrowserSupp())
  {
   return;
  }
  var monthName = new Array ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
  //begin table for calendar
  target.document.open();
  calendar = "<html><head><title>Calendar</title></head><body bgcolor='darkgray' topmargin=2 leftmargin=2><div align='center'> <STYLE TYPE='text/css'>.BLACK1 { color : Black; font-size : 13px; font-family:  Verdana ,Arial, Helvetica, sans-serif; }"
  calendar +="A {text-decoration:none;}</style>"
  calendar +="<table border=0 cellspacing=3 cellpadding=0>"
  calendar +="<tr valign=top>"

  var mthIdx = parseInt(month, 10);

  var endday = getDaysInMonth(mthIdx, year)

  //next month and previous month buttons

  var goPrevMonth = prevMonth(mthIdx)

  var goNextMonth = nextMonth(mthIdx)

  var nextYear = changeYear("next",parseInt(month, 10),parseInt(year, 10))

  var prevYear = changeYear("prev",parseInt(month, 10),parseInt(year, 10))
  var index = (mthIdx-1)

  //month header
  {

    calendar +="<form><td align=left colspan=7 bgcolor='deepskyblue'><table width='100%' border=0 cellpadding=0 cellspacing=0><tr><td><a href='javascript:void(0)' onClick='document.clear();opener.generateCalendar(opener.calendarWindow,"+goPrevMonth+","+
prevYear+")'><IMG SRC='/IMAGES/Calprev.gif' border=0 ></a></td>"

    calendar +="<td align=center colspan=3 bgcolor='deepskyblue'><b><font size='-1' face='Arial' color='black'>" + monthName[index] + " "
+ year + "</font></b></td>"

    calendar +="<td align=right colspan=2 bgcolor='deepskyblue'><a href='javascript:void(0)'onClick='document.clear();opener.generateCalendar(opener.calendarWindow,"+goNextMonth+","+
nextYear+")'><IMG SRC='/IMAGES/calnext.gif' border=0></a></td></tr></table></td></tr>"


  }
  //writes in the day of the week labels

  calendar +="<tr align=center>"

  calendar +="<td align='center' bgcolor='#FFFFC0'><b>S</b></font></td>"

  calendar +="<td align='center' bgcolor='#FFFFC0'><b>M</b></font></td>"

  calendar +="<td align='center' bgcolor='#FFFFC0'><b>T</b></font></td>"

  calendar +="<td align='center' bgcolor='#FFFFC0'><b>W</b></font></td>"

  calendar +="<td align='center' bgcolor='#FFFFC0'><b>T</b></font></td>"

  calendar +="<td align='center' bgcolor='#FFFFC0'><b>F</b></font></td>"

  calendar +="<td align='center' bgcolor='#FFFFC0'><font color='RED'><b>S</b></font></td>"
  calendar +="</tr>"
  wholeDate = month + "/01/" + year
  thedate = new Date(wholeDate)
  firstDay = thedate.getDay()
  selectedmonth = mthIdx;
  var today = new Date();
  var thisyear = today.getYear() + 1900;
  selectedyear = year;

  var lastDay = (endday + firstDay+1)
  calendar +="<tr>"

  var daycounter = 0;
  for (var i = 1; i < lastDay; i++)
  {
    daycounter=i;
    if (i <= firstDay)
    {
      // 'empty' boxes prior to first day
      calendar +="<td>&nbsp</td>"


    }
    else
    {
      // enter date number
      if (i % 7 == 0 || i % 7 == 1)
      {
      if ((i-firstDay)==(today.getDate())&&(month == parseInt(today.getMonth() + 1)) &&(year == today.getYear()))
      {
       calendar +="<td bgcolor='lightgreen' align=center><a href='JavaScript:self.close();opener.closeCalendar"+"("+(i-firstDay)+ "," + selectedyear + ")' class=black1><b>"+(i-firstDay)+"</b></a></td>"
}
      else
      {
       calendar +="<td bgcolor='pink' align=center><a href='JavaScript:self.close();opener.closeCalendar"+"("+(i-firstDay)+ "," + selectedyear + ")' class=black1><b>"+(i-firstDay)+"</b></a></td>"
}

      }
      else
      {
        if ((i-firstDay)==(today.getDate())&&(month == parseInt(today.getMonth() + 1)) && (year == today.getYear()))
        {
       calendar +="<td bgcolor='lightgreen' align=center><a href='JavaScript:self.close();opener.closeCalendar"+"("+(i-firstDay)+ "," + selectedyear + ")' class=black1><b>"+(i-firstDay)+"</b></a></td>"
        }
        else
        {
       calendar +="<td align=center bgcolor='white'><a href='JavaScript:self.close();opener.closeCalendar"+"("+(i-firstDay)+ "," + selectedyear + ")' class=black1><b>"+(i-firstDay)+"</b></a></td>"
        }
      }


    }
    //must start new row after each week
    if (i % 7 == 0 && i != lastDay)
      {
      calendar +="</tr><tr>"
      }
    }
  calendar +="</tr>"



  //separator line

  //calendar +="<tr><td colspan=7 align=center width=200><hr noshade></td></tr></table></form></body></html>"

calendar +="</table></div></form></body></html>"

  target.document.write(calendar);
target.focus();
  target.document.close()
}

function SetDateField(FieldName, DateFormat, day, year)
{
// Get the total number of input elements on the page
var NumElements=document.LANSA.elements.length;

// Loop thorugh each input element
for (i=0; i<NumElements;i++)
{
// Find the matching fieldname and type
if (document.LANSA.elements[i].name==FieldName && document.LANSA.elements[i].type =="text")
{
// Set the Date to the selected date using the required format
if (DateFormat == 6)
{

document.LANSA.elements[i].value=year + "/" + selectedmonth + "/" + parseInt(day, 10);
}
else if (DateFormat == 5)
{

document.LANSA.elements[i].value=selectedmonth + "/" + parseInt(day, 10) + "/" + year;
}
else if (DateFormat == 4)
{
document.LANSA.elements[i].value=parseInt(day,10) + "/" + selectedmonth + "/" + year;
}
else if (DateFormat == 3 || DateFormat == null)
{
document.LANSA.elements[i].value=parseInt(day,10) + "/" + selectedmonth + "/" + year;
break;
}
else if (DateFormat == 2)
{
document.LANSA.elements[i].value=selectedmonth + "/" + day + "/" + year;
break;
}
else if (DateFormat == 1)
{
document.LANSA.elements[i].value=year + "/" + selectedmonth + "/" + parseInt(day, 10);
break;
}
}
}
}
function closeCalendar(day, year)
{
// If no FieldName is passed in return. you could put an alert in here to inform the user that no FieldName was passed.

if (FieldName == null || FieldName == "")
{ return; }

// Set Default DateFOrmat to 1
if (DateFormat == null || DateFormat == "")
{ DateFormat = 1; }

// Add leading 0 if Month is less than 10
if (selectedmonth < 10)
{ selectedmonth = "0" + selectedmonth; }

if (day < 10 && day.length != 2) {day = "0" + day;}

// Make year 2 digit format only if DateFormat is 4, 5 or 6
if (DateFormat >= 4 && DateFormat <= 6)
{
if ((year >= 2000) && (year <= 2050))
{ year = parseInt(year, 10) - 2000; }
else
{ year = parseInt(year, 10) - 1900;}
if (year < 10) year = "0" + year;
}

// Call SetDateField to set the value of the Field to the Selected Date.

SetDateField(FieldName, DateFormat, day, year);
}

