
// This loads all the listed images in a vector

  function ImageList(){
    var imgs     = [];
    var img_path = "";
    for (var i=0;i<arguments.length;i++)
     {
      j = arguments[i];
      imgs[i]     = new Image();
      img_path    = "./photo/home/img_"+j+".jpg";
      imgs[i].src = img_path;
     }
    imgs.index = 0;
    return imgs;}

// This sets the opacity of an element according to the brower in use

  function setOpacity(el, fOp){
    if (typeof el.style!="undefined"){
      if ( typeof el.style.MozOpacity!="undefined" )
        el.style.MozOpacity = fOp-0.001;
      else if ( typeof el.style.opacity!="undefined" )
        el.style.opacity = fOp;
      else if ( typeof el.style.KhtmlOpacity != "undefined" )
        el.style.KhtmlOpacity = fOp;
      else if ( typeof el.style.filter!="undefined"  )
        el.style.filter = "Alpha(Opacity="+(fOp*100)+")";}}

// This performs the opacity change

  function mix(delay){
    op = op +inc;

// If the opacity swing is done the slope must be inverted

    if ( op < 0 || op > 1 )
     {
      op = Math.round(op);

      if (op == 0)
       {
// updates (or restarts) the image index and 
// assigns the new source to the img element

      if ((imageList.index + 1) >= imageList.length)
       {imageList.index = 0}
      else
       {imageList.index=imageList.index+1};

        document.getElementById("frontg").src = imageList[imageList.index].src;
       };

      if (inc>0)
       {delay = 4000}
      else
       {delay = 1000};

      inc=-inc;
     }
    else
     {
      if (inc>0)
       {delay = 50}
      else
       {delay = 5};
    };

      setTimeout(mix,delay);
      setOpacity(document.getElementById("frontg"),op);

      }


