$(document).ready(function() {		
	function init() {
		$(".section:first-child").css("display", "block");
		
		/* CONTENT LOADER
		****************************************/
		$(".load").click(function() {
			$("#personal-progress").load(this.href + "?random=" + Math.random()*99999, "", function() {init();});
			return false;
		});
	
		/* TRANSITION EFFECT
		****************************************/
		var trig = ".content-sub .nav a";
		var cont = ".content-main .section";
		
		var curr = 0;
		var prev;
		var next;
		
		// keeps absolute positioned content inside .content-main wrapper
		function hCtrl() {$(".content-main").height($(cont).eq(curr).height());}
		hCtrl();
		
		$(trig).mouseover(function() {
			$(".nav ul").children("li").removeClass("active");
			$(this).parent("li").addClass("active");
			
			next = $(trig).index(this);
			if(next != curr) {
				$(cont).eq(curr).fadeOut(1000, function () {$(cont).eq(next).fadeIn(500);});
				curr = next;
				hCtrl();
			};
		});
		
		$(window).resize(function() {
			hCtrl();
		});
		
		/* ACCORDION NAV
		****************************************/
		$("#accordion").accordion({
			autoHeight: false,
			//event: "mouseover"
			event: "click"
		});
	};
	
	/* INITIAL PAGE LOAD
	****************************************/
	$("#personal-progress").load("/pa/yw/ppv/new-personal-progress-focus.html?random=" + Math.random()*99999, "", function() {init();});
});

