﻿// JScript File

var pause = false;
var timeToNext = false;
var teaserInterval = 6000;

function showTeaser(num) {
    $('.teaser-text:eq(' + num + ') em')
        .css({color: '#ffffff'})
        .animate({color: '#2378CF'}, 1000)
    $('.teaser-text:eq(' + num + ')')
        .show()
        .css({right: '300px', color: '#ffffff'})
        .animate({right: '17px', color: '#777777'}, 1600, '', function(){
            $('.teaser-text:eq(' + num + ')')
                .mouseover(function(){
                    pause = true;
                })
                .mouseout(function(){
                    setTimeout("pause = false; showNextTeaser()", 300);
                });
        })
}

showTeaser(curTeaser);

function hideTeaser(num) {
    $('.teaser-text:eq(' + num + ') em')
        .animate({color: '#ffffff'}, 200)
    $('.teaser-text:eq(' + num + ')')
        .animate({right: '0', color: '#ffffff'}, 200, '', function() {
            $('.teaser-text:eq(' + num + ')').hide();
        })
        .mouseover(function(){})
        .mouseout(function(){});
    //$('.teaser-text:eq(' + curTeaser + ')').hide();
}

function showNextTeaser() {
    if (timeToNext && !pause) {
        hideTeaser(curTeaser);
        curTeaser = curTeaser + 1;
        if (curTeaser == numOfTeasers) curTeaser = 0;
        showTeaser(curTeaser);
        timeToNext = false;
        setTimeout("timeToNext = true; showNextTeaser()", teaserInterval);
    }
}
setTimeout("timeToNext = true; showNextTeaser()", teaserInterval);