//-- stacked ads for the RHS nav column
// give the divId for the ad containers and limit the randomness to 0..limit
function bannerStack( divId , limit) {
  this.id = divId;
  this.items = [];
  this.ctr = 0;
  this.limit = limit;
}

bannerStack.prototype.addItem = function( text ) {
  this.items.push( text);
}

bannerStack.prototype.randomize = function( ) {
  var i = (this.items.length > this.limit) ? this.limit : this.items.length;
  if ( i == 0 ) return false;
  while ( --i ) {
     var j = Math.floor( Math.random() * ( i + 1 ) );
     var tempi = this.items[i];
     var tempj = this.items[j];
     this.items[i] = tempj;
     this.items[j] = tempi;
   }
}
  
bannerStack.prototype.getItem = function( ) {
  if (this.ctr > this.items.length) this.ctr = 0;
  return(this.items[this.ctr++]);
}

// write the banner html to the slots
bannerStack.prototype.display = function( ) {
  for (var i = 0; i < this.items.length; i++) {
    var el = document.getElementById(this.id + i);
    if ( el && typeof el.innerHTML != "undefined" ) {
      el.innerHTML = this.items[i];
    }
  }
}

function init_stackedAds() {
  var banstack1 = new bannerStack("stackAds", 2);

  // sample
  // banstack1.addItem('<a href="http://" target="_blank"><img src="/images/ads/" alt=".com" title=".com" border="0" width="115" height="150" style="margin-top: 5px;"/></a>');
  
  // 0
  // kink adds - choose one
  if (Math.random() > 0.49) {
    banstack1.addItem('<a href="http://www.sfarmory.com/tours.php" target="_blank"><img src="/images/ads/Kink_ArmoryTours_115x150.jpg" alt="Kink.com Armory Tours" title="Kink.com Armory Tours" border="0" width="115" height="150" style="margin-top: 5px;"/></a>');
  } else {
    banstack1.addItem('<a href="http://www.kinkmen.com" target="_blank"><img src="/images/ads/KinkMen_12033_BiP_115x150.jpg" alt="KinkMen.com" title="KinkMen.com" border="0" width="115" height="150" style="margin-top: 5px;"/></a>');
  }

  // 1
  banstack1.addItem('<a href="http://www.boyzshop.com/home.html?utm_source=FolsomeStreetFair&utm_medium=banner&utm_campaign=FSFcocksRainbow" target="_blank"><img src="/images/ads/2010_bs_folsom_4.gif" alt="BoyzShop.com" title="BoyzShop.com" border="0" width="115" height="150" style="margin-top: 5px;"/></a>');
  
  // 2
  // banstack1.addItem('<a href="http://www.mr-s-leather.com/" target="_blank"><img src="/images/ads/mr-s-sidebanner.gif" width="115" style="margin-top: 5px;" border="0" alt="Mr. S Leather" title="Mr. S Leather"></a>');
  banstack1.addItem('<a href="http://www.mr-s-leather.com/index.html?campaign=Folsom" target="_blank"><img src="/images/ads/2010_MSL_anime_FSE.gif" width="115" style="margin-top: 5px;" border="0" alt="Mr. S Leather" title="Mr. S Leather"></a>');

  // 3
  banstack1.addItem('<a href="http://www.extremerestraints.com/home.html?utm_source=FolsomeStreetFair&utm_medium=banner&utm_campaign=FSFultimateFetish" target="_blank"><img src="/images/ads/2010_er_folsom.gif" alt="eXtremeRestraints.com" title="eXtremeRestraints.com" border="0" width="115" height="150" style="margin-top: 5px;"/></a>');

  // banstack1.addItem('<a href="http://www.straighthell.net/l690.html" target="_blank"><img src="/images/ads/sh_stack_115x150b.jpg" width="115" style="margin-top: 5px;" border="0" alt="StraightHell" title="StraightHell"></a>');
  // banstack1.addItem('<a href="http://www.straighthell.net/l690.html" target="_blank"><img src="/images/ads/StraightHell_115x150_b.jpg" width="115" style="margin-top: 5px;" border="0" alt="StraightHell" title="StraightHell"></a>');

  // banstack1.addItem('<a href="http://www.leatherpost.com/static/?utm_source=folsomevent&utm_medium=banner&utm_campaign=nextlevel" target="_blank"><img src="/images/ads/Leatherpost_2008-115x150.gif" width="115" style="margin-top: 5px;" border="0" alt="Leather Post" title="Leather Post" ></a>');

  // banstack1.randomize();
  banstack1.display();
}
if (document.getElementById("stackAds2")) init_stackedAds();

