/// <reference path="jquery-vsdoc.js" />
// File: smar_eb_functions.js | Requires : jquery.js (v 1.5.2+), braingnat.js (v 0.4.0) | Author: Kyle Weems of mindfly.com
// Created: Oct 06, 2009 | Modified : Apr 20, 2011
var list = new Array('/images/splash/img1.jpg', '/images/splash/img2.jpg', '/images/splash/img3.jpg', '/images/splash/img4.jpg', '/images/splash/img5.jpg');
var starter = 0;
var leaderEmail = null;

$(document).ready(function() {
	//bg.Facebook.addButton(".facebook");
    //splashDiv();
    BrainGnat.slideshow.fadein('.slideshow .wrapper', list, 5000, 1000, starter, 'img')
    $('.thumbs a[class^="img"]').click(function() {
        $('.slideshow .wrapper').stop(true);
        $('.slideshow .wrapper img').stop(true);
        BrainGnat.slideshow.override = true;
        var i = $(this).attr('class').substring(3, 4) * 1;
        $('.slideshow .wrapper').css('background-image', 'url("/images/splash/img' + i + '.jpg")');
        starter = i;
        $('.slideshow img').animate({ opacity: '0' }, 1000, function() {
            $('.slideshow img').attr('src', '/images/splash/img' + (starter - 1) + '.jpg');
            $('.slideshow img').css({ opacity: '1' });
            BrainGnat.slideshow.override = false;
            BrainGnat.slideshow.fadein('.slideshow .wrapper', list, 5000, 1000, (starter - 1), 'img');
        });
        return false;

    });
    teamMemberToggle();
    textboxFill();
});

function teamMemberToggle() {
    $('.teamList h3').click(function() {
        $(this).siblings('.teamMembers').toggleClass('open');
    });
}

function textboxFill() {
    $('input[id$="txtEmail"]').change(function() {
        var email = $('input[id$="txtEmail1"]').attr('value');
        if (leaderEmail == email || email == '') {
            $('input[id$="txtEmail1"]').attr('value', $(this).attr('value'));
        }
        leaderEmail = $(this).attr('value');
    });
}

function splashDiv(){
	// April/May 2011 splash page
	if(document.URL == "http://www.everybodybike.com/" || document.URL == "http://everybodybike.com/"){
			var l = sessionStorage.getItem("viewed-splash");
			if(l!="viewed"){
				$("#splash-banner .close, #shroud").live("click",function(){
					$("#splash-banner .close").remove();
					$("#splash-banner").slideUp(function(){
						$("#shroud").animate({opacity:0},function(){
							$("#shroud").remove();
							$("#splash-banner").remove();
						});
					});
				});
				sessionStorage.setItem("viewed-splash", "viewed");
				$("body").append("<div id='shroud'></div>");
				$("#shroud").css({opacity:0,position:"fixed",left:0,top:0,width:$(window).width()+"px",height:$(window).height()+"px",background:"#000"});
				$("#shroud").animate({opacity:.5}, function(){
					$("body").append("<div id='splash-banner'>Team up. Make bike trips. Win prizes! Win prizes for bicycling in May. Join a team and bike or walk instead of driving for at least three trips during May - and your team could win!<button type='button' class='close'>close</button></div>");
					$("#splash-banner").css({width:"720px",height:"540px",background:"transparent url(images/splashMay2011.jpg) no-repeat left top",textIndent:"-9999em",position:"fixed",left:"50%",marginLeft:"-360px",top:"50px",boxShadow:"0 0 10px black"});
					$("#splash-banner .close").css({width:"43px",height:"43px",textIndent:"-9999em",background:"transparent url(images/close.png) no-repeat left top",position:"absolute",right:"-21px",top:"-21px",border:"none",cursor:"pointer"});
				});	
			}
	}
}

