<!--
prod_flag=true;
try {
   prod_flag=Glob_P_flag;
   //alert("prod_flag=Glob_P_flag="+prod_flag);
   }

catch (e) {
   document.writeln("<br>at start Glob_P_flag problem"  
 +'<br>e.message:     ' + e.message
 +'<br>e.fileName:    '+e.fileName
 +'<br>e.lineNumber:  '+e.lineNumber 
 +'<br>e.stack:       '+e.stack 
 +'<br>e.name:        '+e.name 
);
}

//    var t = element.form.textarea3;
text3_flag=true;
   //alert("document.everything.form.textarea3="+text3_flag);
try {
   var t33 = document.everything.textarea3.value;
   }

catch (e) {
   text3_flag=false;
/*   document.writeln("<br>at start document.everything.form.textarea3 problem"  
 +'<br>e.message:     ' + e.message
 +'<br>e.fileName:    '+e.fileName
 +'<br>e.lineNumber:  '+e.lineNumber 
 +'<br>e.stack:       '+e.stack 
 +'<br>e.name:        '+e.name 
);	*/
}
   if (!prod_flag) alert("document.everything.form.textarea3="+text3_flag);


if (!prod_flag) document.writeln("<br>this is the test_javascript pkg -*-/\\/\\/\\/\\-* <br>");

Glob_stat="start";
Glob_brow="IE";
Glob_element=document.everything;



window.onerror=customHandler

function get_db_flg() {
    //document.everything
    Glob_stat="start.fun.get_db_flg";
    //var db1 = ff1.form.dodebug;
    //db1 ="???";
    //return db1.checked;
    xyz=document.everything.dodebug.checked;
    return xyz;
}

if (!prod_flag) document.writeln("<br>this is [3]");
dd = new Date();

if (!prod_flag) document.writeln("<br>" + dd);

//fun to dump elements
function db_dump_elements(fflg) {
if (fflg) {
   alert("in function db_dump_elements "+fflg);
   debugwindow("at beginning elements:");
   j=0;
   lst="";
   for (sProp in window.document) {
      debugwindow("j=" + j + " " + sProp);
      lst=lst+"\nj=" + j + " " + sProp;
      if (j%10==0) {
         //alert("db_dump_elements"+lst);
         lst="";
      }
      j++;
   }
   //alert("db_dump_elements"+lst);
}
}
wqq=false;	//get_db_flg();
db_dump_elements(wqq); 

 //var t1 = textarea1;


function goHandler(desc,page,line,chr1,chr2)  {
 alert(
  'go button clicked! \n'
 +'The event was handled by '
 +'a customized  handler.\n'
 +'\nevent description: \t'+desc
 +'\nfile content:      \t'
 +'\nLine number:       \t'+line
 )
 return true
}


function customHandler(desc,page,line,chr1,chr2)  {
 alert(
  'JavaScript error occurred! \n'
 +'The error was handled by '
 +'a customized error handler.\n'
 +'\nError description: \t'+desc
 +'\nPage address:      \t'+page
 +'\nLine number:       \t'+line
 +'\nChr1 ??:       \t'+chr1
 +'\nChr2 ??:       \t'+chr2
 +'\nGlob_stat:       \t'+Glob_stat
 )
 return true
}

//set up onclick handler


//need a routine to print non-printables as hex or <>escape *********************
function printable(instring) {
   Glob_stat="start.fun.printable";
   var outstr="";
   if (instring.length>0) {
      //go thru instring, convert non-printable
      sst=" ".charCodeAt(0);
      spp="~".charCodeAt(0);
      for (var i=0; i < instring.length-1; i++) {
         tst=instring.charCodeAt(i);
         if (tst>=sst && tst <=spp) {
            outstr +=instring[i];
         } else {
            outstr = outstr + "<" + tst + ">";
         }
      }
      Glob_stat="end.fun.printable";
      return outstr;
   } else {
      Glob_stat="end.fun.printable.oops";
      alert("In printable Input string is empty");
      return "--oops--";
   }
}

