$(document).ready(function(){
	$("ul.slideshow").wrap( $("<div class='slideshowWrapper' />") );			// insert wrapper-div for ul.slideshow
	$("ul.slideshow").after( $("<div class='slideshowNavWrapper' />") );			// insert 'navigation wrapper' for the slides
	$("div.slideshowNavWrapper").append( $("<div class='slideshowNav' />") );		// add the div for the slideshow-pager-nav
	$("div.slideshowNavWrapper").append( $("<div id='slideTitle' />") );			// add a place to shove the title
	$("ul.slideshow > li").wrapInner("<div style='width:482px; height: 228px'></div>");
	$("ul.slideshow > li .blurb").after( $("<div class='photo'/>") );			// photo div for right-side of slide
	
	//$(".youtube").colorbox({iframe:true, innerWidth:425, innerHeight:344});
	
	$(".youtube").bind("click", function(){
			$.fn.colorbox({ iframe: true, innerWidth:"425", innerHeight:"344", href: $(this).attr('href')});
			return false;
		});


	/*
		Get each of the <a href> from 
				<li id="ssWhatever">
					<div class='link'>
						<a href='http://link-to-somewhere-goes-here.html'>link</a>
					</div>
					...
		then insert the href from th <A> tag into the whole slide.  When the slide is clicked anywhere, you will be taken to the action 
		of the 'href' value
	*/
	$.each( $("ul.slideshow").children(), function(i,item) {
		$(item).click(function(){
			var href = $(item).find("div.link a").attr('href');
			window.location.href=href;
		});
	});

	/*
		When the slide is changed (automatically or by clicking the pager-nav), shove the slide's title into the 'title' area of nav
	*/
	function highlightButton() {						
		var id = $(this).attr('id');

		var link = $("#" + id + " > div > div.title").html();
		$("#slideTitle").html(link);
	}

	/*
		The handy-dand jquery cycle() plug-in
	*/
	$('ul.slideshow').cycle({ 
		fx:     	'fade', 
		timeout: 	5000, 
		pager:		"div.slideshowNav",
		before:		highlightButton
	});

	$.each( $("div.slideshowNav").children(), function(i,item){
		var id="ssButton_"+(i+1);	
		$(item)
		.	attr("id", id)
		.	html("")
		;
		
	});

	$("a.snowPlayVideo").bind("click", function(){
		$.fn.colorbox({iframe:true, width:"600px", height:"400px", href: $(this).attr('href')} );
		return false;
	});

	//colorbox({iframe:true, width:"400px", height:"250px"} );
});
