Jquery lightbox with comment box

Jquery lightbox with comment box

I got an light box coding in jquery it will show an image . now i need to alter the Jquery to add some comment box with the image . 
i tried to do that but comment box keeps on increasing i dont know where to insert the code any anyone help me with this 

  1. (function(){
  2. /* Private variables */
  3. var overlay = $('<div id="galleryOverlay">'),
  4. slider = $('<div id="gallerySlider">'),
  5. comment= $('<div class="fb-comments" data-href="http://www.bluetopten.com" data-width="350" data-num-posts="10">'),
  6. prevArrow = $('<a id="prevArrow"></a>'),
  7. nextArrow = $('<a id="nextArrow"></a>'),
  8. overlayVisible = false;
  9. /* Creating the plugin */
  10. $.fn.touchTouch = function(){
  11. var placeholders = $([]),
  12. index = 0,
  13. items = this;
  14. // Appending the markup to the page
  15. overlay.hide().appendTo('body');
  16. slider.appendTo(overlay);
  17. // Creating a placeholder for each image
  18. items.each(function(){
  19. placeholders = placeholders.add($('<div class="placeholder">'));
  20. });
  21. // Hide the gallery if the background is touched / clicked
  22. slider.append(placeholders).on('click',function(e){
  23. if(!$(e.target).is('img')){
  24. hideOverlay();
  25. }
  26. });
  27. // Listen for touch events on the body and check if they
  28. // originated in #gallerySlider img - the images in the slider.
  29. $('body').on('touchstart', '#gallerySlider img','#fb-comments', function(e){
  30. var touch = e.originalEvent,
  31. startX = touch.changedTouches[0].pageX;
  32. slider.on('touchmove',function(e){
  33. e.preventDefault();
  34. touch = e.originalEvent.touches[0] ||
  35. e.originalEvent.changedTouches[0];
  36. if(touch.pageX - startX > 10){
  37. slider.off('touchmove');
  38. showPrevious();
  39. }
  40. else if (touch.pageX - startX < -10){
  41. slider.off('touchmove');
  42. showNext();
  43. }
  44. });

  45. // Return false to prevent image 
  46. // highlighting on Android
  47. return false;
  48. }).on('touchend',function(){
  49. slider.off('touchmove');
  50. });
  51. // Listening for clicks on the thumbnails
  52. items.on('click', function(e){
  53. e.preventDefault();
  54. // Find the position of this image
  55. // in the collection
  56. index = items.index(this);
  57. showOverlay(index);
  58. showImage(index);
  59. // Preload the next image
  60. preload(index+1);
  61. // Preload the previous
  62. preload(index-1);
  63. });
  64. // If the browser does not have support 
  65. // for touch, display the arrows
  66. if ( !("ontouchstart" in window) ){
  67. overlay.append(prevArrow).append(nextArrow);
  68. prevArrow.click(function(e){
  69. e.preventDefault();
  70. showPrevious();
  71. });
  72. nextArrow.click(function(e){
  73. e.preventDefault();
  74. showNext();
  75. });
  76. }
  77. // Listen for arrow keys
  78. $(window).bind('keydown', function(e){
  79. if (e.keyCode == 37){
  80. showPrevious();
  81. }
  82. else if (e.keyCode==39){
  83. showNext();
  84. }
  85. });
  86. /* Private functions */
  87. function showOverlay(index){
  88. // If the overlay is already shown, exit
  89. if (overlayVisible){
  90. return false;
  91. }
  92. // Show the overlay
  93. overlay.show();
  94. setTimeout(function(){
  95. // Trigger the opacity CSS transition
  96. overlay.addClass('visible');
  97. }, 100);
  98. // Move the slider to the correct image
  99. offsetSlider(index);
  100. // Raise the visible flag
  101. overlayVisible = true;
  102. }
  103. function hideOverlay(){
  104. // If the overlay is not shown, exit
  105. if(!overlayVisible){
  106. return false;
  107. }
  108. // Hide the overlay
  109. overlay.hide().removeClass('visible');
  110. overlayVisible = false;
  111. }
  112. function offsetSlider(index){
  113. // This will trigger a smooth css transition
  114. slider.css('left',(-index*100)+'%');
  115. }
  116. // Preload an image by its index in the items array
  117. function preload(index){
  118. setTimeout(function(){
  119. showImage(index);
  120. }, 1000);
  121. }
  122. // Show image in the slider
  123. function showImage(index){
  124. // If the index is outside the bonds of the array
  125. if(index < 0 || index >= items.length){
  126. return false;
  127. }
  128. $('.placeholder').load($('img').after("<div><i>After</i></div>"));
  129. $('.placeholder>div:gt(1)').remove();
  130. // Call the load function with the href attribute of the item
  131. loadImage(items.eq(index).attr('href'), function(){
  132. placeholders.eq(index).html(this);
  133. });
  134. }
  135. // Load the image and execute a callback function.
  136. // Returns a jQuery object
  137. function loadImage(src, callback){
  138. var img = $('<img>').on('load', function(){
  139. callback.call(img); });
  140. img.attr('src',src);
  141. }
  142. function showNext(){
  143. // If this is not the last image
  144. if(index+1 < items.length){
  145. index++;
  146. offsetSlider(index);
  147. preload(index+1);
  148. }
  149. else{
  150. // Trigger the spring animation
  151. slider.addClass('rightSpring');
  152. setTimeout(function(){
  153. slider.removeClass('rightSpring');
  154. },500);
  155. }
  156. }
  157. (function(d, s, id) {
  158.   var js, fjs = d.getElementsByTagName(s)[0];
  159.   if (d.getElementById(id)) return;
  160.   js = d.createElement(s); js.id = id;
  161.   js.src = 'http://connect.facebook.net/en_US/all.js#xfbml=1';
  162.   fjs.parentNode.insertBefore(js, fjs);
  163. }(document, 'script', 'facebook-jssdk'));
  164. function showPrevious(){
  165. // If this is not the first image
  166. if(index>0){
  167. index--;
  168. offsetSlider(index);
  169. preload(index-1);
  170. }
  171. else{
  172. // Trigger the spring animation
  173. slider.addClass('leftSpring');
  174. setTimeout(function(){
  175. slider.removeClass('leftSpring');
  176. },500);
  177. }
  178. }
  179. };
  180. })(jQuery);
Codes that are mentioned are added by me . Can any one tell me which is the correct place to add that query