//routine to get next pair "tag":"value"
function getNextPair(arr_in,start_at,rets ) {   //found_at, end_at,tag1,value1
    Glob_stat="start.fun.getNextPair s:"+start_at;
    tag1="";
    value1="";
    rets[0]=-2;
    rets[1]=-2;
   if (arr_in.length>0) {
      found_at=arr_in.indexOf('"',start_at);
      if (found_at>-1) {
         mid1=arr_in.indexOf('":',found_at);
         if (mid1>-1) {	//need to handle string differently
            //end_at=arr_in.indexOf(',',mid1+2);	//this will miss last pair
            //handle string
            end_at=-1;
            val_st_i=0;
            if (arr_in.charAt(mid1+2)=='"') {	//loop till "' deal with \"
               db_tx="";
               var k = mid1+3 ;
               val_st_i=k;
               while ( k <= arr_in.length-1) {
                  db_tx=db_tx+arr_in.charAt(k);
                  if (arr_in.charAt(k)=='\"' && arr_in.charAt(k-1)!='\\') {
                     end_at=k;
                     break; //can stop loop
                  }
                  db_tx=db_tx+arr_in.charAt(k);
                  k++;
               }
               //alert("in getNextPair val str|"+db_tx+"|");
            } else {	//not string; "," or end of input ends
               end_at=arr_in.indexOf(',',mid1+2);
               val_st_i=mid1+2;
               if (end_at==-1) end_at=arr_in.length-1;
            }
            if (end_at>-1) {
               //valid "tag":"value" exists
               //alert("In getNextPair exists found/mid/end:" + found_at + "/"+mid1 + "/"+end_at);
               tag1=arr_in.substring(found_at+1, mid1);
               value1=arr_in.substring(val_st_i, end_at);
               //alert("In getNextPair exists |tag|val|" + tag1 + "|" + value1 + "|");
               rets[0]=found_at;
               rets[1]=end_at;
               rets[2]=tag1;
               rets[3]=value1;
               return true;
            } else {
               //alert("In getNextPair end quote at:" + end_at);
               Glob_stat="end.fun.getNextPair s:"+start_at;
               return false;
            }
         } else {
            //alert("In getNextPair mid at:" + mid1);
            Glob_stat="end.fun.getNextPair s:"+start_at;
            return false;}
      } else {
         //alert("In getNextPair found at:" + found_at);
         Glob_stat="end.fun.getNextPair s:"+start_at;
         return false;}
      //go thru arr_in, 
   } else {
      alert("In getNextPair Input string is empty");
      Glob_stat="end.fun.getNextPair empty";
      return false;
   }
}

