
/**
 * Promo Carousel
 * Creates dynamic promo sliding window object
 *
 * @author Ben Henry
 * @date 06/24/2010
 *
 * Arguments - promoSliderJSON - JSON object defining all parameters of slider
 *
 * Code Flow
 * 1. Finds SliderContainer and sets width and height based on parameters
 * 2. Creates slider layers from bottom up. #1 slide is static slide, others will move
 */

PromoCarousel = {

  // PromoSlider initializer - Parse JSON object and set object variables
  init:function( promoSliderJSON ) {
    this.sliderContentDiv = $( promoSliderJSON.sliderContainerDiv );
    this.sliderContainerContentDiv = $( promoSliderJSON.sliderContainerContentDiv );
    this.sliderDirection = promoSliderJSON.sliderDirection;
    this.width = promoSliderJSON.width;
    this.height = promoSliderJSON.height;
    this.wcdContentPath = promoSliderJSON.wcdContentPath;
	this.location = promoSliderJSON.location,
    //this.arrowLeftImg = promoSliderJSON.arrowLeftImg;
    //this.arrowRightImg = promoSliderJSON.arrowRightImg;
    this.promoSlides = promoSliderJSON.promoSlides;
    this.numSlides = promoSliderJSON.promoSlides.length;

    this.sliderContentDiv.setStyle({ width: this.width+'px', height: this.height+'px', overflow:'hidden', position:'relative' });

    for( i=0; i < this.numSlides; i++ ) {
      var currentSlide = this.promoSlides[i];
      this.createSlide( currentSlide );
    }
	this.createSlide( this.promoSlides[0] );
	
    var promoCarousel = new Carousel( $('carousel-wrapper'), $$('#carousel-container .slide'), $$('a.carousel-control'), { frequency:3.0, duration: 1.0, circular: true, auto: true, wheel: false });
	
	sliderViewed = "";

	if ( sliderViewed == "" ) {
		/*twinTimer = setTimeout ( function() {
			promoCarousel.moveTo('slide-2');
		},3000 );*/

		//gidLib.setCookieVar('mktUniversalSession',WCDCookieVal,'yes');
	}	
  }, // END init


  // createStaticSlide - Creates base non-moving slide
  createSlide:function( slide ) {
	var newSlideImg = new Element('img', { 'src': this.wcdContentPath + slide.imgURL, 'alt': slide.imgAlt });
	if( slide.imgMap != '' ) { newSlideImg.useMap = '#' + slide.imgMap; }

	var newSlide = new Element('div', { 'class':'slide' }).insert({ top: newSlideImg });

    // Set up base static slide div
    this.sliderContainerContentDiv.insert( newSlide );
  }
}



