function checkUncheckAll(theElement) {
	var theForm = theElement.form, z = 0;
	
	for(z=0;z<theForm.length;z++) {
		if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){theForm[z].checked = theElement.checked;}
	}
}

$(function (){
	
	$('#categories li').hover(
		function () {$(this).addClass('selected');},
		function () {$(this).removeClass('selected');}
	);

	$('.recentv').hover(
		function () {$(this).addClass('srecentv');},
		function () {$(this).removeClass('srecentv');}
	);

	$('.ajmenu li').click(function () {
		if (!$(this).hasClass("selected")) {
			$(this).siblings().removeClass('selected');
			$(this).addClass('selected');
			
			var id = $(this).find('a').attr('id');
			
			if (id == 'recently_added' || id == 'most_viewed' || id == 'featured') {
				$.ajax({
					type: 'GET',
					url: 'ajaxresp.php',
					data: 'id='+id,
					success: function(html){
						$('#achach_topcontainer').animate({'opacity': 0}, 700, function () {
							$(this).empty().append(html).animate({'opacity': 1}, 700);
						});
					}
				});
			} else if (id == 'mostly_today' || id == "mostly_week" || id == "mostly_month") {
				$.ajax({
					type: 'GET',
					url: 'ajaxresp.php',
					data: 'id='+id,
					success: function(html){
						$('#achach_statcontainer').animate({'opacity': 0}, 700, function () {
							$(this).empty().append(html).animate({'opacity': 1}, 700);
						});
					}
				});
			}
			
		}
	});
	
	$('.container div').hover(
		function () {
			var title = $(this).find('a').find('img').attr('alt');
			$(this).find('h3').after("<span>"+title+"</span>");
		},
		function () {
			$(this).find('span').remove();
		}
	);
	
	$('div.comment').click(function (event) {
		var $tgt = $(event.target);
		if ($tgt.is('span.reply') && $(this).find('div.textarea')) {$(this).find('div.textarea').slideDown('slow');}
	});
	
	$('h1.view-comment-form').toggle(
		function() {$('div.comment_mainpad').slideDown('slow');},
		function() {$('div.comment_mainpad').slideUp('slow');}
	);
	
	$("#loading")
		.ajaxStart(function(){$(this).fadeIn("slow");})
		.ajaxStop(function(){$(this).fadeOut("slow");});
	
	$('#loading').hide();
});
