!reset appletdir

!set appletdir=!getopt applet in $(replyoption$i)
!if $appletdir issametext imagedir
  !set appletdir=$imagedir
!endif
!default appletdir=java/jmol

!distribute lines $(reply$i) into score,selgood,selbad,selforget,ans_sc1,ans_orient
!for j in selgood,selbad,selforget
  !set $j=!translate {()} to $ $ $ $ $ in $($j)
  !set $j=!singlespace $($j)
  !set $j=!words2items $($j)
  !set $j=!values x+1 for x in $($j)
!next
!set for_feedback=$selgood;$selbad;$selforget

nbsel=!getopt nb_select in $(replyoption$i)

!distribute lines $oef_applet_option into size,file,ans_sc0,ans_sc2
!if __http isin __$ans_sc0
  ans_file0=$ans_sc0
  !reset ans_sc0
!endif

!if __http isin __$ans_sc2
  ans_file2=$ans_sc2
  !reset ans_sc2
!endif

!if $wims_read_parm=nocompare
  reply$i=$(m_reply$i)
  !set for_feedback=$selbad
  !goto applet
!endif

!if $score=10
 diareply$i=good
 !advance freegot
!else
   diareply$i=bad
   freegot=$[$freegot+$score]
!endif

:applet

reply_$i=<script type="text/javascript" src="$appletdir/Jmol.js"></script>
reply_$i=$(reply_$i)

reply_$i=$(reply_$i)<script type="text/javascript">\
    jmolInitialize('$appletdir','JmolApplet.jar');\
    jmolSetAppletColor('white');\
    var sc0='$ans_sc0';\
    var sc2='$ans_sc2';\
    var sc1='$ans_sc1';\
    var orient='$ans_orient';\
var jscr='load $file;';\
    jscr= jscr +'selectionhalos on;select none; color selectionHalos blue;';\
    jscr= jscr +'set frank on;set DisablePopupMenu TRUE; hover off; \n';\
    jscr= jscr +'set picking off;\n';\
\
    jmolApplet([$size],jscr+sc0+orient+sc1+sc2);
!if $ans_file0!=$empty
    reply_$i=$(reply_$i)\
    jmolScriptWait('script $ans_file0;');
!endif
!if $ans_file2!=$empty
    reply_$i=$(reply_$i)\
    jmolScriptWait('script $ans_file2;');
!endif
reply_$i=$(reply_$i)\
</script>

!set reply_$i=$(reply_$i)
!set m_reply$i=$for_feedback
!set reply$i=
