var kids = function()
{
	var _imgPath;
    var _quotes = [
    	"Walking school buses use 1 or 2 parents to walk a group of kids to school.",
    	"Kids get a healthy dose of physical activity by walking or biking to school.",
		"Walking or biking to school gives kids a sense of responsibility and independence.",
    	"Safety education for your kids is part of a complete SRTS program.",
    	"In 1969, 42% of kids walked or biked to school. This dropped to 16% by 2001.",
    	"When it rains, rain coats, hats and umbrellas are essentials for walking or biking to school.",
    	"You can reduce much of the traffic around your school in the morning by walking with your kids.",
    	"Enroll as a Partner with the Resource Center and get a SRTS program started at your school.",
    	"Make a SRTS plan that includes things your school is already doing to encourage kids to walk and bike safely.",
		"Participate in Walk to School Day on October 7. Register your event at <a href='http://www.walktoschool.org'>www.walktoschool.org</a>.",
		"Based on a study by the EPA, air quality is measurably better around schools with more bicycling and walking."
    ];
    
    var _kidImgs = [
    	"bella.gif",
    	"maggie.gif",
    	"george.gif",
    	"trey.gif"
	];
    
    var getRandomQuote = function() {
    	var i = random(_quotes.length);
    	// Uncomment the below line and set the value to 0-(number of quotes minus 1)
    	// to always show a specific quote.
    	//i = 9;
    	return _quotes[i];
    };

	var random = function(sampleSize) {
		return Math.floor(Math.random() * sampleSize)
	};

    return {
    	init:function(imagesPath) {
    		_imgPath = imagesPath;
    	},
    	
        rockIt:function() {
        	// 33% chance the Spokeskid will show.
        	var show = random(3);
        	// Uncomment the below line to always show a kid.
        	//show = 0;
        	if (show == 0)
        	{
        		var kid = random(4);

				// Uncomment the below line and set the value to 0-3 to
				// always show a specific kid.
				//kid = 0;
        		$("#spokeskid > img")[0].src = _imgPath + _kidImgs[kid];

        		// Bella is a special case ...
        		if (_kidImgs[kid].indexOf("bella") != -1)
        		{
        			$("#spokeskid").css({ "margin-left":"-4px" });
        			$("#smallbubble").css({ left:"82px" });
					$("#bigbubble").css({ left:"62px" });
        		}
        		
        		$("#bubblespeech").html(getRandomQuote());
				$("#spokeskid").fadeTo(1500, 1).show("slide", null, 500);
				$("#smallbubble").fadeTo(2250, 1).fadeIn("def", kids_Pulsate);
				
				$("#smallbubble").hover(
					function() {
						kids_PulsateFlag = false;
						var img = $(this).find("img");
						img.stop(true, true);
						img.fadeOut("fast");
						$("#bigbubble").fadeIn("fast").css("display:table-cell;");
					}
				);
    
				$("#bigbubble").hover(
					function() {},
					function() {
						$(this).fadeOut("fast");
						$("#smallbubble > img").fadeIn("fast");
					}
				);
        	}
        }
    };
}();

var kids_PulsateFlag = true;
function kids_Pulsate()
{
	$("#smallbubble").effect("pulsate", { times:1 }, 1000,
		function() {
			if (kids_PulsateFlag)
				setTimeout("kids_Pulsate()", 1)
		}
	);
}