//routine to split out levels and records and # them and get str/stp
function doSplit1(element,out_ar) 
{
    Glob_stat="start.fun.doSplit1";
    if (element.form.dodebug.checked) debugwindow("Glob_stat:"+Glob_stat+"|");
    var t1 = element.form.textarea1;
  //search for {}[] : {str rec; }end rec; [str sub sec; ]end sub sec
    start_at=0;
    xxx = true;
    istop=0;
    level1=0;
    rec_n=0;
    //RgE1=new RegExp("\[", "mg"); //\[\]  "[{}\x5B\x5D]"
    RgE1= /[{}]/mg; //\[\]  "[{}\x5B\x5D]"

  cc=0;
  cc1=0;
  ott="";
  ott2="";
    Glob_stat="start.fun.doSplit1 :2";
    if (element.form.dodebug.checked) debugwindow("Glob_stat:"+Glob_stat+" input len:" + t1.value.length+"|");

for (var i = 0; i <= t1.value.length-1; i++) {
    tst_ch=t1.value.charAt(i);
    switch (tst_ch) {
      case "{" :
         rec_n++;
         //ott=ott + "\ncc=" + cc + " found at:" + i + " char:{  lev/rec:" + level1 + "/" + rec_n ;
         out_ar[cc]=new Array(4);
         out_ar[cc][0]=tst_ch;
         out_ar[cc][1]=i;
         out_ar[cc][2]=level1;
         out_ar[cc][3]=rec_n;
         /* if (element.form.dodebug.checked) debugwindow("In doSplit1 found:"+tst_ch+" at:" 
            + i+" rec:"+rec_n+"|"); */
         cc++;
         cc1++;
         break;
      case "}" :
         //ott=ott + "\ncc=" + cc + " found at:" + i + " char:}  lev/rec:" + level1 + "/" + rec_n ;
         out_ar[cc]=new Array(4);
         out_ar[cc][0]=tst_ch;
         out_ar[cc][1]=i;
         out_ar[cc][2]=level1;
         out_ar[cc][3]=rec_n;
         /* if (element.form.dodebug.checked) debugwindow("In doSplit1 found:"+tst_ch+" at:" 
            + i+" rec:"+rec_n+"|"); */
         cc++;
         cc1++;
         break;
      case "[" :
         level1++;
         rec_n=0;
         //ott=ott + "\ncc=" + cc + " found at:" + i + " char:[  lev/rec:" + level1 + "/" + rec_n ;
         out_ar[cc]=new Array(4);
         out_ar[cc][0]=tst_ch;
         out_ar[cc][1]=i;
         out_ar[cc][2]=level1;
         out_ar[cc][3]=rec_n;
         cc++;
         cc1++;
         break;
      case "]" :
         level1--;
         //ott=ott + "\ncc=" + cc + " found at:" + i + " char:]  lev/rec:" + level1 + "/" + rec_n ;
         out_ar[cc]=new Array(4);
         out_ar[cc][0]=tst_ch;
         out_ar[cc][1]=i;
         out_ar[cc][2]=level1;
         out_ar[cc][3]=rec_n;
         cc++;
         cc1++;
         break;
      /* case "9" :
         if (element.form.dodebug.checked) debugwindow("In doSplit1 found:"+tst_ch+" at:" 
            + i+" rec:"+rec_n+"|");
         break; */
      default : 
         ott2=ott2 + tst_ch;

         break;
    }
    /* if (i%30==0 ) {
         if (element.form.dodebug.checked) debugwindow("In doSplit1 at:" 
            + i +" text:" + t1.value.substring(i, i+30) + "|");
        //alert("in search " + ott);
        ott="";
        cc1=0;
    }
    if (i%30==0 ) {
         if (element.form.dodebug.checked) debugwindow("In doSplit1 at:" 
            + i +" looked at:" + ott2 + "|");
        ott2="";
        cc1=0;
    }  */
}

/*
  while (cc<10) {
    myArray = RgE1.exec(t1.value); 
    //check for null
    q1=myArray.index; 
    q2=myArray[0];
    q3=RgE1.lastIndex;
    //alert("reg exp cc=" + cc + " found at:" + q1 + " char:" + q2 + " Next i:" +q3);
    ott=ott + "\ncc=" + cc + " found at:" + q1 + " char:" + q2 + " Next i:" +q3 + " near:" + t1.value.substr(q1, 12);
    cc++;
  }
*/
  //alert("end search " + ott);
    Glob_stat="end.fun.doSplit1";
    if (element.form.dodebug.checked) debugwindow("Glob_stat:"+Glob_stat+" at:" 
            + i+" rec:"+rec_n+"|");
}

//remove '"' from string********************
function clean_quote(str_in) 
{
   Glob_stat="start.fun.clean_quote";
   var qt = String.fromCharCode(34);	//"
   out_st=str_in;
   if (str_in.length>0) {
      zx="0";
      if(str_in.charAt(0)==qt) zx="1";	//1 is front, 2 is back,  3 is both
      if(str_in.charAt(str_in.length-1)==qt) {
         zx=zx+"1";
      } else zx=zx+"0";
      switch (zx) {
         case "10":
            out_st=str_in.substr(1);
         break;
         case "01":
             out_st=str_in.substring(0, str_in.length-1);
         break;
         case "11":
             out_st=str_in.substring(1, str_in.length-1);
         break;
      }
      return out_st;
   } else return "";
}

