
tx_iocomments_app = {
	init: function() {
		$(document).bind('HTMLChange', tx_iocomments_app.domChange);
		$.event.trigger('HTMLChange');
		$('a[rel=#comments]').click(function() {
			_commentID = $(this).attr('class');
			$('#comments').overlay({ 
				expose: { 
					color: '#333', 
					loadSpeed: 200, 
					opacity: 0.9 
				}, 
				closeOnClick: false, 
				onBeforeLoad: function() { 
					// grab wrapper element inside content 
					var wrap = $("#comments .contentWrap");
					//http://wwwtest.bonedo.de/index.php?id=1&type=1234
					wrap.load('/index.php?id=7906&tx_iocomments[showUid]='+_commentID, {}, function() {
						$('#comments .contentWrap').trigger('HTMLChange');
					});
				},
				api: true
			}).load();
			return false;
		}); 
	},
	domChange: function(e) {
		//var context = e && e.target || $('#comments .contentWrap');
		var context = $('#comments .contentWrap');
		$('form', context).ajaxForm({
			target: '#comments .contentWrap',
			success: function() {
				$('#comments .contentWrap').trigger('HTMLChange');
			}
		});
		if (typeof _commentID != 'undefined') {
			$('form', context).append('<input type="hidden" name="tx_iocomments[showUid]" value="'+_commentID+'" />');
		}
	}
}

/* DUMMY METHOD do not delete it, its a bugfix fpr jQuery Tools */
function tx_comments_pi1_setUserData() {}

$(document).ready(function() {
	var _commentID = 0;
	$(tx_iocomments_app.init);
});