jQuery.noConflict();
jQuery(document).ready(function($){
		
	/*
	$.fancybox(
	'<h2>Hi!</h2><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam quis mi eu elit tempor facilisis id et neque</p>',
	{
    	'autoDimensions'	: false,
		'width'         		: 350,
		'height'        		: 'auto',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
	*/

	
	$('div.tx-orlprg-pi1 div.group-by-date').each(function(){
		
		var date = $(this).find('h2').text();

		var menu 	= '';
		var content = '';
		var ul = '<ul>';
		
		$(this).find('div.item').each(function(){
			
			ul = ul + '<li>' + $(this).find('h3').text() + '</li>';
			
			var place = $(this).find('p.listview-place').text();
			var h4 = '';
			
			// gestion de l'heure
			var date_start 	= $(this).find('p.listview-date-start').text();
			//var date_end 	= $(this).find('p.listview-date-end').text();
			/*
			if(date_end != '')
			{
				var reg = new RegExp('00h00');
				if(reg.test(date_end)) date_end = '&agrave; minuit';
				
				var h4 = date_start + ' ' + date_end + ' : ' + place;
			}
			else
			{
				if(date_start != '00h00')
				{
					var h4 = date_start + ' : ' + place;
				}
				else
				{
					var h4 = place;
				}
			}
			*/
			h3 = '<h3>' + $(this).find('h3').text() + '</h3>';
			h4 = '<h4>' + date_start;
			if(place != '') h4 = h4 + ' - ' + place;
			h4 = h4 + '</h4>';
			content = content + h3 + h4;
			if($(this).find('div.listview-content').html() != null)
			{
				content = content + '<div class="prg-content">' + $(this).find('div.listview-content').html() + '</div>';
			}
			else
			{
				content = content + '<div class="prg-content"></div>';
			}
			
			
		});
		
		ul = ul + '</ul>';
		
		var div = $('<div></div>')
					.addClass('hide')
					.hide()
					.append(content);
		
		menu = menu + '<h2>' + date + '</h2>' +	ul;
		
		var href = $('<a></a>')
					.addClass('button-open-close open')
					/*
					.click(function(){
						$.fancybox(
						$(div).html(),
						{
					    	'autoDimensions'	: true,
							'width'         		: '75%',
							'height'        		: '75%',
							'transitionIn'		: 'none',
							'transitionOut'		: 'none'
						})					
					})
					*/
					.toggle(
						function(){
							$(div).show();
							$(this).text('fermer');
							$(this).toggleClass('open close');
						},
						function(){
							$(div).hide();
							$(this).text('en savoir plus');
							$(this).toggleClass('open close');
						}
					)
					.text('en savoir plus');
		
		var pPlus = $('<p></p>').addClass('savoir-plus').append(href);
		
		
		$(this).empty();

		$(this).append(menu);
		$(this).append(div);
		$(this).append(href);
		
	});
	
	/* FANCYBOX */
	$("a.fancybox").fancybox();
	
	$("a.fancybox-frame").fancybox({
		'width' : '75%',
		'height' : '75%',
		'autoScale' : false,
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'type' : 'iframe'
	}); 
	
});