// Ajax Article Filtering

$(document).ready(function(){

	$('#viewall').click(function(){
		$('#articlelist').html('').css({height:'300px', background:'url(/_img/ajax-loader.gif) no-repeat center center'});

		var seriesObj = document.getElementById('series');

		$.get('/ajax-articles.php', {
		//	'series':seriesObj.value
		},
		function(o){
			var response = o.split('<!--split-->');
			$('.sorter').attr({selectedIndex:0});		
			$('#articlelist').html(response[0]).css({height:'auto', background:'none'});			
		});
		return false;
	});
	
	$('.sorter').change(function(){
		$('#articlelist').html('').css({height:'300px', background:'url(/_img/ajax-loader.gif) no-repeat center center'});
			var monthObj = document.getElementById('month');
			var authorObj = document.getElementById('author');
			var ctgyObj = document.getElementById('category');
			var seriesObj = document.getElementById('series');
	
			var monthIndex = monthObj.selectedIndex;
			var authorIndex = authorObj.selectedIndex;
			var ctgyIndex = ctgyObj.selectedIndex;
	
			$.get('/ajax-articles.php', { 
				'groupby':this.id,
				'month':monthObj.options[monthIndex].value,
				'author':authorObj.options[authorIndex].value,
				'category':ctgyObj.options[ctgyIndex].value
			//	'series':seriesObj.value
			}, 
			function(o){
				var response = o.split('<!--split-->');
				$('#articlelist').html(response[0]).css({height:'auto', background:'none'});			
		});
	});	
	
});
