
/** 
* ÆÄÀÏ¸í: lib.rollover.js 
* ¼³  ¸í: ·Ñ¿À¹ö ÀÚµ¿È­ ¶óÀÌºê·¯¸® 
* ÀÛ¼ºÀÚ: jstoy project 
* ³¯  Â¥: 2003-10-28 
* 
* 2002-11-05: °ÅÄ£¸¶·ç 
* 2003-10-24: xtac.net 
* 2003-10-29: laintt 
*********************************************** 
*/ 

Roll = function() { 
   if (!document.body.getAttribute) return false; 
   this.outMark  = "_on"; 
   this.overMark = "_off"; 
   this.num      = 0; 
   this.outList  = new Array; 
   this.overList = new Array; 
   this.evalList = new Array; 
   this.outSearch = new RegExp(this.outMark + "(\.[^\.]+)$"); 
   this.init(document.images); 
   if (document.getElementsByTagName) { 
      this.init(document.getElementsByTagName("input")); 
   } 
} 
Roll.prototype.init = function() { 
   Roll.object = this; 
   Roll.image = ''; 
   for (var i=0, s=arguments[0].length; i<s; i++) { 
      if (arguments[0][i].getAttribute("roll") !== null) { 
         Roll.image = arguments[0][i]; 
         Roll.image.setAttribute("roll", ++this.num); 
         this.outList[this.num]  = new Image; 
         this.overList[this.num] = new Image; 
         this.outList[this.num].src  = Roll.image.src;
         if (Roll.image.getAttribute("oversrc")) { 
            this.overList[this.num].src = Roll.image.getAttribute("oversrc"); 
         } else { 
            this.overList[this.num].src = Roll.image.src.replace(this.outSearch, this.overMark + "$1"); 
         } 
         if (document.all) { 
            if (Roll.image.onmouseover) { 
               eval("Roll.image._onmouseover=function()" + Roll.image.onmouseover.toString().replace(/^[^)]+\)/,'')); 
               Roll.image.onmouseover= function() { 
                  this._onmouseover(); 
                  Roll.object.doOver(this); 
               } 
            } else { 
               Roll.image.onmouseover= function() { 
                  Roll.object.doOver(this); 
               } 
            } 
            if (Roll.image.onmouseout) { 
               eval("Roll.image._onmouseout=function()" + Roll.image.onmouseout.toString().replace(/^[^)]+\)/,'')); 
               Roll.image.onmouseout= function() { 
                  this._onmouseout(); 
                  Roll.object.doOut(this); 
               } 
            } else { 
               Roll.image.onmouseout= function() { 
                  Roll.object.doOut(this); 
               } 
            } 
         } else if (Roll.image.addEventListener) { 
            Roll.image.addEventListener('mouseover', function(){Roll.object.doOver(this)}, true); 
            Roll.image.addEventListener('mouseout',  function(){Roll.object.doOut (this)}, true); 
         } else { 
            return false; 
         } 
      } 
   } 
} 
Roll.prototype.doOver = function(img) { 
   img.src = this.overList[img.getAttribute("roll")].src; 
} 
Roll.prototype.doOut = function(img) { 
   img.src = this.outList[img.getAttribute("roll")].src; 
} 