<!--
// Image MouseOver Opacity (10-Jan-2006)
// by Vic Phillips http://www.vicsjavascripts.org.uk

// Application Notes

// The MouseOver and MouseOut Images are nested in a <DIV>
// The first image is the MouseOver Image
// The second image is the MouseOut Image
// The <DIV> must have a specified style position of absolute or relative;
// The images must have a specified style position of absolute; and left:0px;top:0px;
//
// <div id="Thumbs2" style="position:relative;width:50px;height:50px;" onmouseover="zxcOpacityMouse(this,2,50);" onmouseout="zxcOpacityMouse(this);" >
//  <img src="http://www.vicsjavascripts.org.uk/StdImages/One.gif" width=50 height=50  style="position:absolute;left:0px;top:0px;" >
//  <img src="http://www.vicsjavascripts.org.uk/StdImages/Two.gif" width=50 height=50 style="position:absolute;left:0px;top:0px;"  >
// </div>

// The mouseover function zxcOpacityMouse(this,2,50);
// parameter 0 = the mouseover object, this or the unique ID Name       (object or string)
// parameter 1 = the Opacity increment (1 = minimum = slow)             (digit)
// parameter 2 = the Opacity speed in milliSeconds (minimum = 5 = fast) (digit)

// The mouseout function zxcOpacityMouse(this,5,5);
// parameter 0 = the mouseover object, this or the unique ID Name (object or string)
// parameters 1 and 2 are option, if omitted the mouseover parameters are used
// parameter 1 = the Opacity increment (1 = minimum = slow)             (digit)
// parameter 2 = the Opacity speed in milliSeconds (minimum = 5 = fast) (digit)

// All variable, function etc. names are prefixed with 'zxc' to minimise conflicts with other JavaScripts
// These charactors are easily changed to charactors of choise using global find and replace.

// The Functional Code(2.5K) is best as an External JavaScript

// Tested with IE6 and Mozilla FireFox


// Functional Code - NO NEED to Change

var zxcCnt=0;
var zxcCkOpc=false;

function zxcOpacityMouse(zxcm,zxci,zxcd){
 if (typeof(zxcm)=='string'){ zxcm=document.getElementById(zxcm); }
 if (!zxcm.obj){
  if (!zxci){ zxci=5; }
  if (!zxcd){ zxcd=15; }
  zxcm.obj=new zxcOOPOpcMse(zxcm.getElementsByTagName('IMG'));
  zxcm.obj.imgT.zIndex='1';
  if (zxcm.style.MozOpacity!=null||zxcm.style.opacity!=null||zxcm.style.filter!=null||zxcm.style.KHTMLOpacity!=null){
   zxcCkOpc=true;
  }
 }
 if (zxci){ zxcm.obj.inc=zxci; }
 if (zxcd){ zxcm.obj.delay=zxcd; }
 if (zxcm.obj.inc<1){ zxcm.obj.inc=1; }
 if (zxcm.obj.delay<5){ zxcm.obj.delay=5; }
 clearTimeout(zxcm.obj.to);
 if (zxcm.obj.updown){
  zxcm.obj.updown=false;
  if (!zxcCkOpc){ zxcm.obj.imgT.zIndex='0'; zxcm.obj.imgB.zIndex='1'; }
  zxcm.obj.up();
 }
 else {
  zxcm.obj.updown=true;
  if (!zxcCkOpc){ zxcm.obj.imgB.zIndex='0'; zxcm.obj.imgT.zIndex='1';  }
  zxcm.obj.down();
 }
}

function zxcOOPOpcMse(zxcimgs){
 this.imgT=zxcimgs[1].style;
 this.imgB=zxcimgs[0].style;
 this.ref='zxcimgmo'+zxcCnt;
 window[this.ref]=this;
 this.updown=true;
 this.cnt=0;
 this.min=0;
 this.max=100;
 this.to=null;
 zxcCnt++;
}

zxcOOPOpcMse.prototype.up=function(){
 if(!this.updown){
  this.cnt+=this.inc;
  if(this.cnt<=this.max){
   zxcOpacity(this.imgB,this.cnt)
   zxcOpacity(this.imgT,(100-this.cnt));
   this.setTimeOut("up();",this.delay);
  }
  else {
   zxcOpacity(this.imgB,this.max)
   zxcOpacity(this.imgT,this.min)
  }
 }
}

zxcOOPOpcMse.prototype.down=function(){
 if(this.updown){
  this.cnt-=this.inc;
  if(this.cnt>=this.min){
   zxcOpacity(this.imgB,this.cnt)
   zxcOpacity(this.imgT,(100-this.cnt));
   this.setTimeOut("down();",this.delay);
  }
  else {
   zxcOpacity(this.imgB,this.min);
   zxcOpacity(this.imgT,this.max);
  }
 }
}

zxcOOPOpcMse.prototype.setTimeOut= function(zxcf,zxcd){
 this.to=setTimeout("window."+this.ref+"."+zxcf,zxcd);
}

function zxcOpacity(zxcobj,zxcop) {
 if (zxcop>100||zxcop<0){ return }
 if (zxcobj.MozOpacity!=null){ zxcobj.MozOpacity=(zxcop/100)-.001; }
 else if (zxcobj.opacity!=null){ zxcobj.opacity=(zxcop/100)-.001; }
 else if (zxcobj.filter!=null){ zxcobj.filter = 'alpha(opacity='+zxcop+')';     }
 else if (zxcobj.KHTMLOpacity!=null){ zxcobj.KHTMLOpacity=(zxcop/100)-.001; }
}

//-->
