	$(document).ready(function() {

		// Navigation Popouts -------------------------------------------------------------
		$("#header .navTabs div").hover( function() {
			var clip = $(this).attr("id");
			$("div#"+clip+" .expanded").show(); },function() { $("div#"+$(this).attr("id")+" .expanded").hide();
		});
		$("#footer .navTabs div").hover( function() {
			var clip = $(this).attr("id");
			$("div#"+clip+" .expanded2").show(); },function() { $("div#"+$(this).attr("class")+" .expanded2").hide();
		});







		function switchSlide(change) {
			$('#carouselBody h3').html('<a href=\"'+photos[change].url+'\">'+photos[change].headline+'</a>');
			$('#carouselCopy').html('<p>'+photos[change].copy+'</p>\n').append('<p><a href="'+photos[change].url+'" class="learnMore">Learn&nbsp;More<sup>&raquo;</sup></a></p>\n');
			$('#sposoredBy').html('<span>Sponsor:</span> <img src="_images/sponsors/'+photos[change].sponsorimg+'" width="132" height="43" alt="'+photos[change].sponsor+'" title="'+photos[change].sponsor+'" />');
		}








		// Carousel Box Set ---------------------------------------------------------------
		//alert(photos.length);
		var totalSlides = photos.length;
		$('#panel').html("");
		for(i=0;i<photos.length;i++) {
			$('#panel').append("<a href=\"javascript:void(0);\" cid=\""+i+"\"><span>"+photos[i].title+"</span><div></div></a>\n");
		}
		// Select & Populate 1st Item (Runs Once)
		$('#panel a:first').attr('class','selected');
		$('#carouselBody h3').html('<a href=\"'+photos[0].url+'\">'+photos[0].headline+'</a>');
		$('#carouselCopy').html('<p>'+photos[0].copy+'</p>\n').append('<p><a href="'+photos  [0].url+'" class="learnMore">Learn&nbsp;More<sup>&raquo;</sup></a></p>\n');
		$('#sposoredBy').html('<span>Sponsor:</span> <img src="_images/sponsors/'+photos[0].sponsorimg+'" width="132" height="43" alt="'+photos[0].sponsor+'" title="'+photos[0].sponsor+'" />');
		$('#carouselImg') .html('<a href="'+photos[0].url+'"><img src="_images/carousel/'+photos[0].image+'" width="286" height="228" /></a>');

		// Hover State
		$('#panel a').hover(function() {
			$('#panel a').attr('class','');
			$(this).attr('class','selected');
			change = $(this).attr('cid');
			switchSlide(change);


		//if($('#panel a').attr('class') != "selected") {
			if('images/'+photos[change].image != $('#carouselImg img').attr('src')) {
				$('#carouselImg').stop(true,true).animate({'opacity':'toggle'},0, function() {$('#carouselImg').html('<a href="'+photos[change].url+'"><img src="_images/carousel/'+photos[change].image+'" width="286" height="228" /></a>');
				$('#carouselImg').animate({'opacity':'toggle'},200);});
			}
		});


		// Carousel Panel Specific
		// Set Panel Defaults
		$("span#amount").html($("li#panel a").index()+1+"-4");
		$("span#total").html($("li#panel a").size());
		// Assign position id to first element
		$("li#panel a").attr("id","position");
		// Listen For Previous Button Click
		$("a.prev").click(function() {
			if($('li#panel a#position').prevAll().length != '0') {
				prevBlock = $("#position").prev();
				$("li#panel a").attr("id","");
				prevBlock.attr("id","position");
				prevBlock.show();
				// Update Totals Panel
				var total = prevBlock.index("li#panel a")+1;
				display4 = parseInt(total)+3;
				$("#amount").html(total+"-"+display4);
			}
		});
		// Listen For Next Button Click
		$("a.next").click(function() {
			if($('li#panel a#position').nextAll().length >= '4') {
				nextBlock = $("#position").next();
				$("li#panel a").attr("id","");
				nextBlock.attr("id","position");
				nextBlock.prevAll().hide();
				// Update Totals Panel
				var total = nextBlock.index("li#panel a")+1;
				display4 = parseInt(total)+3;
				$("#amount").html(total+"-"+display4);
			}
		});




		// Tabbed Box 1  --------------------------------------------------------------
		$('.tabBox1 .tabBoxNav a').click(function(event) {
			// Show / Hide Items
			$('.tabBox1 .tabBoxCopy .tabBox').hide();
			$('.tabBox1 .tabBoxNav a').removeClass('selected');
			// Highlight-unhightlight tabs
			$(this).addClass('selected');
			$('div#'+$(this).attr('id').replace('title','copy')).show();
		});


		// Tabbed Box 2  --------------------------------------------------------------
		$('.tabBox2 .tabBoxNav a').click(function(event) {
			// Show / Hide Items
			$('.tabBox2 .tabBoxCopy .tabBox').hide();
			$('.tabBox2 .tabBoxNav a').removeClass('selected');
			// Highlight-unhightlight tabs
			$(this).addClass('selected');
			$('div#'+$(this).attr('id').replace('title','copy')).show();
		});


		// Right Bar Accordion --------------------------------------------------------
		$('dl.accordion > dd').hide();
		$('dl.accordion > dt').click(function() {
			var $nextDT = $(this).next();
			var $visibleSiblings = $nextDT.siblings('dd:visible');
			if($nextDT.text() == '') {
				$visibleSiblings.slideUp();
			} else {
				if($visibleSiblings.length) {
					$visibleSiblings.slideUp('normal', function() {
						$nextDT.slideToggle('normal');
					});
				} else {
					 $nextDT.slideToggle('normal');
				}
			}
		});

	// End Document Ready
	});




	// Featured Picks -------------------------------------------------------------
	(function() {
		$.fn.featured_slider = function() {
			function repeat(str, n) {
				return new Array(n + 1).join(str);
			}
			return this.each(function() {
				// Magic!
				var $wrapper = $('> div', this).css('overflow', 'hidden'),
				$slider = $wrapper.find('> ul').width(9999),
				$items = $slider.find('> li'),
				$single = $items.filter(':first')
				singleWidth = $single.outerWidth(),
				visible = Math.ceil($wrapper.innerWidth() / singleWidth),
				currentPage = 1,
				pages = Math.ceil($items.length / visible);

				// 1. Pad the pages with empty element if required
				if($items.length % visible != 0) {
					// Pad
					$slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
					$items = $slider.find('> li');
				}
				// 2. Create the carousel padding on left and right (cloned)
				$items.filter(':first').before($items.slice(-visible).clone().addClass('cloned'));
				$items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
				$items = $slider.find('> li');
				// 3. Reset scroll
				$wrapper.scrollLeft(singleWidth * visible);
				// 4. Paging function
				function gotoPage(page) {
					var dir = page < currentPage ? -1 : 1,
					n = Math.abs(currentPage - page),
					left = singleWidth * dir * visible * n;
					$wrapper.filter(':not(:animated)').animate({
						scrollLeft : '+=' + left
					}, 2500, function() {
						// if page == last page - then reset position
						if(page > pages) {
							$wrapper.scrollLeft(singleWidth * visible);
							page = 1;
						} else if(page == 0) {
							page = pages;
							$wrapper.scrollLeft(singleWidth * visible * pages);
						}
						currentPage = page;
					});
				}
				// 5. Insert the back and forward link
				$wrapper.after('<a href="#" class="arrow back"></a><a href="#" class="arrow forward"></a>');
				// 6. Bind the back and forward links
				$('a.back', this).click(function() {
					gotoPage(currentPage - 1);
					return false;
				});
				$('a.forward', this).click(function() {
					gotoPage(currentPage + 1);
					return false;
				});
				$(this).bind('goto', function(event, page) {
					gotoPage(page);
				});
				// When Uncommented This Will Automate Slides Changing Once Hovered Over
				$(this).bind('next', function() {
					gotoPage(currentPage + 1);
				});
			});
		};
	})(jQuery);


	$(document).ready(function() {
		// Code For Automatic Featured Picks
		var autoscrolling = true;
		$('.featured_slider').featured_slider().mouseover(function() {
			autoscrolling = false;
		}).mouseout(function() {
			autoscrolling = true;
		});
		setInterval(function() {
			if(autoscrolling) {
				$('.featured_slider').trigger('next');
			}
		},7500);

	// End Document Ready
	});

