Integrating JQuery gallery (ADGallery) into phpfox, unbind(*) breaking gallery when using AJAX
===

Sorry this is a bit long. I have successfully integrated [AdGallery][1] into phpfox for the user profile photos section. I added some code to use AJAX to get comments and photo details when a photo is clicked.

The problem is that with each AJAX call done through phpfox a javascript function called loadInit is run which does the following:

    $('*').unbind();
	
	$.each($Behavior, function() 
	{		
		this(this);
	});

This removes all the click events from the gallery and so it no longer works. If I create a new function loadInit2 and change it to this:

    $.each($Behavior, function() 
	{		
		this(this);
	});	


Then everything in the gallery still works however it has 2 drawbacks; firstly it requires editing core phpfox files rather than being a plugin, and secondly it causes quirky behavior with comments, such as each additional comment without a page reload will add 2 duplicate comments, then 3, then 4 etc.

So onto the problem. You can set $Behaviors in the javascript files which will be binded after each run of loadInit by phpfox, however the gallery was not designed to be instantiated twice so if I set the var galleries = $('.ad-gallery').adGallery(); as a $Behavior it gets totally confused trying to start from scratch when a gallery is already there and I get very odd behavior such as image thumbnails sliding all over the place, images overlapping etc.

What I am looking to do is split it up into two pieces, one bit which runs with the page load and creates the gallery, then a second chunk which can be made as a $Behavior which will set all the events and which will run happily after each AJAX call.

There is too much code to post here but the link to the gallery is: http://coffeescripter.com/2009/07/ad-gallery-a-jquery-gallery-plugin/

I know this is a big ask but would be willing to pay for someone who can give me their time to help with this if needed. Thanks.

  [1]: http://coffeescripter.com/2009/07/ad-gallery-a-jquery-gallery-plugin/
  [2]: http://www.phpfox.com