function setupimg()
{
   var imgs = document.getElementsByTagName("img");
   for (i = 0; i < imgs.length; i++) {
     if (imgs.item(i).getAttribute("hoversrc")) {
        var elm = imgs.item(i);
        if (window.navigator.userAgent.indexOf("MSIE") > 0 ) {
           elm.attachEvent("onmouseover", turnOn);
           elm.attachEvent("onmouseout",  turnOff);
        }
        else {
           elm.addEventListener("mouseover",turnOn,false);
           elm.addEventListener("mouseout",turnOff,false);
        }
     }
   }  
   var input_imgs = document.getElementsByTagName("input");
   for (i = 0; i < input_imgs.length; i++) {
     if (input_imgs(i).getAttribute("type") == "image") {
       if (input_imgs.item(i).getAttribute("hoversrc")) {
         var elm = input_imgs.item(i);
         if (window.navigator.userAgent.indexOf("MSIE") > 0 ) {
             elm.attachEvent("onmouseover", turnOn);
             elm.attachEvent("onmouseout",  turnOff);
          }
          else {
             elm.addEventListener("mouseover",turnOn,false);
             elm.addEventListener("mouseout",turnOff,false);
          }
        }
      }
    }

   var anchors = document.getElementsByTagName("a");
   for (i = 0; i < anchors.length; i++) {
      if (anchors[i].getAttribute("hoversrc")) {
         // Check to see if it has an img that doesn't have
         // the hoversrc attribute and it is the first child
         // if it does have the hoversrc then it should be
         // already setup from the first for above
         var a = anchors.item(i);
         if (a.firstChild && (a.firstChild.tagName == "img" || a.firstChild.tagName == "IMG")) {
            var elm = a.firstChild;
            if (!elm.getAttribute("hoversrc")) {
               // It doesn't but the anchor element does so added to it
               // for the turnOn can work.
               elm.setAttribute("hoversrc",a.getAttribute("hoversrc"));

               if (window.navigator.userAgent.indexOf("MSIE") > 0 ) {
                   elm.attachEvent("onmouseover", turnOn);
                   elm.attachEvent("onmouseout",  turnOff);
                }
                else {
                   elm.addEventListener("mouseover",turnOn,false);
                   elm.addEventListener("mouseout",turnOff,false);
               }
            }
         }
      }
   }
}

function turnOn(e) {
   var element;
   if (window.navigator.userAgent.indexOf("MSIE") > 0 )
      element = window.event.srcElement;
   else
      element = e.target;
	if (element.filters != null && element.filters[0] != null)
         element.filters[0].apply();
	element.offSrc = element.src;
	if (element.getAttribute("hoversrc"))
	   element.src = element.getAttribute("hoversrc");
	if (element.filters != null && element.filters[0] != null)
		   element.filters[0].play();
}

function turnOff(e) { 
   var element;
   if (window.navigator.userAgent.indexOf("MSIE") > 0 )
      element = window.event.srcElement;
   else
      element = e.target;
	if(element.filters != null && element.filters[0] != null)
      element.filters[0].stop();
	if (element.offSrc)
	   element.src = element.offSrc;
}
