$(document).ready(function() {
	window.onload = function(){
		var maxHeight =  $("#F1").height();
		if ($("#F2").height() > $("#F1").height()){ var maxHeight =  $("#F2").height(); }
		if ($("#F3").height() > $("#F2").height()){ var maxHeight =  $("#F3").height(); }
		if ($("#F4").height() > $("#F3").height()){ var maxHeight =  $("#F4").height(); }
		$(".featuredArticles, #F1,#F2,#F3,#F4").height(maxHeight);
	}
	$("#F2").hide();
	$("#F3").hide();
	$("#F4").hide();
	$("#F2").css("display","block");
	$("#F3").css("display","block");
	$("#F4").css("display","block");
	$("input.option1").css("background","#0b8eff");
	$(".featuredOptions input").css("display","block");
	$(".featured").css("min-height","200px");
	
	$("input.option1").click(function(){
		$("input.option1").css("background","#0b8eff");
		
		$("input.option2").css("background","#5b5b5b");
		$("input.option3").css("background","#5b5b5b");
		$("input.option4").css("background","#5b5b5b");

		$("#F3").fadeOut("fast");
		$("#F2").fadeOut("fast");
		$("#F4").fadeOut("fast");
		$("#F1").fadeIn("fast");
	});
	$("input.option2").click(function(){
		$("input.option2").css("background","#0b8eff");
		
		$("input.option1").css("background","#5b5b5b");
		$("input.option3").css("background","#5b5b5b");
		$("input.option4").css("background","#5b5b5b");

		$("#F1").fadeOut("fast");
		$("#F3").fadeOut("fast");
		$("#F4").fadeOut("fast");
		$("#F2").fadeIn("fast");
	});
	$("input.option3").click(function(){
		$("input.option3").css("background","#0b8eff");
		
		$("input.option2").css("background","#5b5b5b");
		$("input.option1").css("background","#5b5b5b");
		$("input.option4").css("background","#5b5b5b");
		

		$("#F1").fadeOut("fast");
		$("#F2").fadeOut("fast");
		$("#F4").fadeOut("fast");
		$("#F3").fadeIn("fast");
	});
	$("input.option4").click(function(){
		$("input.option4").css("background","#0b8eff");
		
		$("input.option3").css("background","#5b5b5b");
		$("input.option2").css("background","#5b5b5b");
		$("input.option1").css("background","#5b5b5b");
		

		$("#F1").fadeOut("fast");
		$("#F2").fadeOut("fast");
		$("#F3").fadeOut("fast");
		$("#F4").fadeIn("fast");
	});
	
	//Article Image Gallery
	$('.articleImageGallery').height($('.articleImageGallery li:first').height());
	var currentImage = $('.articleImageGallery li:first-child');
	var currentImageNum = 1;
	var imageNumTotal = $('.articleImageGallery li').length;
	$(".articleImageGallery .imageTotal").append("<strong class=\"imageTotalNum\">"+ imageNumTotal + "</strong>");
	
	
	$(".articleImageGallery .imageOf").append("<strong class=\"imageNum\">"+ currentImageNum + "</strong>");
	
	$(".articleImageGallery #nextImage").click(function() {
		$("strong.imageNum").remove();
		if (!currentImage.is(":last-child")) {
			$('.articleImageGallery').height(currentImage.next().height());
			currentImage.removeClass("displayed");
			currentImage.next().addClass("displayed");
			currentImage = currentImage.next();
			currentImageNum++;
		} else {
			$('.articleImageGallery').height($('.articleImageGallery li:first').height());
			currentImage.removeClass("displayed");
			$('.articleImageGallery li:first').addClass("displayed");
			currentImage = $('.articleImageGallery li:first-child');
			currentImageNum = 1;
		}
		$(".articleImageGallery .imageOf").append("<strong class=\"imageNum\">"+ currentImageNum + "</strong>");
	});
	$(".articleImageGallery #prevImage").click(function() {
		$("strong.imageNum").remove();
		if (!currentImage.is(":first-child")) {
			$('.articleImageGallery').height(currentImage.prev().height());
			currentImage.removeClass("displayed");
			currentImage.prev().addClass("displayed");
			currentImage = currentImage.prev();
			currentImageNum--;
		} else {
			$('.articleImageGallery').height($('.articleImageGallery li:last').height());
			currentImage.removeClass("displayed");
			$('.articleImageGallery li:last').addClass("displayed");
			currentImage = $('.articleImageGallery li:last-child');
			currentImageNum = $('.articleImageGallery li').length;
		}
		$(".articleImageGallery .imageOf").append("<strong class=\"imageNum\">"+ currentImageNum + "</strong>");
	});

	//Article Text Size
	
	//Enabled = Show
	$(".textSize").css("display","block");
	var currentTextSize = 13;
	$(".textSize a#increase").click(function() {
		if(currentTextSize<24){
			currentTextSize++;
		}
		$(".articleContent").css("font-size",currentTextSize + "px");
	});
	$(".textSize a#decrease").click(function() {
		if(currentTextSize>8){
			currentTextSize--;
		}
		$(".articleContent").css("font-size",currentTextSize + "px");
	});
});