jQuery.noConflict();

jQuery(document).ready(function(){
	// Messages
	if (document.getElementById('messages')) {
		jQuery('#messages').appendTo('body');
		var height = (jQuery('#messages').outerHeight()*-1)-20;
		var height_hide = height;
		if ((jQuery('#messages').outerHeight()-20) < 120) {
			jQuery('#messages').css('height', '80px');
			height_hide = -150;
		}
		jQuery('#messages').css('top', height);
		jQuery('#messages').css('display', 'block');
		jQuery('#messages').stop().animate({ top: -20 }, { easing:'easeOutBounce' });
		
		jQuery('#messages').click(function() {
			jQuery(this).stop().animate({ top: height_hide });
		});
	}
	
	jQuery("a[rel=group]").fancybox({
//				'transitionIn'		: 'none',
//				'transitionOut'		: 'none',
				'zoomSpeedIn': 500,
				'zoomSpeedOut': 500,
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
									   	return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
									  }
	});
	
	jQuery("a.lien_ext").click( function()
	  {
		window.open(jQuery(this).attr("href"));
		return false;
	  }
	).each( function()
	  {
		jQuery(this).attr("title", jQuery(this).attr("title") + "Lien externe: " + jQuery(this).attr("href"));
	  }
	);
	
	jQuery("a.portrait").hover( function(){		
		 jQuery("a.portrait img").attr('src','/illu/' + jQuery(this).attr("title") + '-over.png')},function(){
			jQuery("a.portrait img").attr('src','/illu/' + jQuery(this).attr("title") + '-big.png');
		});
	
	
});


(function($) {
	$.fn.inputdynvalue = function (options) {
		var opts = $.extend({}, $.fn.inputdynvalue.defaults, options);

		return this.each(function(){
			// Initialisation de l'INPUT (attributs value, class)
			var hvalue = opts.htext;
			switch (opts.htext) {
				case 'title': hvalue = jQuery(this).attr('title'); break;
				case 'value': hvalue = jQuery(this).attr('value'); break;
			}
			jQuery(this).attr('value', hvalue).addClass(opts.hclass)

			// Remise à zéro des gestionnaires d'évènement
			.unbind('focus.dynvalue blur.dynvalue')

			// Ajout et suppression du texte au focus ou à la perte de focus
			.bind('focus.dynvalue', function() {
				if (this.value === hvalue) {
					this.value = '';
					jQuery(this).removeClass(opts.hclass);
				}
			})
			.bind('blur.dynvalue', function() {
				if (this.value === '') {
					this.value = hvalue;
					jQuery(this).addClass(opts.hclass);
				}
			});
		});
	};
	// Arguments par défaut
	$.fn.inputdynvalue.defaults = {
		htext: 'title',
		hclass: 'hint'
	};
})(jQuery);
