  // edit here to change slides
var homeslides= [
 ['banner-image-manwcups.jpg',
  'What is Business Intelligence?',
  '/what-is'], // end of first slide (note: comma after ']')
 ['banner-image-goldegg.jpg',
  'Find value in your business data. Now.',
  '/find-value-in-your-business-data-now' ], // end of second slide (note: comma after ']')
 ['banner-image-tablet.jpg',
  'Access, analyze, and understand your data.  Information delivered. Intelligently.',
  '/access-analyze-and-understand-your-data-information-delivered-intelligently'], // end of last slide (note: comma after ']')
['banner-image-puzzle.jpg',
  'Share information assets - easily. Make better decisions - faster.',
  '/share-information-assets-easily'], // end of last slide (note: comma after ']')
['banner-image-5x.jpg',
  '5x Technology…Building Value Through Business Intelligence.',
  false] // end of last slide (note: NO comma after ']')
];

 
function rotator(elm, items, name, link){
 this.$elm = $(elm);
 this.items = items;
 this.name = name;
 this.itemcount = items.length;
 this.currentitem = 0;
 this.olditem = items.length - 1;
 this.link = link

 this.additems();
 this.rotatecomplete(this)
 return this;
}
rotator.prototype.imgroot = '/Portals/92116/images/banner-images/';
rotator.prototype.rotate = function(rot){
 var backtostart = (rot.currentitem + 1 < rot.itemcount)? false : true;
 if(backtostart){
  var mycurrent = 'div#rotslide' + rot.currentitem;
  rot.olditem = rot.currentitem
  rot.currentitem = 0;
  rot.$elm.find('div#rotslide' + 0).show();
  rot.$elm.find(mycurrent).fadeOut( 1000 , function(){rot.rotatecomplete(rot)});
 }else{
  var mynext = 'div#rotslide' + (rot.currentitem + 1);
  rot.olditem = rot.currentitem;
  rot.currentitem += 1;
  rot.$elm.find(mynext).fadeIn( 1000 , function(){rot.rotatecomplete(rot)});
 }
}
rotator.prototype.rotatecomplete = function(rot){
 var backtostart = (rot.currentitem == 0)? true : false;
 rot.$elm.find('div#rotslide' + rot.olditem).hide();
 setTimeout(rot.name + '.rotate(' + rot.name + ')', 8000);
}
rotator.prototype.additems = function(){
 var link = ''
 var endlink = ''
 if(this.link){
  //alert(' link is : ' + this.link )
  link = '<a href="' + this.link + '">';
  endlink = '</a>';
 }
 for(i=0; i< this.items.length; i++){
  if(!this.link && this.items[i][2]){ // if link not set for whole banner, and there is a link provided as the third element of the item array
   endlink = '<a href="' + this.items[i][2] + '" class="rotatorbutton"><img src="'+ this.imgroot + 'clear.gif"></a>';
  }else if(!this.link){
   endlink = '';
  }
  if(!this.link && !this.items[i][2]){ // if link not set for whole banner, and there is a link provided as the third element of the item array
   endlink = '';
  }

  var hide = (i == 0)? '' : ' hidden';
  this.$elm.append('<div class="rotatoritem' + hide + '" id="rotslide' + i + '">' + link + '<img src="'+ this.imgroot + this.items[i][0] +'" alt="'+ this.items[i][1] +'">' + endlink + '</div>');
 }
}