//remove '\n' from string********************
function clean_newline(str_in) 	//othe esc char \'Single quot  \"Double quot  \\Backslash
{
   Glob_stat="start.fun.clean_newline";
   var qt = String.fromCharCode(34);	//"
    var cr1 = String.fromCharCode(13);
   if (str_in.length>0) {
      cstr=0;
      out_st="";
      ix=str_in.indexOf("\\n", cstr);
      while (ix>-1) {
         out_st=out_st+str_in.substring(cstr,ix) + cr1 + "    ";
         cstr=ix+2;
         ix=str_in.indexOf("\\n", cstr);
      } 
      newstr1=out_st.replace(/\\\\/g, "\\");
      newstr2=newstr1.replace(/\\\'/g, "'");
      newstr3=newstr2.replace(/\\\"/g, '"');
      //return out_st+ cr1 + "    "+newstr1+ cr1 + "    "+newstr2+ cr1 + "    "+newstr3;
      return newstr3;
   } else return "";
}

//dunp 2 dim array in alerts********************
function dumpArr(element,arrr) 
{
    Glob_stat="start.fun.dumpArr";
    var t1 = element.form.textarea1;
    d1=arrr.length
    d2=arrr[0].length
    dtx="dump array "+ d1 + " by " + d2;
    ott="";
    cc1=0;
    cc=0;
    for (var i = 0; i <= d1-1; i++) {
       
       //for (var j = 0; j <= d2-1; j++) {
          ott=ott + "\nIndx:" + cc +" Sym:" + arrr[i][0] + " at:" + arrr[i][1] + " lev:" + arrr[i][2] + " rec:" + arrr[i][3];
          cc1++;
          cc++;
          if (cc1>=10) {
             alert(dtx + " " + ott);
             ott="";
             cc1=0;
          }
       //}
    }
    if (ott.length>0) alert(dtx + " " + ott);
}

//format & output 2 dim array in t1.value rec tag|value pairs********************
function format_out(element,arrr) 
{
    Glob_stat="start.fun.format_out";
    var db1 = element.form.dodebug;
    if (db1.checked) debugwindow("Glob_stat:"+Glob_stat+"|");
    var t2 = element.form.textarea2;
    var cr1 = String.fromCharCode(13);
    //t2.value="---new output---";
    d1=arrr.length
    //d2=arrr[0].length
    dtx="in function format_out dump array2 "+ d1 + " by ???";  // + d2;
    ott="";
    cc1=0;
    cc=0;
    Glob_stat="in.fun.format_out dtx:"+dtx;
    for (var i = 0; i <= d1-1; i++) {
       ott="<br>format_out Indx:" + i +" Rec:" + arrr[i][0] ;
       num_txt="";
       cit_txt="";
       typ_txt="";
       secn_txt="";
       numb_txt="";
       val_txt="";
       mkr_txt="";
       for (var j = 1; j <= arrr[i].length-1; j+=2) {
          Glob_stat="in.fun.format_out i,j:"+i+" ,"+j;
          ott=ott + " j="+j+" Tag:" + arrr[i][j] +" Value:" + arrr[i][j+1] ;
          cc++;
          xtst=clean_quote(arrr[i][j]);
          switch (xtst){
             case 'markerNumber':
                num_txt=arrr[i][j+1];
             break;
             case ',"markerNumber':
                mkr_txt=arrr[i][j+1];
                t2.value=t2.value+cr1+ "What? Rec:" + arrr[i][0]+"|"+ arrr[i][2]+"|"+arrr[i][j]+"|"+arrr[i][j+1]+ "  ";
                t2.value=t2.value+cr1+ "Rec="+RecordNis(element,i+1)+"|";
             break;
             case 'citation' :
                cit_txt=clean_quote(arrr[i][j+1]);
             break;
             case 'type' :	
                typ_txt=clean_quote(arrr[i][j+1]);
             break;
             case 'sectionNumber' :	
                secn_txt=arrr[i][j+1];
             break;
             case 'numbered' :	
                numb_txt=arrr[i][j+1];
             break;
             case 'value' :	
                val_txt=arrr[i][j+1];
             break;
             case 'note' :	//skip
             break;

             default :
                alert("not recognized:" +arrr[i][j]+ "| In rec:"+arrr[i][0]);
          }	//switch
       }	//for j
       if (db1.checked) debugwindow(ott+"|");

       cc1++;
       Glob_stat="in.fun.format_out format i:"+i;
       //format record for output
       //t2.value=t2.value+cr1+num_txt+cit_txt+typ_txt+val_txt;
          resul="";
          switch (typ_txt){
             case 'citation':	//"("+arrr[i][j+1]+") "
                if (num_txt=="null") {
                   t2.value=t2.value+cr1+cit_txt;	//+"||"+typeof(num_txt);
                   resul=cit_txt;
                } else {
                   t2.value=t2.value+cr1+"("+num_txt+") "+cit_txt;
                   resul="("+num_txt+") "+cit_txt;
                }
             break;
             case 'text':
                t2.value=t2.value+cr1+"    "+clean_newline(clean_quote(val_txt));
                resul="    "+clean_newline(clean_quote(val_txt));
             break;
             case 'section':
                t2.value=t2.value+cr1+"    Section:"+secn_txt +	" " +clean_quote(val_txt);
                resul="    Section:"+secn_txt +	" " +clean_quote(val_txt);
             break;
             default :
                //alert("not recognized:" +typ_txt+ "| In rec:"+arrr[i][0]);
                if (db1.checked) debugwindow("Glob_stat:"+Glob_stat+" not recognized:" 
                   +typ_txt+ "| In rec:"+arrr[i][0]+"|");
          }	//switch
          if (db1.checked) debugwindow("Result i,j:"+i+","+j+" |"+resul+"|");


    }	//for i
    //if (ott.length>0) alert(dtx + " " + ott);
}	//function format_out

//dump to win dim array rec tag|value pairs********************
function win_dump(zzxx,out_ar,arrr) 
{
    Glob_stat="start.fun.win_dump";
    d1=arrr.length
    d2=arrr[0].length

    ott="";
    for (var i = 0; i <= d1-1; i++) {
       ott=ott + "<tt><br>Indx:" + i +" Rec:" + arrr[i][0] ;
       
       for (var j = 1; j <= arrr[i].length-1; j+=2) {
          ott=ott + " j="+j+" Tag:" + arrr[i][j] +" Value:" + arrr[i][j+1] ;
       }	//for j
       zzxx.document.writeln(ott);
       ott="";
    }	//for i
    zzxx.document.writeln("</tt>");
}



//dump 2 dim array in alerts rec tag|value pairs********************
function dumpArr2(element,arrr) 
{
    Glob_stat="start.fun.dumpArr2";
    var t1 = element.form.textarea1;
    d1=arrr.length
    d2=arrr[0].length
    dtx="dump array2 called "+ d1 + " by " + d2;
    ott="";
    cc1=0;
    cc=0;
    for (var i = 0; i <= d1-1; i++) {
       ott=ott + "\nIndx:" + i +" Rec:" + arrr[i][0] ;
       
       for (var j = 1; j <= arrr[i].length-1; j+=2) {
          ott=ott + " j="+j+" Tag:" + arrr[i][j] +" Value:" + arrr[i][j+1] ;
          cc++;
       }	//for j
          cc1++;
          if (cc1>=10) {
             alert(dtx + " " + ott);
             ott="";
             cc1=0;
          }	//if
    }	//for i
    if (ott.length>0) alert(dtx + " " + ott);
}	//function dumpArr2

//routine to get record n from t1 input
function RecordNis(element,nn) 
{
    Glob_stat="start.fun.RecordNis N="+ nn;
    //out_ar2
    var t1 = element.form.textarea1;
    i=nn;
    rec_st=t1.value.substring(out_ar[i][1]+1,out_ar[i+1][1]);
    return rec_st;
}

//routine to find record "{}" and pull tag:value pairs
function pullRecords(element,arrr,arrr2) 
{
    Glob_stat="start.fun.pullRecords";
    var t1 = element.form.textarea1;
    var t2 = element.form.textarea2;
    var cr1 = String.fromCharCode(13);
    var db1 = element.form.dodebug;
    d1=arrr.length;
    //d2=arrr[0].length;
    rets2=new Array();
    rec_ct=-1;
    Glob_stat="in.fun.pullRecords at for d1:"+d1;
    if (db1.checked) debugwindow("Glob_stat:"+Glob_stat+"|");
    for (var i = 0; i <= d1-1; i++) {
        if (arrr[i][0]=="{" && arrr[i+1][0]=="}") {
           //rec must be >0
           if (arrr[i+1][1]-arrr[i][1]>1) {
           //we have a record
           rec_st=t1.value.substring(arrr[i][1]+1,arrr[i+1][1]);
           aaaa=rec_st;
           Glob_stat="in.fun.pullRecords st:"+arrr[i][1]+1;
           /* if (db1.checked) {  //do debug
              debugwindow("Rec:" +arrr[i][3]+ " |"+ aaaa+"|");
           } */
           //alert("Rec:" +arrr[i][3]+ " |"+rec_st+"|");
           //t2.value = t2.value +cr1+"Rec:" +arrr[i][3]+ " |"+rec_st+"|";
           rec_ct++;

           arrr2[rec_ct]=new Array(3);
           arrr2[rec_ct][0]=arrr[i][3];
           start_at=0;
           xxx = true;
           istop=0;
           pair1=0;
           while(xxx && istop<10) {
              xxx = getNextPair(rec_st,start_at,rets2 );  
              Glob_stat="in.fun.pullRecords st:"+(arrr[i][1]+1) +" i:"+pair1;
              //alert("In --do-- return found/mid/end:" + rets2[0] + "/"+mid1 + "/"+ rets2[1] + " |tag|val|" + rets2[2] + "|" + rets2[3] + "|");
              if (xxx ) {
                 //t2.value = t2.value + "st pos:" + found_at + " tag|" + tag1 + "| value|" + value1 + "|" + cr1;
                 arrr2[rec_ct][pair1+1]=rets2[2];
                 arrr2[rec_ct][pair1+2]=rets2[3];
                 pair1 +=2;
              }	//if
              start_at=rets2[1]+1;
              istop++;
           }	//while
           }	//if for len>1
           
        }	//if
    }		//for
}		//function pullRecords

//new window**************
function openwindow()
{
	top.consoleRef=window.open("","mywindow","menubar=1,resizable=1,width=550,height=250,scrollbars=1");
        top.consoleRef.document.writeln("------new output window------------");
        //top.consoleRef.document.writeln("<br><br>second line in test window------------");
        //top.consoleRef.document.close()
	return top.consoleRef;
}

//new debug window**************
function debugwindow(txt_str)
{
        Glob_stat="start.fun.debugwindow";
	top.consoleRef=window.open("","mywindow","menubar=1,resizable=1,width=550,height=250,scrollbars=1");
        Glob_stat="start.fun.debugwindow:2";
        //top.consoleRef.document.writeln("<p style='text-align: center;'>------new debug window------</p>");
        top.consoleRef.document.writeln("<br><tt>"+txt_str+"</tt>");
        //top.consoleRef.document.close()
	//return top.consoleRef;
        Glob_stat="end.fun.debugwindow";
}

//investigate other elements (file path) ****************************************
//do something on go click
function doSomething1(element) 
{
    Glob_stat="start.fun.doSomething1";
    var db1 = element.form.dodebug;
    if (db1.checked) debugwindow("<br><br>----new run----");
    var t1 = element.form.textarea1;
    //alert("start w/:" + t1.value + "::");
    var t2 = element.form.textarea2;
    var name = element.name;
    var t_date = new Date();
    var cr1 = String.fromCharCode(13);
    found_at=-11;
    end_at=-1;
    tag1="tag";
    value1="value";
    mid1="undef--";
    rets = new Array();
    var t_time = t_date.toLocaleTimeString();
    strt_msg="Run at:"+ t_time;
    if (!prod_flag) strt_msg=strt_msg + " Debug:"+db1.checked;
    t2.value =  strt_msg +cr1; //t2.value +
    //t2.value = t2.value + printable(t1.value);
    out_ar = new Array();
    out_ar2 = new Array();

    if (t1.value.length==0) {
       Glob_stat="in.fun.doSomething1 empty";
       t2.value = t2.value + cr1+ " You need to cut and past a JBOS file exported from"+
          " Concord Desktop into the input area.";
    } else {
    //zzxx=openwindow();
    //zzxx.document.writeln("<br>---from other routine---");
    Glob_stat="in.fun.doSomething1 go";
    if (db1.checked) debugwindow("Glob_stat:"+Glob_stat+" len out_ar:"+out_ar.length+"|");
    doSplit1(element,out_ar);
    Glob_stat="in.fun.doSomething1 go2";
    if (db1.checked) debugwindow("Glob_stat:"+Glob_stat+" len out_ar:"+out_ar.length+"|");
    //dumpArr(element,out_ar);
    pullRecords(element,out_ar,out_ar2);
    Glob_stat="in.fun.doSomething1 go3";
    if (db1.checked) debugwindow("Glob_stat:"+Glob_stat+" len out_ar2:"+out_ar2.length+"|");
    //dumpArr2(element,out_ar2);
    //win_dump(zzxx,out_ar,out_ar2);
    format_out(element,out_ar2);
    }
    t2.value = t2.value + cr1+ "---the end---" + cr1;

    Glob_stat="end.fun.doSomething1";

}

// This generic function appends details of an event to the big Textarea
// element in the form above. It will be called from various event handlers.
function report(element, event) 
{
    //alert("function report="+text3_flag);
    if (text3_flag) var t = element.form.textarea3;
    var name = element.name;
    if ((element.type == "select-one") || (element.type == "select-multiple")){
        value = " ";
        for(var i = 0; i < element.options.length; i++)
            if (element.options[i].selected) 
                value += element.options[i].value + " ";
    }
    else if (element.type == "textarea") value = "...";
    else value = element.value;
    var msg = event + ": " + name + ' (' + value + ')\n';
    if (text3_flag) t.value = t.value + msg;
}
// This function adds a bunch of event handlers to every element in a form.
// It doesn't bother checking to see if the element supports the event handler,
// it just adds them all. Note that the event handlers call report() above.
function addhandlers(f)
{
    if (text3_flag) {
    for(var i = 0; i < f.elements.length; i++) {
        var e = f.elements[i];
        e.onclick = new Function("report(this, 'Click')");
        e.onchange = new Function("report(this, 'Change')");
        //e.onfocus = new Function("report(this, 'Focus')");
        //e.onblur = new Function("report(this, 'Blur')");
        e.onselect = new Function("report(this, 'Select')");
    }
    
    // Special case handlers for the buttons:  this.form.textarea1.value='';
    f.gobutton.onclick = 
        new Function(" report(this, 'GoClick'); doSomething1(this)");
/*    f.submitbutton.onclick = 
        new Function("report(this, 'Click'); return false");
*/
    f.resetbutton.onclick = 
        new Function("this.form.reset(); report(this, 'Click'); return false");
    } else {
    f.gobutton.onclick = 
        new Function(" doSomething1(this)");
    f.resetbutton.onclick = 
        new Function("this.form.reset();  return false");
    }	//if else end
}
// Activate our form by adding all possible event handlers!

addhandlers(document.everything);

/* rrt=get_db_flg();
alert("testing debug checked  "+ rrt);	*/

if (!prod_flag) document.writeln("<br><br>this is the END OF test javascript pkg");
if (!prod_flag) alert("Javascript test end");

//end-->
