##
##  wml::des::rollover - RollOver-Style Image-Button
##  Copyright (c) 1997-2001 Ralf S. Engelschall, All Rights Reserved. 
##

#  The <preserve>/<restore> tags with multiple arguments require WML 2.0.3
#use wml::mod::version
<require 2.0.3 />

#use wml::std::tags

<set-var __ro:count=1 />

<define-tag rollover:jsfuncs>\
<javascript>
function ro_imgNormal(imgName) {
    if (document.images) {
        document[imgName].src = eval(imgName + '_n.src');
        self.status = '';
    }
}
function ro_imgOver(imgName, descript) {
    if (document.images) {
        document[imgName].src = eval(imgName + '_o.src');
        self.status = descript;
    }
}
</javascript>
<define-tag rollover:jsfuncs></define-tag>
</define-tag>

<define-tag rollover whitespace=delete>
<preserve name src oversrc href alt target hint />
<set-var %attributes />
<if "<get-var name />" "" <group
    <set-var name=unknown<get-var __ro:count /> />
    <increment __ro:count />
/>/>
<defvar alt <get-var href /> />
<defvar hint <get-var alt /> />
<defvar href "#" />
<rollover:jsfuncs />

<copy-var name __ro:name />
<copy-var src __ro:src />
<copy-var oversrc __ro:oversrc />
#   The <group> tag is to prevent the concatenation of the javascript code
<group "
#   Protect `name', `src' and `oversrc' variables from being overriden
#   by the <javascript> tag
<javascript>
if (document.images) {
    ro_img_<get-var __ro:name />_n = new Image();
    ro_img_<get-var __ro:name />_n.src = '<get-var __ro:src />';
    ro_img_<get-var __ro:name />_o = new Image();
    ro_img_<get-var __ro:name />_o.src = '<get-var __ro:oversrc />';
}
</javascript>
" />
<a href="<get-var href />" \
   <if <get-var target /> "target=\"<get-var target />\"" /> \
   onmouseover="ro_imgOver('ro_img_<get-var name />', '<get-var hint />'); return true" \
   onmouseout="ro_imgNormal('ro_img_<get-var name />'); return true" \
   onfocus="ro_imgOver('ro_img_<get-var name />', '<get-var hint />'); return true" \
   onblur="ro_imgNormal('ro_img_<get-var name />'); return true"\
   <attributes-quote <attributes-extract :a:(.*) %attributes /> />\
><img \
   name=ro_img_<get-var name /> \
   src="<get-var src />" \
   alt="<get-var alt />" \
   width=* height=* \
   border=0 \
   <attributes-quote <attributes-extract :img:(.*) %attributes /> />\
/></a>
<restore  name src oversrc href alt target hint />
</define-tag>

##EOF##
