/*************************************************************************
  This code is from Dynamic Web Coding at dyn-web.com
  Copyright 2001-5 by Sharon Paine 
  See Terms of Use at www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

// preload images
imageHandler.path = "img/";
imageHandler.preload("testimonial-2.png", "testimonial-2.png", "nancy.jpg");

function initBanner() {
    if ( !document.getElementById ) return;
    // arguments: id, delay (amount of time in milliseconds you linger on each item)
    var ban1 = new dw_Banner('txtBanner', 6500);
    // add as many items as you like
    ban1.addItem('&#8220;I have been taking natural products for over 25 years, but I have not had any as useful as those from Total Prevention. I take four and they are terrific products. I hope I do not ever have to do without them!&#8221;<br /><span style="float:right;"><a href="testimonials.php">Michael J.R., Dallas, TX</a></span>');
    ban1.addItem('&#8220;I&#8217;ve tried lots of other cleanses, and nothing has every worked for me until I found Total Prevention cleanse. I&#8217;ve been using your product for years now. I have high energy now after taking this product. I love it!&#8221;<br /><span style="float:right;"><a href="testimonials.php">Gloria N.S., Malad, ID</a></span>');
    ban1.addItem('&#8220;Janice has worked with me for several months. I saw results immediately. With Janice&#8217;s guidance I have a new lease on life and my aches and pains have steadily diminished. The key to success for me is having an open mind and regular follow up. Janice will do the rest!&#8221;<br /><span style="float:right;"><a href="testimonials.php">Nancy P., Knoxville, TN</a></span>');
        
    var ban2 = new dw_Banner('imgBanner', 6500);
    // put your items here
    ban2.addItem('<a href="testimonials.php"><img src="img/testimonial-2.png" width="100" height="100" border="0" alt="testimonials" /></a>');
    ban2.addItem('<a href="testimonials.php"><img src="img/testimonial-1.png" width="100" height="100" border="0" alt="testimonials" /></a>');
    ban2.addItem('<a href="testimonials.php"><img src="img/nancy.jpg" width="100" height="100" border="0" alt="testimonials" /></a>');
        
    dw_Banner.setPartners(ban1, ban2);
    ban1.rotate();  
    ban2.rotate(); 
}

dw_Banner.setPartners = function(p1, p2) {
    p1.el = document.getElementById(p1.id);
    p2.el = document.getElementById(p2.id);
    if (p1.el && p2.el) {
        p1.el.onmouseover = dw_Banner.tandemHalt;
        p2.el.onmouseover = dw_Banner.tandemHalt;
        p1.el.onmouseout = dw_Banner.tandemResume;
        p2.el.onmouseout = dw_Banner.tandemResume;
        p1.partner = p2; p2.partner = p1;
    }
}

dw_Banner.tandemHalt = function() {
    var curObj = dw_Banners[this.id];
    if ( curObj && curObj.partner ) {
        clearTimeout(curObj.timer); curObj.timer = null;
        clearTimeout(curObj.partner.timer); curObj.partner.timer = null; 
    }
}

dw_Banner.tandemResume = function(e) {
    e = e? e: window.event;
    var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
    if ( this != toEl && !dw_contained(toEl, this) ) { 
        var curObj = dw_Banners[this.id];
        if ( curObj && curObj.partner ) {
            curObj.timer = setTimeout(curObj.animString + ".rotate()", dw_Banner.restartDelay);
            curObj.partner.timer = setTimeout(curObj.partner.animString + ".rotate()", dw_Banner.restartDelay);        
        }
    }     
}
