if (typeof CDC.FeaturedTools == "undefined") CDC.FeaturedTools = new Object();
if (typeof CDC.FeaturedTools.Switcher == "undefined") CDC.FeaturedTools.Switcher = new function() {

	return {
		render: function() {

			// A class used to define a feature image 
			// "indexOf" type match).
			function FeaturedTool(targetUrl, imagePath, altText, title, description) {
				this.TargetUrl = targetUrl;
				this.ImagePath = imagePath;
				this.AltText = altText;
				this.Title = title;
				this.Description = description;
			};
		
			var featuredToolList = new Array(
				new FeaturedTool("http://www2c.cdc.gov/ecards/", "/images/home/dev/multimedia_ecard.gif", "eCards", "eCards", "Say hello and spread messages of good health and safety with a CDC.gov eCard. <br />&nbsp;"),
				new FeaturedTool("/cdctv/", "/images/home/dev/multimedia_cdctv.jpg", "CDC-TV", "CDC-TV", "Watch, listen, and learn with CDC-TV on many popular health topics. <br />&nbsp; <br />&nbsp;"),
				new FeaturedTool("/Widgets/", "/images/home/dev/multimedia_widgets.jpg", "Widgets", "Widgets", "Add a widget to your Web site or blog to share updates and data on important health topics. <br />&nbsp"),
				new FeaturedTool("/mobile/", "/images/home/dev/multimedia_moble2.jpg", "Mobile", "Mobile", "View CDC information on seasonal flu, H1N1 flu, public health emergencies, and more on your mobile device."),
				new FeaturedTool("http://phil.cdc.gov/", "/images/home/dev/multimedia_photos.jpg", "Photos", "Photos", "CDC\'s Public Health Image Library has collections of photographs to document numerous health issues including H1N1 Flu."),
				new FeaturedTool("/SocialMedia/Tools/ButtonsBadges.html", "/images/home/dev/multimedia_badges.jpg", "Buttons &amp; Badges", "Buttons &amp; Badges", "Add a button or badge to your Web site to promote healthy behaviors and awareness of important health information."),
				new FeaturedTool("http://www2c.cdc.gov/podcasts/rss.asp", "/images/home/dev/multimedia_rss.jpg", "RSS Feeds", "RSS Feeds", "Subscribe to CDC RSS feeds to stay updated on news related to important health topics, such as H1N1 Flu. <br />&nbsp;"),
				new FeaturedTool("http://www2c.cdc.gov/podcasts/", "/images/home/dev/multimedia_podcasts.jpg", "Podcasts", "Podcasts", "CDC offers a library of audio and video podcasts developed to deliver health information in a convenient and enjoyable format.")
			);
			
			var selectedIndexes = new Array();
			
			// Check to see if there is a session cookie for the SWF file to server.
			try {
				var markup = "";
				for (var i = 0; i < 3; i++)
				{
					var haveIndex = false;
					var attempts = 0;
					while (!haveIndex && attempts < 100)
					{
						haveIndex = true;
						var index = Math.floor((Math.random() * featuredToolList.length) + 1) - 1;
						// check to make sure the number hasn't been used before.
						for (var j = 0; j < selectedIndexes.length; j++)
						{
							if (selectedIndexes[j] == index)
							{
								haveIndex = false;
								break;
							}
						}
						if (haveIndex)
						{
							selectedIndexes[selectedIndexes.length] = index;
						}
						attempts++;
					}
					var tool = featuredToolList[index];
					var colClass = "c33l";
					var subColClass = "subcl";
					if (i == 1)
					{
						subColClass = "subc";
					}
					if (i == 2)
					{
						colClass = "c33r";
						subColClass = "subcr";
					}
					markup += "<div class='" + colClass + "'><div class='" + subColClass + "'><div class='group'><a href='" + tool.TargetUrl + "'><img src='" + tool.ImagePath + "' alt='" +  tool.AltText + "' border='0'/></a><h5><a href='" + tool.TargetUrl + "'>" + tool.Title + "</a></h5><p class='cdc-caption-text'>" + tool.Description + "</p></div></div></div>";
				}
				$("#panel1").html(markup);
				
			} catch(err) {
			}
			
		}
	};
	
}
$(document).ready(function(){
	CDC.FeaturedTools.Switcher.render();
});
