 $(document).ready(function(){
	// When the 'play video' thumbnail is clicked 
    $("#play-video").click(function () {
	      $("#movie-slide").slideDown ("slow", 
		  	function(){
				$("#vid-wrap")[0].style.display = "block";				
				var vidLink = $("#movie-slide .video0").attr("rel");//get default video
				var flashvars = {media: vidLink};
				swfobject.embedSWF("/wp-content/themes/cufoundation/images/global/videoPlayer.swf", "flashmovie", "407", "254", "7", "/wp-content/themes/cufoundation/images/global/expressInstall.swf", flashvars,  {wmode:"transparent"});
			});
			$(".video").hide();//hide other content
			$(".video0").fadeIn("fast");//show default
			$("#priorities-slide").slideUp("fast");//hide other slider				
			$("#movie-slide .small-thumbs").fadeIn(2000);//show video thumbs
			$("#movie-slide .small-thumbs img").removeClass("current");
			$("#movie-slide .small-thumbs img:first").addClass("current");
    });
	
	// When a video thumbnail is clicked
    $("#movie-slide .small-thumbs img").click(function () {
		var vidLink = $(this).attr("rel");//determine which thumbnail was clicked
		var vidId = $(this).attr("id");		
		var flashvars = {media: vidLink};
				swfobject.embedSWF("/wp-content/themes/cufoundation/images/global/videoPlayer.swf", "flashmovie", "407", "254", "7", "/wp-content/themes/cufoundation/images/global/expressInstall.swf", flashvars,  {wmode:"transparent"});
		$(".video").hide();//hide all other content
		$(this).siblings().removeClass("current");
		$(this).addClass("current");				
		$("." + vidId).fadeIn("fast");//show desired content
    });	
	
	// When the 'featured priorities' thumbnail is clicked 
    $("#featured-priorities").click(function () {
			$("#priorities-slide").slideDown("slow",
			function() {
                              //var DIVtoRemove = document.getElementById("flashmovie");
                              //DIVtoRemove.parentNode.removeChild(DIVtoRemove);
				var imgSrc = $("#priorities-slide .image").attr("rel");//get default img src
				$("#featured-image").attr("src", imgSrc);//load default img
        $("#vid-wrap")[0].style.display = "none";				
				var vidLink = "test";//get default video
				var flashvars = {media: vidLink};
				swfobject.embedSWF("/wp-content/themes/cufoundation/images/global/videoPlayer.swf", "flashmovie", "407", "254", "7", "/wp-content/themes/cufoundation/images/global/expressInstall.swf", flashvars,  {wmode:"transparent"});
			});
			//$("#vid-wrap")[0].style.display = "none";
			$(".image").hide();//hide other content
			$("#image0").fadeIn("fast");//show image0 content			
			$("#priorities-slide .small-thumbs").fadeIn(2000);//show video thumbs
			$("#priorities-slide .small-thumbs img").removeClass("current");
			$("#priorities-slide .small-thumbs img:first").addClass("current");
    });
	
	// When a featured priorities thumbnail is clicked
    $("#priorities-slide .small-thumbs img").click(function () {
		//determine which thumbnail was clicked
		var imgSrc = $(this).attr("rel");
		var imgClass = $(this).attr("id");

		$("#featured-image").attr("src", imgSrc);
		$(".image").hide();//hide all other content	
		$("#" + imgClass).fadeIn("fast");//load desired content
		
		$(this).siblings().removeClass("current");
		$(this).addClass("current");		
    });		
  });