// IMAGE PRELOAD

servicestab = new Image();
servicestab.src = "images/services-tab-hover.gif";
signup = new Image();
signup.src = "images/button-signup-hover.jpg";
menuhover = new Image();
menuhover.src = "images/menu-hover.gif";
sendhover = new Image();
sendhover.src = "images/button-send-hover.jpg";




//slideshow script v3
function startSlideshow(path, numimgs, numslots, timer, rnd, start, imagetype)
{
  if (typeof imagetype == "undefined") {
      imagetype = "jpg";
  }

  if (start==0) var firstimg = 1 + Math.floor(Math.random()*numimgs);   // random first image
      else var firstimg = start;
       // we use base 0 for our slot calculations
  var delay = timer + ( Math.random()*rnd)- (rnd/2)  // random length of time if rnd is non-zero
  window.setTimeout('cueNextSlide("'+path+'",'+firstimg+','+numimgs+',0,'+numslots+','+timer+','+rnd+',"'+imagetype+'")', delay*500);
}
function cueNextSlide(path, imgno, numimgs, slotno, numslots, timer, rnd, imagetype)
{
  if (slotno >= numslots) { toback=false; } else { toback=true;  }
  var nextimg = (imgno % numimgs) + 1;
  var nextimgforthisslot = ((imgno+numslots)%numimgs)+1
  var nextslot = (slotno+1)%(numslots*2);
  var thisslot = (slotno%numslots)+1;
  var frontId = path+'-sl'+thisslot+'front';
  var backId = path+'-sl'+thisslot+'back';
  var delay = timer + ( Math.random()*rnd)- (rnd/2);  // random length of time if rnd is non-zero
  if (toback) {
     window.setTimeout('changeimg("front","'+path+'","'+thisslot+'","'+nextimgforthisslot+'","'+imagetype+'")', delay*750);
     fade(backId,0.5, 'in');
     fade(frontId, 0.5, 'out');
  }
  else
  {
     window.setTimeout('changeimg("back","'+path+'","'+thisslot+'","'+nextimgforthisslot+'","'+imagetype+'")', delay*750);
     fade(frontId,0.5,'in');
     fade(backId,0.5,'out');
  }
  window.setTimeout('cueNextSlide("'+path+'",'+nextimg+','+numimgs+','+nextslot+','+numslots+','+timer+','+rnd+',"'+imagetype+'")', delay*1000);
}
function changeimg(layer, path, thisslot, imgno,imagetype)
{
  var chgimgId = path+'-sl'+thisslot+layer;
  chgimg = document.getElementById(chgimgId);
  chgimg.src="images/"+path+"/sshow"+imgno+"."+imagetype;
}
function fade(img, time, dir)
{
  img = document.getElementById(img);
  var steps=time*10;
  if (typeof img.style.opacity != 'undefined')
  {
    var otype='w3c';
  }
  else if (typeof img.style.MozOpacity != 'undefined')
  {
    var otype='moz';
  }
  else if (typeof img.style.MKhtmlOpacity != 'undefined')
  {
    var otype='khtml';
  }
  else if (typeof img.filters =='object')
  {
    otype = (img.filters.length >0
      && typeof img.filters.alpha == 'object'
      && typeof img.filters.alpha.opacity == 'number')
      ? 'ie' : 'none';
  }
  else { otype = 'none';}
  if (otype != 'none')
  {
    if (dir == 'out') { dofade(steps,img,1,false,otype);}
    else { dofade(steps, img, 0, true, otype); }
  }
}
function dofade(steps, img, value, targetvisibility, otype)
{
  value += (targetvisibility ? 1 : -1) / steps;
  if (targetvisibility ? value >1 : value <0)
    value = targetvisibility ? 1:0;
  setfade(img,value,otype);
  if (targetvisibility ? value <1 : value >0)
  {
    setTimeout(function()
    {
      dofade(steps, img, value, targetvisibility, otype);
    }, 100);
  }
}
function setfade(img,value, otype)
{
  switch(otype)
  {
    case 'ie':
      img.filters.alpha.opacity = value * 100;
      break;
    case 'khtml':
      img.style.KhtmlOpacity = value;
      break;
    case 'moz':
      img.style.MozOpacity = (value==1?0.9999999 : value);
      break;
    default:
      img.style.opacity = (value == 1?0.9999999 : value);
  }
}