﻿slideimages = new Array();
slideimages[0]="../images/photo_ert_4.jpg";
slideimages[1]="../images/photo_ert_5.jpg";
slideimages[2]="../images/photo_ert_6.jpg";

slidetext = new Array();
slidetext[0]="<strong>Get Caught Red-Handed:</strong><br /> Keep a stash of dried cherries on hand for an antioxidant-rich snack break. Buy single-serve packages or portion out those bought in bulk to keep in your purse, desk or gym bag.";
slidetext[1]="<strong>A Perfect Red Parfait:</strong><br /> Keep a bag of frozen cherries in the freezer and grab a handful when hunger strikes.  Thaw them for a few minutes and then layer with lowfat vanilla yogurt and granola.";
slidetext[2]="<strong>Dress Your Salad in Red:</strong><br /> Give your favorite chopped salads a red boost by topping them with dried cherries or even drizzling homemade vinaigrette made with cherry juice.";

var slider;
var level = -210;

function loadSlideShow() {
   slide = document.getElementById('slideshow2');
   var newdiv = document.createElement('div');
   newdiv.setAttribute('id', 'ert_front');
   newdiv.style.position = 'absolute';
   newdiv.style.left = '0';
   newdiv.style.top = level + 'px';
   newdiv.innerHTML = '<p class="headline" style="font-size:14px;font-weight:bolder;margin:0 0 5px 0;">Eat Red Tips</p><img src="../images/photo_lbt_2.jpg" alt="glass of cherry juice" style="margin-top:10px;" /><p style="margin-top:10px;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec pede. Nulla gravida ligula et neque.</p>';
   slide.appendChild(newdiv);
   imageObj = new Image();
   var i = 0;
   for(i=0; i<=5; i++) 
   {
        imageObj.src=slideimages[i];
   }
   imageObj.onLoad=startSlideShow();
}

function startSlideShow() {
    setTimeout('nextSlide(1)',6000);
}

function nextSlide(slideNumber) {
    toplayer = document.getElementById('ert_front');
    thumb = toplayer.getElementsByTagName('img')[0];
    thumb.src = slideimages[slideNumber];
    copy = toplayer.getElementsByTagName('p')[1];
    copy.innerHTML = slidetext[slideNumber];
    slider = setInterval('slideIn(' + slideNumber + ')',1);
}

function slideIn(x) {
    toplayer = document.getElementById('ert_front');
    if (level >= 0) {
        stopSlide(x);    
    } else {
        level = level + 2;
        toplayer.style.top = level + 'px';
    }
}

function stopSlide(x){
    clearInterval(slider);
    document.getElementById('ert_back').innerHTML = document.getElementById('ert_front').innerHTML;
    toplayer = document.getElementById('ert_front');
    toplayer.style.top = '-210px';
    level = -210;
    x = x + 1;
    if ( x >= 3 ) { x = 0; }
    setTimeout('nextSlide(' + x + ')',7000);
}

window.onload = function () {
    if(document.getElementById('slideshow2')) { loadSlideShow(); }
}