/***********************************************************
			ebsScriptIndexOnly.js
Javascript for Emerald Business Systems Webpage
Written by Andy Silke on behalf of Emerald Business Systems
This copy of the script is specific to the index page as
it's pathing is different.
		   Last updated 12/21/2011
************************************************************/


/***********************************************************
This section is for our navigation bar and title at the top
of each page. It controls the rollover images, allowing us
to change the text to yellow when the links are hovered over
************************************************************/

//First we initialize our array variable to hold the images

Rollimage = new Array()
var i = 20

//Next we fill the array with the images

  Rollimage[0]= new Image(916,150)
  Rollimage[0].src = "navBars/ebstopbar.jpg"

  Rollimage[1] = new Image(916,150)
  Rollimage[1].src = "navBars/restaurant.jpg"

  Rollimage[2] = new Image(916,150)
  Rollimage[2].src = "navBars/retail.jpg"

  Rollimage[3] = new Image(916,150)
  Rollimage[3].src = "navBars/camera.jpg"

  Rollimage[4] = new Image(916,150)
  Rollimage[4].src = "navBars/cashregister.jpg"

  Rollimage[5] = new Image(916,150)
  Rollimage[5].src = "navBars/signage.jpg"

  Rollimage[6] = new Image(916,150)
  Rollimage[6].src = "navBars/accessories.jpg"

//Finally we write our functions to swap the images
//These are the functions that are called by our 
//"onMouseOver" events

  function Swap1(){
    document.restaurant.src = Rollimage[1].src;
    return true;
  }

  function Swap2(){
    document.restaurant.src = Rollimage[2].src;
    return true;
  }

  function Swap3(){
    document.restaurant.src = Rollimage[3].src;
    return true;
  }

  function Swap4(){
    document.restaurant.src = Rollimage[4].src;
    return true;
  }

  function Swap5(){
    document.restaurant.src = Rollimage[5].src;
    return true;
  }

  function Swap6(){
    document.restaurant.src = Rollimage[6].src;
    return true;
  }

  function SwapBack(){
    document.restaurant.src = Rollimage[0].src;
    return true;
  }


/***********************************************************
This next section handles our screenshots page for the e7.
We call the functions NextScreen() and PreviousScreen()
when the "Next" and "Previous" buttons are pushed. This
increments, or decriments the image count (respectively) and
then displays the image located at the new index. When we
increment or decriment past our bounds, we roll back to the
beginning or end of the count (respectively).


  Rollimage[20]= new Image(600,470)
  Rollimage[20].src = "images/quantity.jpg"

  Rollimage[21] = new Image(600,470)
  Rollimage[21].src = "images/86.jpg"

  Rollimage[22] = new Image(600,470)
  Rollimage[22].src = "images/repeatRound.jpg"

  Rollimage[23] = new Image(600,470)
  Rollimage[23].src = "images/tables.jpg"

  Rollimage[24] = new Image(600,470)
  Rollimage[24].src = "images/checkSlu.jpg"

  Rollimage[25] = new Image(600,470)
  Rollimage[25].src = "images/forcedMod.jpg"

  Rollimage[26] = new Image(600,470)
  Rollimage[26].src = "images/managerAuth.jpg"

  Rollimage[27] = new Image(600,470)
  Rollimage[27].src = "images/tab.jpg"


  function NextScreen(){
  	if (i==27)
  	{
  		i=20;
	}
  	else
  	{
  		i++;
  	}

    document.screenShot.src = Rollimage[i].src;
    return true;
  }

    function PreviousScreen(){
  	if (i==20)
  	{
  		i=27;
	}
  	else
  	{
  		i--;
  	}

      document.screenShot.src = Rollimage[i].src;
    return true;
  }
  ************************************************************/
  
  // Opacity and Fade in script.
  
  e7FadeArray = new Array()
  var j = 0
  
  e7FadeArray[0]= new Image(666,500)
  e7FadeArray[0].src = "images/slide1.jpg"
  
  e7FadeArray[1]= new Image(666,500)
  e7FadeArray[1].src = "images/slide2.jpg"

  e7FadeArray[2]= new Image(666,500)
  e7FadeArray[2].src = "images/slide3.jpg"
  
  function SetOpacity(object,opacityPct)
  {
    // IE.
    object.style.filter = 'alpha(opacity=' + opacityPct + ')';
    // Old mozilla and firefox
    object.style.MozOpacity = opacityPct/100;
    // Everything else.
    object.style.opacity = opacityPct/100;
  }
  
  function ChangeOpacity(id,msDuration,msStart,fromO,toO)
  {
    var element=document.getElementById(id);
    var opacity = element.style.opacity * 100;
    var msNow = (new Date()).getTime();
    opacity = fromO + (toO - fromO) * (msNow - msStart) / msDuration;
    if (opacity<0) 
      SetOpacity(element,0)
    else if (opacity>100)
      SetOpacity(element,100)
    else
    {
      SetOpacity(element,opacity);
      element.timer = window.setTimeout("ChangeOpacity('" + id + "'," + msDuration + "," + msStart + "," + fromO + "," + toO + ")",1);
    }
  }
  
  function FadeIn(id)
  {
    var element=document.getElementById(id);
    if (element.timer) window.clearTimeout(element.timer); 
    var startMS = (new Date()).getTime();
    element.timer = window.setTimeout("ChangeOpacity('" + id + "',1000," + startMS + ",0,100)",1);
  }
  
  function FadeOut(id)
  {
    var element=document.getElementById(id);
    if (element.timer) window.clearTimeout(element.timer); 
    var startMS = (new Date()).getTime();
    element.timer = window.setTimeout("ChangeOpacity('" + id + "',1000," + startMS + ",100,0)",1);
  }
  
  function FadeInImage(foregroundID,backgroundID)
  
  {

    if (j==2)
    {
    j=0;
    }
    else
    {
    j++;
    }    

    var foreground=document.getElementById(foregroundID);
    if (backgroundID)
    {
      var background=document.getElementById(backgroundID);
      if (background)
      {
        background.style.backgroundImage = 'url(' + foreground.src + ')';
        background.style.backgroundRepeat = 'no-repeat';
      }
    }
    SetOpacity(foreground,0);
    foreground.src = e7FadeArray[j].src;
    if (foreground.timer) window.clearTimeout(foreground.timer); 
    var startMS = (new Date()).getTime();
    foreground.timer = window.setTimeout("ChangeOpacity('" + foregroundID + "',1000," + startMS + ",0,100)",10);
  }





// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;
// Specify the image files
var Pic = new Array();
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = 'images/quote1.jpg'
Pic[1] = 'images/quote2.jpg'
//Pic[2] = '3.jpg'
//Pic[3] = '4.jpg'
//Pic[4] = '5.jpg'
//Pic[5] = '6.jpg'

// do not edit anything below this line
var t;
var j = 0;
var p = Pic.length;
var preLoad = new Array();
for (i = 0; i < p; i++) {
preLoad[i] = new Image();
preLoad[i].src = Pic[i];
}
function runSlideShow() {
if (document.all) {
document.images.SlideShow.style.filter="blendTrans(duration=2)";
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
document.images.SlideShow.filters.blendTrans.Apply();
}
document.images.SlideShow.src = preLoad[j].src;
if (document.all) {
document.images.SlideShow.filters.blendTrans.Play();
}
j = j + 1;
if (j > (p - 1)) j = 0;
t = setTimeout('runSlideShow()', slideShowSpeed);
}
