$(document).ready(function() {
	
	$("#post_row .category").each(function(){
		$(this).find(".zoom:first").show();
	});
	
	$("#post_row .category:first").show();
	
//	$("#top_menu").find(".name:first a").addClass('selected').find(".sub_menu:first").show().find(".menu_post:first a").addClass('selected');
	
/*
	$("#top_menu .name a").click(function(){
		var id = $(this).attr('id');
		id = id.replace("ca_","");
		$("#post_row .category").fadeOut("fast");
		$("#category_" + id).fadeIn("fast");
		$(".sub_menu").fadeOut("fast");
		$(this).closest(".category").find(".sub_menu").fadeIn("fast");
		$("#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 a").attr('id');
		id = id.replace("pa_","");
		parentID = parentID.replace("ca_","");
		$("#post_row #category_" + parentID + " .zoom").fadeOut("fast");
		$("#post_row #category_" + parentID + " #z_" + id).fadeIn("fast");
		$(this).closest("li").siblings().find("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");
	});
	
	$(".post .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").fadeOut("fast");
			$(imgArray[currImg]).fadeIn("fast");
		});
	});
	
});
