var accordeon_history = Array();

$(document).ready(function(e){
	
	$('.c_style_2 .module_contentlist_item_title').live('click', function(e){
		var query = new Object();
		var data = new Object();
		$(this).children('input[type=hidden]').each(function(e){
			var _key = $(this).attr('name');
			data[_key]=$(this).val();
		});
		query.data = data;
		
		if(trim($('#'+query.data['reference']).html()).length==0) {
			accordeon_history.push(query.data['reference']);
			var callback = function(_return) {
				$('#'+query.data['reference']).html(_return);
			};
			$(this).children('span').attr('class','active');
			$('.module_contentlist_navigate_top').has('input[name='+query.data['reference']+']').show();
			BOT.query('mod_content', query, callback);
		}else{
			$('#'+query.data['reference']).toggle();
			if($('#'+query.data['reference']).css('display')=='none') {

				accordeon_history.splice(accordeon_history.indexOf(query.data['reference']),1);
				$(this).children('span').attr('class','');
				$('.module_contentlist_navigate_top').has('input[name='+query.data['reference']+']').hide();
			}else{
				accordeon_history.push(query.data['reference']);
				$(this).children('span').attr('class','active');
				$('.module_contentlist_navigate_top').has('input[name='+query.data['reference']+']').show();
			}
		}
	});
	
	$('.module_contentlist_navigate_top').live('click', function(e){
		var item = accordeon_history.pop();
		$('#'+item).toggle();
		$('.module_contentlist_item_title').has('input[value='+item+']').children('span:last').attr('class','');
		$(this).hide();
	});	
	
	
});
