﻿$(document).ready(function () {
    $("#bannertext span").hide();
    $("#bannertext span.active").show();
    $("#bannerheader span").hide();
    $("#bannerheader span.active").show();
    $("#bannerheader").show();
    $("#bannertext").show();
});

var intransition = false;

function slideSwitch(target, mytype) {
    intransition = true;
    var $active = $(target + ' ' + mytype + '.active');

    if ($active.length == 0) $active = $(target + ' ' + mytype + ':last');

    var $next = $active.next().length ? $active.next() : $(target + ' ' + mytype + ':first');

    $active.addClass('last-active')
    $next.hide()
                .addClass('active')
    $active.fadeTo(500, 0.01, function () {

        $next.fadeTo(500, 0.99, function () {
            $active.removeClass('active last-active');
            intransition = false;
        });
    });
}

function slideSwitch2(target, mytype) {
    intransition = true;
    var $active = $(target + ' ' + mytype + '.active');

    if ($active.length == 0) $active = $(target + ' ' + mytype + ':last');

    var $prev = $active.prev().length ? $active.prev() : $(target + ' ' + mytype + ':last');

    $active.addClass('last-active')
    $prev.hide()
                .addClass('active')
    $active.fadeTo(500, 0.01, function () {

        $prev.fadeTo(500, 0.99, function () {
            $active.removeClass('active last-active');
            intransition = false;
        });
    });
}
var headerid;
var textid;
$(function () {
    //setInterval("slideSwitch('#banner', 'IMG')", 3500);
    headerid = setInterval("slideSwitch('#bannerheader', 'span')", 3500);
    textid = setInterval("slideSwitch('#bannertext', 'span')", 3500);
});