(function(){
/*
 * Resizable Plus! - UI Resizable enhancement
 * jQuery Plugin - comptibility : 1.2.6 + jQuery.UI 1.6b
 *
 * Copyright (c) 2008 Nicolas VINCENT (adaka.fr)
 * $Date: 2008-08-07 14:37:00 +0100 (Thu, 07 August 2008) $
 * Version: devStart
 *
 *-
 *
 * How to use :
 * $('myElementResizable').resizablePlus(options);
 *
 * Where var options contain the list of the options [...].
 */
	(
		function($)
		{
			$.fn.resizablePlus = function(options)
			{
				var resizableElements = this;
				
				var settings = {
					plus_position_relative:		false,
					plus_handles_moveTo:		false,
					plus_handler_style:
					{
						a:{},//all
						e://est
						{
							className:undefined,
							cssProperties:
							{
								backgroundColor:	'transparent',
								backgroundImage:	'url(/modele/institutionSP/media/image/btn-redimensionnable-fleche.gif)',
								backgroundPosition:	'left center',
								backgroundRepeat:	'no-repeat',
								borderWidth:		'3px',
								width:				'13px'
							}
						}
					}
				};
				
				settings = $.extend(settings, options || {});
				
				resizableElements.each(
					function()
					{
						var resizableElement	=	$(this);
						
						resizableElement.resizable(settings).css({position:''});
						
						if (settings.plus_handles_moveTo!=false&&settings.plus_handles_moveTo!='')
						{
							var resizableHandles_elements	=	resizableElements.find('div.ui-resizable-handle'),resizableHandles_target	=	resizableElement.find(settings.plus_handles_moveTo);
	
							if (resizableHandles_target.length>0)					
							{
								resizableHandles_target.css({position:'relative'}).append(resizableHandles_elements);
							}
						}
						
						if (!settings.plus_position_relative)
						{
							resizableElement.css({position:''});
						}
						
						resizableElement.resize(
							function()
							{
								$(this).css({height:'auto'});
							}
						);
						
						if ($.browser.version<7)
						{
							// Pour IE 6 Gestion de l'aspect graphique de la barre qui permet le resize
							resizableElement.find('div.ui-resizable-e,div.ui-resizable-w').css('height',resizableElement.find('div.bloc_contenu').height()+'px').end().resize(
								function()
								{
									var plus_handles_container	=	(settings.plus_handles_moveTo!=false&&settings.plus_handles_moveTo!='')?settings.plus_handles_moveTo:null;
									if (plus_handles_container!=null)
										$(this).find(plus_handles_container).find('div.ui-resizable-e,div.ui-resizable-w').css('height',$(this).find(plus_handles_container).height()+'px');
								}
							);
						}
						
						// Style perso des handlers
						if (settings.plus_handler_style)
						{
							var handlers_liste	=	new Array('a','n','e','s','w');
							$.each(
								handlers_liste,
								function()
								{
									var handler	=	this;
									
									if (settings.plus_handler_style[handler])
									{
										if (handler=='a')
										{
											var $handler_element	=	resizableElement.find('div.ui-resizable-handle');
										}
										else
										{
											var $handler_element	=	resizableElement.find('div.ui-resizable-'+handler);
										}
										
										if ($handler_element.length==1)
										{
											if (settings.plus_handler_style[handler].className)
											{
												$handler_element.addClass(settings.plus_handler_style[handler].className);
											}
											if (settings.plus_handler_style[handler].cssProperties)
											{
												$handler_element.css(settings.plus_handler_style[handler].cssProperties);
											}
										}
									}
								}
							)
						}
					}
				);
				
				return resizableElements;
			};
		}
	)(jQuery);
})();
