var imgs = new Array("images/homepic1.jpg", "images/homepic2.jpg", "images/homepic3.jpg", "images/homepic4.jpg"),
preloadimgs = new Array(), showd=document.getElementById("idhomeshow"), n = 0;
var opcount=0, opvalfg=1, opval=0, showtime, optime, stopind=true;

if (!ie)
{
document.write('<div><a href="#" onclick="showstop()" title="Click to Stop / Start"><img id="idhomeshowfg" src="images/homepic1.jpg" width="580" height="190" border="0" alt="Click to Stop / Start"></a></div><div><a href="#" onclick="showstop()" title="Click to Stop / Start"><img id="idhomeshown" src="images/homepic1.jpg" width="580" height="190" border="0" alt="Click to Stop / Start"></a></div>');
var showfgd=document.getElementById("idhomeshowfg"), shownd=document.getElementById("idhomeshown");
}
if (nn)
{
document.write('<div><img id="idhomeshownn" src="images/homepic1.jpg" width="580" height="190" border="0" alt="Click to Stop / Start"></div><div><img id="idhomeshow2nn" src="images/homepic1.jpg" width="580" height="190" border="0" alt="Click to Stop / Start"></div>');
var shownnd=document.getElementById("idhomeshownn");
}
if (!ie)
{
   showd.style.visibility = 'hidden';
   set_poshow();
}

function set_poshowre()
{
   set_pos();
   if (!ie)
      set_poshow();
}

function set_poshow()
{
   showfgd.style.left = posleft + 28 + "px";
   shownd.style.left = posleft + 28 + "px";
   showfgd.style.visibility = 'visible';
   shownd.style.visibility = 'visible';
   if (nn)
   {
      shownnd.style.left = posleft + 28 + "px";
      shownnd.style.visibility = 'visible';
   }
}

function preloadshow()
{
  for (var i = 0; i < imgs.length; i++)
  {
    preloadimgs[i] = new Image();
    preloadimgs[i].src = imgs[i];
  }
   showpics(1, 9000, 6000, 50, .02, 10, .1);
   window.onresize=set_poshowre;
}

function showpics(firstind, delayinit, delay, loop, valinc, loopnn, valincnn)
{
   if (firstind == 1)
   {
     delayst = delayinit;
     delayo = delay;
     loopo = loop;
     valinco = valinc;
     looponn = loopnn;
     valinconn = valincnn;
     showtime = setTimeout ("showpics(0, 0, 0, 0, 0, 0, 0)", delayst);
   }
   else
   {
       if (ie)
       {
          (n == (imgs.length - 1)) ? n = 0: n++;
          showd.style.filter="blendTrans(duration=0.5)";
          showd.filters.blendTrans.Apply();
          showd.src= preloadimgs[n].src;
          showd.filters.blendTrans.Play();
          showtime = setTimeout ("showpics(0, 0, 0, 0, 0, 0, 0)", delayo);
       }
       else
       {
          if (!nn)
          {
	(n == (imgs.length - 1)) ? n = 0: n++;
	shownd.src = preloadimgs[n].src;
	opvar();
          }
          else
             opvarnn();
       }
   }
}

function opvar()
{
    if (opcount < loopo)
    {
       opvalfg = opvalfg - valinco;
       opval = opval + valinco;
       showfgd.style.opacity = opvalfg;
       shownd.style.opacity = opval;
       opcount +=  1;
       opvartime = setTimeout ("opvar()", 0);
    }
    else
    {
       showfgd.src = preloadimgs[n].src;
       showfgd.style.opacity = 1;
       shownd.style.opacity = 0;
       clearTimeout(opvartime);
       opcount = 0;
       opvalfg = 1;
       opval = 0;
       optime = setTimeout ("showpics(0, 0, 0, 0, 0, 0, 0)", delayo);
    }
}

function opvarnn()
{
    if (opcount < looponn)
    {
       opvalfg = opvalfg - valinconn;
       opval = opval + valinconn;
       if (opcount == 1)
       {
          (n == (imgs.length - 1)) ? n = 0: n++;
          shownd.src = preloadimgs[n].src;
       }
       else
       if (opcount == looponn - 1)
            shownnd.src = preloadimgs[n].src;
       showfgd.style.opacity = opvalfg;
       shownd.style.opacity = opval;
       opcount +=  1;
       opvartime = setTimeout ("opvarnn()", 0);
    }
    else
    {
       showfgd.src = preloadimgs[n].src;
       showfgd.style.opacity = 1;
       shownd.style.opacity = 0;
       clearTimeout(opvartime);
       opcount = 0;
       opvalfg = 1;
       opval = 0;
       optime = setTimeout ("showpics(0, 0, 0, 0, 0, 0, 0)", delayo);
    }
}

function showstop()
{
   if (stopind)
   {
      clearTimeout(showtime);
      clearTimeout(optime);
      stopind = false;
   }
   else
   {
      stopind = true;
      showpics();
   }
}
