function slideSwitch() {
	var $slideshow = $('.slideshow');
    var pause = $slideshow.attr('rel') ? $slideshow.attr('rel') : 5000;
    var $active = $slideshow.find('img.active');

    if ( $active.length == 0 ) $active = $slideshow.find('img:last');

    var $next =  $active.next().length ? $active.next()
        : $slideshow.find('img:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 2500, function() {
            $active.removeClass('active last-active');
        });
    if($next != $slideshow.find('img:first')) {
        setTimeout( "slideSwitch()", pause );
    }
}
function linkSlideSwitch() {
	var $link_slideshow = $('.link-slideshow');
    var pause = $link_slideshow.attr('rel') ? $link_slideshow.attr('rel') : 4000;
    var $active = $link_slideshow.find('a.active');

    if ( $active.length == 0 ) $active = $link_slideshow.find('a:last');

    var $next =  $active.next().length ? $active.next()
        : $link_slideshow.find('a:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 2500, function() {
            $active.removeClass('active last-active');
        });
    if($next != $link_slideshow.find('a:first')) {
        setTimeout( "linkSlideSwitch()", pause );
    }
}

jQuery.jQueryRandom = 0;
jQuery.extend(jQuery.expr[":"],
{
    random: function(a, i, m, r) {
        if (i == 0) {
            jQuery.jQueryRandom = Math.floor(Math.random() * r.length);
        };
        return i == jQuery.jQueryRandom;
    }
});

$(document).ready(function(){
	setTimeout( "slideSwitch()", 4000 );
    $("input[name='donation_type']:radio").change(function(){
       $("input[name='donation_type']:radio").each(function(){
           $("#" + $(this).val()).hide();
       });
       $("#" + $(this).val()).show();
    });
    
    $(".rsvp").each(function() {
        $(this).click(function(){
            return false;
        });
        $(this).qtip({
            content: {
                text: $("#k2s_form").html(),
                title: 'Key to Stability Breakfast - RSVP Form'
            },
            show: 'click',
            hide: 'unfocus',
            style: {
                tip: true,
                border: {
                    width: 3,
                    radius: 5,
                    color: '#20a6cb'
                },
                width: { 
                    min: 250,
                    max: 500
                }
            },
            position: {
                corner: {
                    target: 'rightMiddle',
                    tooltip: 'leftMiddle'
                }
            }
        });
    });
});


