/*<![CDATA[*/
// Slide Show Fade Application of Basic Element Animator (07-March-2008)
// by Vic Phillips http://www.vicsjavascripts.org.uk

// **** The HTML Code
// Images are defined and displayed in a parent DIV
// this DIV must be assigned a unique id name and have a style position defined a 'relative' or 'absolute'
// The Images must have a style position of 'absolute' and top and left of '0px'.
// Images may be nested in link tags in which case the image will be assigned a cursor of 'pointer' by the code.
// Clicking the image will link to the page specified by the href
// or if no href but assigned a title of a valid function name the image object will be passed to the function.

// **** Initialisation
// Normally initialised  from a <BODY> or window onload event call to function:
// zxcInitSlideShow(zxcid,zxcspd,zxchold,zxctxt,zxcauto)
// where:
// parameter 0 = the unique id name of the slide show patent node.                (string)
// parameter 1 = (optional) the speed of the fade effect in millSeconds.          (digits, default 1000)
// parameter 2 = (optional) the auto rotate hold delay between images.            (digits, default 4000)
// parameter 3 = (optional) the class name of the DIV to display the image title. (string)
// parameter 4 = (optional) to automaticaly start auto rotation.                  (string)
//
// Subsequent calls to zxcInitSlideShow may be used to modify parameters 1 and 2.

// **** Manual Controls (Rotate)
// The slideshow may be rotated by event calls to function:
// zxcSlideShow('tst',1,'auto');
// where:
// parameter 0 = the unique id name of the slide show patent node.                     (string)
// parameter 1 = 1 to rotate forward, -1 to rotate backwards, 0 to stop auto rotation. (1, -1 or 9)
// parameter 2 = (optional) to auto rotate.                                            (string)
//

// **** Manual Controls (GoTo)
// The slideshow may be forced to go to a specific image by event calls to function:
// zxcSlideShowGoTo('tst',0);
// where:
// parameter 0 = the unique id name of the slide show patent node.                     (string)
// parameter 1 = the image to goto.                                                    (1 to n)


// **** Functional Code - NO NEED TO CHANGE

function zxcInitSlideShow(zxcid,zxcspd,zxchold,zxctxt,zxcauto){
 var zxcp=document.getElementById(zxcid);
 if (!zxcp.slideshow) zxcp.slideshow=new zxcSlideShowOOP(zxcp,zxcspd,zxchold,zxctxt,zxcauto);
 else {
  var zxcoop=zxcp.slideshow;
  zxcoop.spd=zxcspd||zxcoop.spd;
  zxcoop.hold=zxchold||zxcoop.hold;
 }
}

function zxcSlideShowOOP(zxcp,zxcspd,zxchold,zxctxt,zxcauto){
 this.imgs=zxcp.getElementsByTagName('IMG');
 for (var zxc0=0;zxc0<this.imgs.length;zxc0++){
  zxcBAnimator('opacity',this.imgs[zxc0],(zxc0==0)?90:10,(zxc0==0)?100:0,10);
  zxcES(this.imgs[zxc0],{zIndex:(zxc0>0)?'0':'1',left:(zxcp.offsetWidth-this.imgs[zxc0].offsetWidth)/2+'px',top:(zxcp.offsetHeight-this.imgs[zxc0].offsetHeight)/2+'px',cursor:(this.imgs[zxc0].parentNode.tagName.toUpperCase()=='A')?'pointer':'default'});
  if (this.imgs[zxc0].style.cursor=='pointer'){
   this.imgs[zxc0].link=this.imgs[zxc0].parentNode.href||this.imgs[zxc0].parentNode.title||null;
   this.imgs[zxc0].parentNode.removeAttribute('title');
   this.imgs[zxc0].onclick=function(){
     if (window[this.link]) window[this.link](this);
     else if (this.link) window.top.location=this.link;
    }
  }
  if (zxctxt){
   this.imgs[zxc0].txt=zxcES('DIV',{visibility:(this.imgs[zxc0].title)?'visible':'hidden'},zxcp,this.imgs[zxc0].title||'');
   this.imgs[zxc0].txt.className=zxctxt;
   zxcBAnimator('opacity',this.imgs[zxc0].txt,(zxc0==0)?90:10,(zxc0==0)?100:0,10);
   this.imgs[zxc0].removeAttribute('title');
  }
 }
 this.p=zxcp;
 this.cnt=0;
 this.spd=zxcspd||1000;
 this.hold=zxchold||this.spd*4;
 this.to=null;
 if (zxcauto) this.to=setTimeout(function(zxcoop){return function(){zxcoop.auto(1);}}(this),this.hold);
}

zxcSlideShowOOP.prototype.rotate=function(zxcud,zxcgoto){
 zxcES(this.imgs[this.cnt],{zIndex:'0'});
 zxcBAnimator('opacity',this.imgs[this.cnt],this.imgs[this.cnt]['opacityoop'].data[0],0,this.spd)
 if (this.imgs[this.cnt].txt) zxcBAnimator('opacity',this.imgs[this.cnt].txt,this.imgs[this.cnt].txt['opacityoop'].data[0],0,this.spd)
 this.cnt+=zxcud||0;
 if (zxcgoto) this.cnt=zxcgoto-1;
 if (this.cnt>=this.imgs.length) this.cnt=0;
 if (this.cnt<0) this.cnt=this.imgs.length-1;
 zxcES(this.imgs[this.cnt],{zIndex:'1'});
 zxcBAnimator('opacity',this.imgs[this.cnt],this.imgs[this.cnt]['opacityoop'].data[0],100,this.spd)
 if (this.imgs[this.cnt].txt) zxcBAnimator('opacity',this.imgs[this.cnt].txt,this.imgs[this.cnt].txt['opacityoop'].data[0],100,this.spd)
}

zxcSlideShowOOP.prototype.auto=function(zxcud){
 this.rotate(zxcud);
 this.to=setTimeout(function(zxcoop){return function(){zxcoop.auto(zxcud);}}(this),this.hold);
}

function zxcES(zxcele,zxcstyle,zxcp,zxctxt){
 if (typeof(zxcele)=='string'){ zxcele=document.createElement(zxcele); }
 for (key in zxcstyle){ zxcele.style[key]=zxcstyle[key]; }
 if (zxcp){ zxcp.appendChild(zxcele); }
 if (zxctxt){ zxcele.appendChild(document.createTextNode(zxctxt)); }
 return zxcele;
}

function zxcSlideShow(zxcid,zxcud,zxcauto){
 var zxcoop=document.getElementById(zxcid).slideshow;
 if (!zxcoop) return false;
 clearTimeout(zxcoop.to);
 if (!zxcauto) zxcoop.rotate(zxcud);
 else if (zxcud) zxcoop.auto(zxcud);
}

function zxcSlideShowGoTo(zxcid,zxcnu){
 var zxcoop=document.getElementById(zxcid).slideshow;
 if (!zxcoop||!zxcoop.imgs[zxcnu-1]) return false;
 clearTimeout(zxcoop.to);
 zxcoop.rotate(0,zxcnu)
}

/*]]>*/