// core code for whitesky
// testing based on jquery 1.6.2

$(document).ready(function() {
	// used to change the link to blue "active"
	$("#leftNav a").click(function(){
		if ($(this).attr('rel')) {  // shorter
			$(this).parent().parent().find(".active").removeClass("active");
			$(this).addClass("active");
			$("#ab_sec1,#ab_sec2,#ab_sec3,#ab_sec4,#ab_sec5").hide();
			$("#cb_sec1,#cb_sec2,#cb_sec3,#cb_sec4").hide();
			$("#cpb_sec1,#cpb_sec2,#cpb_sec3,#cpb_sec4").hide();
			var section = $(this).attr('rel');
			$(section).show();
			return false;
		} else {  // v1
			$(this).parent().parent().find(".active").removeClass("active");
			$(this).addClass("active");
			return false;
		}
	});

	// setup news, management, and board-of-directors handlers
	$(".newsClicker,#ab_sec3 div h3,#ab_sec4 div h3").live('click',function() {
		$(this).next().toggle();
		return false;
	});
	if (location.hash != '') {
		$("#ab_sec1,#ab_sec2,#ab_sec3,#ab_sec4,#ab_sec5").hide();
		$("#cb_sec1,#cb_sec2,#cb_sec3,#cb_sec4").hide();
		$("#cpb_sec1,#cpb_sec2,#cpb_sec3,#cpb_sec4").hide();
		var section = $(location.hash).attr('rel');
		var linky = $(location.hash).attr('title');
		$("#"+linky).parent().parent().find(".active").removeClass("active");
		$("#"+linky).addClass('active');
		window.scrollTo(0,0);
	} else {
		$("#ab_sec1,#ab_sec2,#ab_sec3,#ab_sec4,#ab_sec5").hide();
		$("#cb_sec1,#cb_sec2,#cb_sec3,#cb_sec4").hide();
		$("#cpb_sec1,#cpb_sec2,#cpb_sec3,#cpb_sec4").hide();
	}
	if (!section) {
		if (window.thispage == 'conben') {
			var section = $("#cb_sec1 a").attr('rel');
			window.scrollTo(0,0);
		} else if (window.thispage == 'partben') {
			var section = $("#cpb_sec1 a").attr('rel');
			window.scrollTo(0,0);
		} else if (window.thispage == 'about') {
			var section = $("#ab_sec1 a").attr('rel');
			window.scrollTo(0,0);
		}
	}
	$(section).show();
	
     var j = 0;
     var delay = 3750; //millisecond delay between cycles
	 var jmax = $("ul#hpStats li").length -1;
     function cycleThru(){
             $("ul#hpStats li:eq(" + j + ")")
                     .fadeIn(700)
                     .animate({"opacity" : "1"}, delay)
                      .animate({"opacity" : "0"}, 900, function(){

                             $("ul#hpStats li").hide();

                             (j == jmax) ? j=0 : j++;

                             cycleThru();

                     });

/*.animate({"opacity" : "0"}, 900, function(){
							//$(this).fadeOut(900);
                             (j == jmax) ? j=0 : j++;
                             cycleThru();
                     });*/
             };

     cycleThru();

	$("#homeClick").click(function(){
			window.location='./index.html';
			return true;
	});


});

