$(document).ready(function() {
	
//	$("#post_row .category").each(function(){
//		$(this).find(".zoom:first").show();
//	});
	
	var top_items_amt = $("#top_menu .category").size();
	$("#top_menu td").attr('width',top_items_amt + "%");
	
	$("#top_menu").find(".name:first a").addClass('selected');
	$("#top_menu .sub_menu:first").find(".menu_post:first a").addClass('selected');
	
/*
	$("#top_menu .name a").click(function(){
		var id = $(this).attr('id');
		id = id.replace("ca_","");
		$("#post_row").scrollTo($("#category_" + id),500);
		$("#top_menu .name a").removeClass('selected');
		$(this).addClass('selected');
		$(this).find()
		return false;
	});
*/
	
	$(".sub_menu li a").click(function(){
		var id = $(this).attr('id');
		var parentID = $(this).closest(".category").find(".name").attr('id');
		id = id.replace("pa_","");
		parentID = parentID.replace("ca_","");
//		$("#post_row #category_" + parentID + " .zoom").hide();
//		$("#post_row #category_" + parentID + " #z_" + id).show();
		$("#post_row").scrollTo($("#z_" + id),500,{axis:'x'});
		$(".sub_menu li a").removeClass('selected');
		$(this).addClass('selected');
		return false;
	});
	
	$(".addComment").click(function(){
		$(this).hide();
		$("#comment_form").fadeIn("fast");
	});
	
	$("#categories").find(".name").mouseenter(function(){
		$(this).addClass("highlighted");
	}).mouseleave(function(){
		$(this).removeClass("highlighted");
	});
	
	$(".zoom .images").each(function(){
		var currImg = 0;
		var imgArray = $(this).find(".image");
		$(imgArray[currImg]).show();
		if(imgArray.length > 0) {
			$(".body").find(".control.left").hide();
			$(".body").find(".control.right").show();
			currImg = 0;
			$(imgArray[currImg]).show();
		}
		
		$(this).find(".control:not(.inactive)").mouseenter(function(){
	/*
			$(this).children(".arrow").css('filter','alpha(opacity=90)');
			$(this).children(".arrow").css('-moz-opacity','0.90');
			$(this).children(".arrow").css('-khtml-opacity','0.90');
			$(this).children(".arrow").css('opacity','0.90');
	*/
		}).mouseleave(function(){
	/*
			$(this).children(".arrow").css('filter','alpha(opacity=0)');
			$(this).children(".arrow").css('-moz-opacity','0');
			$(this).children(".arrow").css('-khtml-opacity','0');
			$(this).children(".arrow").css('opacity','0');
	*/
		}).click(function(){
			if($(this).hasClass("left")) {
				$(".control.right:hidden").show();
				if(currImg == 1) {
					$(this).hide();
				} else {
					
				}
				currImg --;
			} else {
				$(".control.left:hidden").show();
				if(currImg == ($(imgArray).length)-2) {
					$(this).hide();
				} else {
					
				}
				currImg ++;
			}
			$(this).siblings(".image").hide();
			$(imgArray[currImg]).show();
		});
	});
	
	
/*	$("#post_grid").scroll(function(){
		var scrollY = (this.scrollY) ? this.scrollY : this.scrollTop;
		for(var i=0; i<anchors.length; i++) {
			var loc = anchors[i].offsetTop - scrollY;
			var base = loc + $(anchors[i]).next().height();
//			$("#header #address").html(currentWork);
			if(base > pplOffset.top && loc < pplOffset.top && currentWork != anchors[i].id) {
				currentWork = anchors[i].id;
				var classes = $("#" + currentWork).attr("class").split(" ");
				classes.shift();
				classes.shift();
//				alert(classes);
				$("#posts ul li").removeClass("active");
				$("#posts ul li .sidenote").hide();
				$("#posts ul li#" + currentWork).next().addClass("active").find(".sidenote").fadeIn("fast");
				$("#people ul li").removeClass("active");
				for(var i=0; i<classes.length; i++) {
					var li = $("#people ul #" + classes[i]);
					$(li).addClass("active");
					if($(li).prev().attr("id")) {
					}
				}
			}
		}
		$("#currentWork").html("current work: " + currentWork + ", location: " + loc);
	});
*/	
/* 	$(".category .year + li").show(); */
	
});