﻿function setOpacity(obj, opacity)
{
  opacity = (opacity == 100)?99.999:opacity;
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeOut(objId,opacity) 
{
  if (document.getElementById)
  {
    obj = document.getElementById(objId);
    if (opacity >= 0)
    {
      setOpacity(obj, opacity);
      opacity -= 10;
      window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 75);
    }
  }
}

function fadeIn(objId,opacity) 
{
  if (document.getElementById)
  {
    obj = document.getElementById(objId);
    
    if (opacity <= 100)
    {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 50);
    }
  }
}

var _photoIdx = 0;
var _photos = null;

function setClientPhotos(photos) 
{
    _photos = photos.split(',');
    var o = document.getElementById('ClientLogo');
    var photoDetail = _photos[0].split('|');
    o.src = './images/content/clients/' + photoDetail[0];
    o.style.visibility = 'visible';
}

function doClientGallery(photoIdx) {
    // Ensure next photo in sequence has loaded
    if (photoIdx + 1 >= _photos.length)
        MM_preloadImages('./images/content/clients/' + _photos[0].substring(0, _photos[0].indexOf('|')));
    else
        MM_preloadImages('./images/content/clients/' + _photos[photoIdx + 1].substring(0, _photos[photoIdx + 1].indexOf('|')));
    
    fadeOut('ClientLogo', 100)
    setTimeout('flip(' + photoIdx.toString() + ');', 1250);
    _photoIdx = photoIdx;                
    if(photoIdx+1 >= _photos.length)
        photoIdx = -1;
    setTimeout('doClientGallery(' + (photoIdx + 1).toString() + ')', 7500);
}

function flip(photoIdx)
{
    var o = document.getElementById('ClientLogo');
    var ol = document.getElementById('ClientLogoLink');
    var photoDetail = _photos[photoIdx].split('|');
    o.style.visibility = 'visible';
    o.src = './images/content/clients/' + photoDetail[0];
    if (photoDetail.length > 1 && photoDetail[1].length > 0)
        ol.href = photoDetail[1];
    else
        ol.href = '';
    setTimeout('fadeIn(\'ClientLogo\', 0);', 100);
}

function MM_preloadImages() 
{
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}