$(function(){
	
	// loading left column
	
	var leftColumn = $("#leftColumn");
	
	leftColumn.load("leftColumn.html");
	
	
		
	// news the reminder trailer
	
	var grayLayer = $(".grayLayer");
	var close = $(".close");
	var thereminderTrailer = $("#thereminderTrailer");
		
	$("#highlightThumbnail").click(function(){
		grayLayer.show(0);
		close.show(0);
		thereminderTrailer.show(0, function(){
			$("#thereminderTrailer iframe").show(0);
			});
		});
		
	grayLayer.click(function(){
		grayLayer.hide(0);
		close.hide(0);
		thereminderTrailer.hide(0);
		});

	close.click(function(){
		grayLayer.hide(0);
		close.hide(0);
		thereminderTrailer.hide(0);
		});
	
	
		
	
	// news headlines popup
	
	var headline = $("#headlines a");
	var article = $(".article");
	
	headline.click(function(){
		var articleId = $(this).attr("href");
		article.load(articleId).show(0);
		return false;
		});
		
	article.click(function(){
		article.hide(0);
		});
	
	
	// about profile pic popup
	
	var profilePic = $("#profilePic img");
	var profilePicLarge = $("#profilePicLarge");
	
	profilePic.click(function(){
		grayLayer.show(0);
		close.show(0);
		profilePicLarge.show(0);
		});
		
	grayLayer.click(function(){
		profilePicLarge.hide(0);
		});

	close.click(function(){
		profilePicLarge.hide(0);
		});
	
	
	
	// videos page video player
	
	var videoWindow = $(".videoWindow");
	var videoThumbs = $("#videosBody a");
	
	videoThumbs.click(function(){
		grayLayer.show(0);
		close.show(0);
		videoId = $(this).attr("href");
		videoWindow.load(videoId, function(){
			$(".videoWindowBody iframe").show(0, function(){
				videoWindow.show(0);
				});
			});
			
		return false;
		});
		
	grayLayer.click(function(){
		videoWindow.hide(0);
		});

	close.click(function(){
		videoWindow.hide(0);
		});
	
	
	
	
	// photo gallery
	
	var albumTitles = $("#albumTitles a");
	var album = $("#album");
	
	albumTitles.click(function(){
		var albumId = $(this).attr("href");
		
		album.load(albumId, function(){
		
			var photoFrame = $("#photoFrame");
			var thumbnails = $("#thumbnailWindow a");
				
		thumbnails.click(function(){
			
			var imgId = $(this).attr("href");
			var photoFrameImg = $("#photoFrame img");

			photoFrame.hide(0, function(){
				photoFrameImg.attr("src", imgId);
				}).show(0);

				return false;
				});
		
				
		}).show(0);		
		
		return false;
		});		
		
	var albumClose = $("#albumClose");
	
	albumClose.click(function(){
		album.hide();
		});
	
	album.click(function(){
		album.hide();
		});
	
	
	
	
	// coordinates tracker
	
	$("*").mousemove(function(e){
		$("#coordinates").html("X: "+e.clientX+"<br />Y: "+e.clientY)
		});


	
	
	// credit information
	
	var viewCredits = $("#viewCredits");
	var credits = $("#credits");
	
	viewCredits.click(function(){
		grayLayer.show(0);
		close.show(0);
		$("#featured iframe").hide(0);
		credits.show(0);
		});
		
	grayLayer.click(function(){
		credits.hide(0, function(){
			$("#featured iframe").show(0);
			});
		});
		
	close.click(function(){
		credits.hide(0, function(){
			$("#featured iframe").show(0);
			});
		});
		
	credits.click(function(){
		grayLayer.hide(0);
		close.hide(0);
		credits.hide(0, function(){
			$("#featured iframe").show(0);
			});
		});
	
	
});
