$(document).ready(function(){
	$('.checkbox').click(function() {

		function getCheckedValues(section) {
			query = '&tx_newscategorytags_pi2['+section+']=';

			// TODO: Temporary rewriting:
			if (section=='categories') section='tags';
			if (section=='regions') section='regios';
			if (section=='sysfolders') section='types';

			$('#'+section).find('input:checked').each(function(index) {
				if(index>0) query += ',';
				query = query + this.value;
			});
			return query;
		}
		query = '?type=116'+getCheckedValues('categories')+getCheckedValues('regions')+getCheckedValues('sysfolders');
		$('#ajaxloader').addClass('loading');
		
		url = document.URL;
		
		// Strip realurl-style rewritten GET-parameters from url
		if (url.indexOf('/tags') != -1) url = url.split('/tags',1);
		if (url.indexOf('/types') != -1) url = url.split('/types',1);
		// Strip standard GET-parameters from url
		if (url.indexOf('?') != -1) {
			url = url.split('?',1)+query;
		} else {
			url = url+query;
		}
		$('#tx-newscategorytags-pi2').load(url);
	});
	
	$('.nojs').hide();
    $('.news-category-list').show();

});


//$(document).ready(function(){
function startclickmonitor () {
	$('#news-related-browser a').click(function(event) {
		// Check if url already has GET parameters, then add type
		if (this.href.indexOf("?") == -1) {
			url = this.href + '?type=116';
		} else {
			url = this.href + '&type=116';
		}
		$('#ajaxloader').addClass('loading');
		$('#tx-newscategorytags-pi2').load(url);
		event.preventDefault();
	});
}

