$(document).ready(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		opacity: 0.35, /* Value betwee 0 and 1 */
		showTitle: false, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
		callback: function(){}
	});
	
	$(window).load(function(){
		$('#clientMail').css('height', '').css('display', '');
		var i = 0;
		while($('#clientMail').height() > 20 && i<1000){
			i++;
			text = $('#clientMail').html();
			length = text.length;
			nbDel = 1;
			while(nbDel > 0 && nbDel < 100){
				subText = text.substr(0, (length-nbDel));
				$('#clientMail').html(subText);
				if(($('#clientMail').html()).length != (length-nbDel))
					nbDel++;
				else
					nbDel = 0;
			}
		}
	});
	
	$('.modifEvent').click(function(){
		var nb = $(this).attr('value');
		var view = $(this).attr('title');
		var opt = $(this).next();
		$('.divEventModif').hide('fast', function(){
			$(this).remove();
		});
		$.ajax({
			type: "POST",
			url: "eventModif.php",
			data: "nb="+nb+"&view="+view,
			success: function(msg){
				$(msg).insertAfter(opt).hide().show('slow', function(){
					CKEDITOR.replace( 'descriptionModif' );
				});
			}
		});
	});
	
	$('.supprimerEvent').click(function(){
		$('.submitSupprimerEvent').hide('fast', function(){
			$(this).remove();
		});
		$('<input type="submit" value="Supprimer" name="supprimerEvent" class="submitSupprimerEvent"/>').insertAfter(($(this).next())).hide().show('slow');
	});
});