  /**
   * Aciontour Teaser
   *
   * @author Stefan Kraus <s.kraus@21torr.com>
   * @package TYPO3
   * @copyright (c) 2009 by 21TORR Interactive GmbH
   * @version 1.0
   * @since 08.04.2010
   */
	// Pointer
	var iRotationPointer = 0;
	var iRotationPointerSmall = 0;

	// Elements
	var aBoxes = new Array();
	var aElementsIndex = new Array();
	
	// Positions
	var iPositionLeftSmall = 585;
	var iPositionLeftBig = 20;
	var iPositionTopBig = 20;
	
/* 	var iPositionTopSmall = 40;
	var iPositionMiddle = 195;
	var iPositionBottom = 330; */
	var aSmallImagePositions = new Array(20, 163, 307);
	
	// Z-Indizes
	var iZindexBottom = 0;
	var iZindexTop = 999;
	
	// Image Sizes
	/* 
	Big: 556 / 423
	Small: 240 / 125
	*/
	
  /**
   * Get all IDs and positions
   */
  function vSetBoxes () {
		
	aElementsBig = $$('div#actiontour_teaser .teaser_img_big');
	aElementsSmall = $$('div#actiontour_teaser .teaser_img_small');
	aTextBoxes = $$('div#actiontour_teaser .teaser_text_overlay_big');
	
    for (i = 0; i < aElementsBig.length; i++) {
	
	  aElementsIndex[i] = (i+1);
	  sIDBig = aElementsBig[i].identify();
      sIDBig = sIDBig.substr(sIDBig.indexOf('teaser_img_big_')+15, sIDBig.length);
	  aElementsBig[i].setOpacity(1);
	  aElementsBig[i].style.top = iPositionTopBig+"px";
	  aElementsBig[i].style.left = iPositionLeftBig+"px";
	   
	  sIDSmall = aElementsSmall[i].identify();
      sIDSmall = sIDSmall.substr(sIDSmall.indexOf('teaser_img_small_')+17, sIDSmall.length);
	  aElementsSmall[i].setOpacity(1);
	  aElementsSmall[i].style.top = aSmallImagePositions[0]+"px";
	  aElementsSmall[i].style.left = iPositionLeftBig+"px";
	  
	  aTextBoxes[i].setOpacity(0.9);
		  
      aBoxes[i] = new Object();
	  aBoxes[i]['big'] = new Array();
      aBoxes[i]['big']['id'] = sIDBig;
	  aBoxes[i]['small'] = new Array();
      aBoxes[i]['small']['id'] = sIDSmall;
	  
	  iZindex = 10 * i; 
	  iZindexReverse = 1000 - (10 * i);
	  aElementsBig[i].style.zIndex = iZindexReverse;
	  aElementsSmall[i].style.zIndex = iZindexBottom;

    }
	
	for (i = 0; i < 3; i++) {
		setSmallImage(i);
	}

  }

  /**
   * Get next pointer
   */
  function iGetNextPointer () {
    if(typeof aBoxes[iRotationPointer + 1] != "undefined") {
      return iRotationPointer + 1;
    } else {
      return 0;
    }
  }

  function iCheckPointer (iValue) {
    if( (typeof aBoxes[iValue - 1] != "undefined")) {
	  return iValue;
    } else {
      return 1;
    }
  }
  
  /**
   * Rotate images and related text box
   */
  function vRotate () {
    var iRotationPointerClass = iRotationPointer + 1;
	var oCurrentImage     = $('teaser_img_big_' + iRotationPointerClass);
	
	var iNext           = iGetNextPointer();
	var iNextClass = iNext + 1;
	var oNextImage        = $('teaser_img_big_' + iNextClass);

    iRotationPointer    = iNext;

    // Fade current image out and next image in
    new Effect.Parallel([
      new Effect.Opacity(oCurrentImage, {
        from: 1.0,
        to: 0,
        sync: true
      }),
      new Effect.Opacity(oNextImage, {
        from: 0,
        to: 1.0,
        sync: true
      })
    ], {
      duration: 1,
      transition: Effect.Transitions.sinoidal,
      queue: {
        position: 'end',
        scope: 'rotation'
      },
      beforeStart : function () {
        oNextImage.setOpacity(1);
        oNextImage.show();
      },
    });

   	for (i = 0; i < 3; i++) {
		setSmallImage(i);
	}
  }

  /**
   * Switch header visuals
   */
  function vSwitchVisual () {
    var iTimeout          = 10;
    var oFirst            = null;
    var oDefault          = null;

    // Get random pointer
    iRotationPointer = 0;
	iRotationPointerClass = 1;
	
    // Get first Image
    oDefault = $('teaser_img_big_' + iRotationPointerClass);
	
	// Get second Image
	iRotationPointer = iRotationPointer + 1;
	iRotationPointerClass = iRotationPointerClass + 1;
    oFirst = $('teaser_img_big_' + iRotationPointerClass);
		
    // Fade First Image Out And Second Image In
    new Effect.Parallel([
      new Effect.Opacity(oDefault, {
        from: 1.0,
        to: 0,
        sync: true
      }),
      new Effect.Opacity(oFirst, {
        from: 0,
        to: 1.0,
        sync: true
      })
    ], {
      duration: 1,
      transition: Effect.Transitions.sinoidal,
      queue: {
        position: 'front',
		scope: 'global'
      },
       beforeStart : function () {
        oFirst.setOpacity(0);
        oFirst.show();
      },
    });
		
   	for (i = 0; i < 3; i++) {
		setSmallImage(i);
	}
	
    // Rotate Other Images
     new PeriodicalExecuter(function(poExecuter) {
      vRotate();
    }, 8); 
	
  }
  
  function setSmallImage(index) {
	aPositionSmallImageShow1 = aElementsIndex.slice(0,iRotationPointer);
	aPositionSmallImageShow2 = aElementsIndex.slice(iRotationPointer+1);
	aPositionSmallImageShow = aPositionSmallImageShow2.concat(aPositionSmallImageShow1);
	$('teaser_img_small_' + aPositionSmallImageShow[index]).style.left = iPositionLeftSmall+"px";
	$('teaser_img_small_' + aPositionSmallImageShow[index]).style.top = aSmallImagePositions[index]+"px";
	if(index == 0 && aPositionSmallImageShow[index] == 1) $('teaser_img_small_' + aElementsIndex.length).style.zIndex = 0;		
	$('teaser_img_small_' + aPositionSmallImageShow[index]).style.zIndex = iZindexTop;
	$('teaser_img_small_' + aPositionSmallImageShow[index]).setOpacity(1);
	$('teaser_img_small_' + aPositionSmallImageShow[index]).show();
  }
  
  // Init Pictures
  vSetBoxes();

  // Then start rotation...
  // setTimeout("vSwitchVisual()", 3500);



