
/**
 * 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: 0.6, circular: true, auto: true, wheel: false });
	/*if( this.location == 'homepage' ) {
		this.containerDiv = 'c02a_hp_standard_full';
	}
	else if( passedLocation == 'division' ) {
		this.containerDiv = 'c02a_dp_standard_full';
	}

	if( (navigator.appVersion.indexOf('MSIE 6.0') !=-1) || (navigator.appVersion.indexOf('MSIE 7.0')!=-1) ) {
		this.wcdContentItemCIID = $( this.containerDiv ).down('div').getAttribute('className');
	}
	else {
		this.wcdContentItemCIID = $( this.containerDiv ).down('div').getAttribute('class');	
	}
	
	this.wcdContentItemCIIDRoot = this.wcdContentItemCIID.slice(0,1);
	this.wcdContentItemCIIDPrefix = this.wcdContentItemCIID.slice(1,4);
	this.wcdContentItemCIIDSuffix = this.wcdContentItemCIID.slice(4,7);
	
	var WCDCookieVal = 'sldr' + this.wcdContentItemCIID;
	sliderViewed = gidLib.getCookieVar('mktUniversalSession',WCDCookieVal);*/
	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 );
  }
}



