Location: PHPKode > scripts > rollover > rollover/rollover.php
<?PHP // Basic rollover image class works fine for all browsers and up to 1 layer
class rollover {
  
  VAR $dirapp ;   // root directory for the web
  VAR $layer ;    // layer where the img is placed
  VAR $imgname ;  // name in <img name="..." 
  VAR $baseimg ;  // src for the base image (deactivated)
  VAR $selimg ;   // src for the alt image (selected)
  VAR $alt ;      // alt text
  VAR $link ;     // link for the image
  
  function rollover($dirapp,$layer,$imgname,$baseimg,$selimg,$alt="",$link="#") {
    $this->dirapp = $dirapp ;
    $this->layer = $layer ;
    $this->imgname = $imgname ;
    $this->baseimg = $baseimg ;
    $this->selimg = $selimg ;
    $this->alt = $alt ;
    $this->link = $link;
  }
  
  function preload() {
    // MUST BE CALLED WITHIN <SCRIPT></SCRIPT> SECTION
    echo "preload('" . $this->imgname . "bas','". $this->dirapp . "images/" . $this->baseimg . "');\n" ;
    echo "preload('" . $this->imgname . "sel','". $this->dirapp . "images/" . $this->selimg . "');\n" ;
  }
  
  function image() {
    $size = GetImageSize($dirapp . "images/" . $this->baseimg) ;
    if ($this->layer == "") {
      echo "<a href='" . $this->link . "' onMouseOver=\"javascript:changeImage(null,'" . $this->imgname ."','".$this->imgname . "sel')\" onMouseOut=\"javascript:changeImage(null,'".$this->imgname ."','".$this->imgname . "bas')\"><img name='" . $this->imgname . "' border=0 width=" . $size[0] . " height=" . $size[1] . " src='" . $this->dirapp . "images/".$this->baseimg ."' alt='" . $this->alt . "'></a>" ;
    } else {
      echo "<a href='" . $this->link . "' onMouseOver=\"javascript:changeImage('" . $this->layer . "','" . $this->imgname ."','".$this->imgname . "sel')\" onMouseOut=\"javascript:changeImage('" . $this->layer . "','".$this->imgname ."','".$this->imgname . "bas')\"><img name='" . $this->imgname . "' border=0 width=" . $size[0] . " height=" . $size[1] . " src='" . $this->dirapp . "images/".$this->baseimg ."' alt='" . $this->alt . "'></a>" ;    
      }
  }
}
?>
Return current item: rollover