rightSlideOut = null;
leftFadeOut = null;
leftSlideOut = null;
leftFadeIn = null;
rightSlideIn = null;
rightFadeIn = null;
schoolRightSlideOut = null;
schoolRightSlideIn = null;
schoolRightFadeIn = null;
weddingsRightSlideOut = null;
weddingsRightSlideIn = null;
weddingsRightFadeIn = null;
weddingsRightHide = null;
fullImageTimeout = null;

revealroll = new Image();
revealroll.src = "images/reveal-bg-roll.png";

koreanroll = new Image();
koreanroll.src = "images/school/korean-flag-roll.gif";

japanroll = new Image();
japanroll.src = "images/school/japanese-flag-roll.gif";

$(document).ready(function() {
	$('.thumbItem').hover(function() {
		$(this).find('.thumbOverlay').hide();
	},
	function() {
		$(this).find('.thumbOverlay').show();
	});
	$('.defaultThumb a').click(function() {
		if ($(this).parent().hasClass('selectedThumb')) { }
		else {
			var folder = $(this).parents('.thumbWrapper').attr('id');
			var image = $(this).attr('rel');
			$('#contentImageWrapper').css('background','url(images/' +folder+ '/' +image+ '.jpg) no-repeat');
			$('.selectedThumb').removeClass('selectedThumb');
			$(this).parent().addClass('selectedThumb');
		}
		return false;
	});
	$('.weddingsThumb a').click(function() {
		if ($(this).parent().hasClass('selectedThumb')) { }
		else {
			var folder = $(this).parents('.thumbWrapper').attr('id');
			var image = $(this).attr('rel');
			$('#contentImageWrapper').css('background','url(images/' +folder+ '/' +image+ '.jpg) no-repeat');
			$('.selectedThumb').removeClass('selectedThumb');
			$(this).parent().addClass('selectedThumb');
			if ($(this).hasClass('testimonial')) {
				clearTimeout(weddingsRightSlideOut);
				clearTimeout(weddingsRightHide);
				clearTimeout(weddingsRightSlideIn);
				clearTimeout(weddingsRightFadeIn);
				var content = '#' + $(this).attr('rev');
				if ($('#contentRightWrapperWeddings').is(':visible')) {
					$('.rightPanel:visible').fadeOut(300);
					weddingsRightSlideOut = setTimeout(function() {
						$('#contentRightWrapperWeddings').animate({ width : 0 },300);
					},300);
					weddingsRightSlideIn = setTimeout(function() {
						$('#contentRightWrapperWeddings').animate({ width : 404 },300);
					},600);
					weddingsRightFadeIn = setTimeout(function() {
						$(content).fadeIn(300);
					},900);
				}
				else {
					$('#contentRightWrapperWeddings').css('width','0px');
					$('#contentRightWrapperWeddings').show();
					$('#contentRightWrapperWeddings').animate({ width : 404 },300);
					weddingsRightFadeIn = setTimeout(function() {
						$(content).fadeIn(300);
					},300);
				}
			}
			else {
				$('.rightPanel:visible').fadeOut(300);
				weddingsRightSlideOut = setTimeout(function() {
					$('#contentRightWrapperWeddings').animate({ width : 0 },300);
				},300);
				weddingsRightHide = setTimeout(function() {
					$('#contentRightWrapperWeddings').hide();
				},700);
			}
		}
		return false;
	});
	$('.selectable').click(function() {
		clearTimeout(schoolRightSlideOut);
		clearTimeout(schoolRightSlideIn);
		clearTimeout(schoolRightFadeIn);
		if ($(this).hasClass('selectedLinkBar')) { }
		else {
			var content = '#' + $(this).attr('rel');
			$('.selectedLinkBar').removeClass('selectedLinkBar');
			$(this).addClass('selectedLinkBar');
			if ($('#contentRightWrapper').is(':visible')) {
				$('.rightPanel:visible').fadeOut(300);
				schoolRightSlideOut = setTimeout(function() {
					$('#contentRightWrapper').animate({ width : 0 },300);
				},300);
				schoolRightSlideIn = setTimeout(function() {
					$('#contentRightWrapper').animate({ width : 404 },300);
				},600);
				schoolRightFadeIn = setTimeout(function() {
					$(content).fadeIn(300);
				},900);
			}
			else {
				$('#contentRightWrapper').css('width','0px');
				$('#contentRightWrapper').show();
				$('#contentRightWrapper').animate({ width : 404 },300);
				schoolRightFadeIn = setTimeout(function() {
					$(content).fadeIn(300);
				},300);
			}
		}
		return false;
	});
	$('.paginationLink').click(function() {
		var content = '#' + $(this).attr('rel');
		$('.rightPanel:visible').fadeOut(300,function() {
			$(content).fadeIn(300);
		return false;
		});
	});
	$('#revealLinkBoth a').toggle(function() {
		clearTimeout(leftFadeIn);
		clearTimeout(rightSlideIn);
		clearTimeout(rightFadeIn);
//		fullImageTimeout = setTimeout(function() {
//			$('.revealLink a').trigger("click");
//		},5000);
		$(this).html('<img src="images/reveal-bg-roll.png" alt="Back To Menu" width="183" height="16" />');
		if ($('#contentRightWrapper,#contentRightWrapperWeddings').is(':visible')) {
			$('#contentRight,#contentRightWeddings').fadeOut(300);
			rightSlideOut = setTimeout(function() {
				$('#contentRightWrapper,#contentRightWrapperWeddings').animate({ width : 0 },300);
			},300);
			leftFadeOut = setTimeout(function() {
				$('#contentLeft').fadeOut(300);
			},600);
			leftSlideOut = setTimeout(function() {
				$('#contentLeftWrapper').animate({ width : 0}, 300);
			},900);
		}
		else {
			$('#contentLeft').fadeOut(300);
			leftSlideOut = setTimeout(function() {
				$('#contentLeftWrapper').animate({ width : 0}, 300);
			},300);
		}
		return false;
	},
	function() {
		clearTimeout(leftFadeOut);
		clearTimeout(leftSlideOut);
		clearTimeout(fullImageTimeout);
		$(this).html('<img src="images/reveal-bg.png" alt="Reveal Full Image" width="183" height="16" />');
		if ($('#contentRightWrapper,#contentRightWrapperWeddings').is(':visible')) {
			clearTimeout(rightSlideOut);
			$('#contentLeftWrapper').animate({ width : 415 },300);
			leftFadeIn = setTimeout(function() {
				$('#contentLeft').fadeIn(300);
			},300);
			rightSlideIn = setTimeout(function() {
				$('#contentRightWrapper,#contentRightWrapperWeddings').animate({ width : 404}, 300);
			},600);
			rightFadeIn = setTimeout(function() {
				$('#contentRight,#contentRightWeddings').fadeIn(300);
			},900);
		}
		else {
			$('#contentLeftWrapper').animate({ width : 415 },300);
			leftFadeIn = setTimeout(function() {
				$('#contentLeft').fadeIn(300);
			},300);			
		}
		return false;
	});
	$('#revealLinkLeft a').toggle(function() {
		clearTimeout(leftFadeIn);
//		fullImageTimeout = setTimeout(function() {
//			$('.revealLink a').trigger("click");
//		},5000);
		$(this).html('<img src="images/reveal-bg-roll.png" alt="Back To Menu" width="183" height="16" />');
		$('#contentLeft').fadeOut(300);
		leftSlideOut = setTimeout(function() {
			$('#contentLeftWrapper').animate({ width : 0}, 300);
		},300);
		return false;
	},
	function() {
		clearTimeout(leftSlideOut);
		clearTimeout(fullImageTimeout);
		$(this).html('<img src="images/reveal-bg.png" alt="Reveal Full Image" width="183" height="16" />');
		$('#contentLeftWrapper').animate({ width : 415 },300);
		leftFadeIn = setTimeout(function() {
			$('#contentLeft').fadeIn(300);
		},300);
		return false;
	});
});