﻿//make sure instant offer text box is filled with valid email address
function checkemail(ele) {
    var obj = document.getElementById(ele);
    if (obj != null) {
        if (obj.value != "") {
            var filter = /^.+@.+\..{2,4}$/;
            if (filter.test(obj.value)) {
                return true;
            }
        }
    }
    return false;
}


/*Functions to handle slide show*/
function slideSwitch() {
    var $active = $('#slideShow DIV.active');

    if ($active.length == 0) $active = $('#slideShow DIV:last');
    // use this to pull the images in the order they appear in the markup
    var $next = $active.next().length ? $active.next()
        : $('#slideShow DIV:first');

    // uncomment the 3 lines below to pull the images in random order

    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );

    //when fade in
    $active.addClass('last-active')
    .css({ 'top': $('#slideShow').position().top })
    .animate({ opacity: 0.0 }, 2000, function() {
});

    //when fade out 
    $next.css({ opacity: 0.0 })
        .addClass('active')
        .animate({ opacity: 1.0 }, 2000, function() {
            $active.removeClass('active last-active');
        });
        
}


function showBanner(data) {
    if (data != '') {
        $('#slideShow').html(data);

        //set up switch interval
        if ($('#slideShow').children('div').length > 1) {
            setInterval("slideSwitch()", 7000);
        }
    }
}


