﻿// JScript File
var slideShowSpeed = 2000;
var crossFadeDuration = 1;
var nWindows = 3;
var nCurrentWindow = 0;
var Pic = new Array();
Pic[0] = 'images/casa/Slideshow/1.gif';
Pic[1] = 'images/casa/Slideshow/2.gif';
Pic[2] = 'images/casa/Slideshow/3new.gif';
Pic[3] = 'images/casa/Slideshow/4.gif';
Pic[4] = 'images/casa/Slideshow/5.gif';
Pic[5] = 'images/casa/Slideshow/6.gif';
Pic[6] = 'images/casa/Slideshow/7new.gif';
Pic[7] = 'images/casa/Slideshow/8.gif';
Pic[8] = 'images/casa/Slideshow/9.gif';
var t;
var j = nWindows;
var p = Pic.length;
var preLoad = new Array();
function setupSlideShow(bIsPrivateDining)
{
   if (bIsPrivateDining == true)
   {
        nWindows = 1; 
        var Pic = new Array();
        //Pic[0] = 'images/casa/PrivateDining/1.gif';
        //Pic[1] = 'images/casa/PrivateDining/2.gif';
        //Pic[2] = 'images/casa/PrivateDining/3.gif';
        //Pic[3] = 'images/casa/PrivateDining/4.gif';
        Pic[0] = 'images/casa/PrivateDining/5.gif';
        Pic[1] = 'images/casa/PrivateDining/6.gif';
        j = 1;
        p = 2;
        preLoad = new Array();
        preLoad[0] = new Image();
        preLoad[1] = new Image();
        //preLoad[2] = new Image();
        //preLoad[3] = new Image();
        //preLoad[4] = new Image();
        //preLoad[5] = new Image();
        preLoad[0].src = Pic[0];
        preLoad[1].src = Pic[1];
        //preLoad[2].src = Pic[2];
        //preLoad[3].src = Pic[3];
        //preLoad[4].src = Pic[4];
        //preLoad[5].src = Pic[5];
   }
   else    
   {
        nWindows = 3;
        Pic = new Array();
        Pic[0] = 'images/casa/Slideshow/1.gif';
        Pic[1] = 'images/casa/Slideshow/2.gif';
        Pic[2] = 'images/casa/Slideshow/3new.gif';
        Pic[3] = 'images/casa/Slideshow/4.gif';
        Pic[4] = 'images/casa/Slideshow/5.gif';
        Pic[5] = 'images/casa/Slideshow/6.gif';
        Pic[6] = 'images/casa/Slideshow/7new.gif';
        Pic[7] = 'images/casa/Slideshow/8.gif';
        Pic[8] = 'images/casa/Slideshow/9.gif';
   
       preLoad = new Array(); 
        for (i = 0; i < p; i++)  {
          preLoad[i] = new Image();
          preLoad[i].src = Pic[i];
        }
   }
  setTimeout('runSlideShow()', 2500);
}
function opacity(id, opacStart, opacEnd, millisec) {
  var speed = Math.round(millisec / 100);
  var timer = 0;
  if(opacStart > opacEnd) {
    for(i = opacStart; i >= opacEnd; i--) {
      setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
      timer++; } }
  else if(opacStart < opacEnd) {
    for(i = opacStart; i <= opacEnd; i++) {
      setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
      timer++; } }
}
function changeOpac(opacity, id) {
  var object = document.getElementById(id).style;
  object.opacity = (opacity / 100);
  object.MozOpacity = (opacity / 100);
  object.KhtmlOpacity = (opacity / 100);
  object.filter = "alpha(opacity=" + opacity + ")";
}
function runIESlideshow() {
  if (nCurrentWindow == 0) { nCurrentWindow = 1; }
  if (nCurrentWindow > nWindows) {  nCurrentWindow = 1; }

//alert('nCurrentWindow=' + nCurrentWindow);  
  var theImage = document.getElementById ('SlideShow' + nCurrentWindow);
  nCurrentWindow++;
  var filterFunctionName=null;
  filterFunctionName = 'blendTrans(duration=' + crossFadeDuration + ')';
  theImage.style.filter = filterFunctionName;
  theImage.filters[0].Apply();
  theImage.src = preLoad[j].src;
  theImage.filters[0].Play();   
  return slideShowSpeed;
}
function runFireFoxSlideshow() {
  nCurrentWindow++;
  if (nCurrentWindow > nWindows) {  nCurrentWindow = 1; }
  var theImage = document.getElementById ('SlideShow' + nCurrentWindow);
  
  
  var theContainer = document.getElementById ('imgContainer' + nCurrentWindow )
  var strBgImg = theImage.src;
  theContainer.style.backgroundImage = "url(" + strBgImg + ")";
  changeOpac(0, 'SlideShow' + nCurrentWindow);
  theImage.src = preLoad[j].src;
  var i = 0;
  while (i <= 100) {
    self.setTimeout("changeOpac(" + i + ",'SlideShow" + nCurrentWindow + "')", i * 20);
    i+=2; 
  }
  return (slideShowSpeed + 500);
}
function runSlideShow() 
{
  var nWaitForNextPic = 2000;
  if (document.all) 
  {
    nWaitForNextPic = runIESlideshow(); 
  }
  else
  {
    nWaitForNextPic = runFireFoxSlideshow(); 
  }
  j = j + 1;
  if (j > (p - 1)) 
  {
    j = 0;
  }
  t = setTimeout('runSlideShow()', nWaitForNextPic);
}


