Witam.

Znalazłem sobie fajny skrypt do ładowania zdjęć ( http://www.dynamicdrive.com/dynamicindex4/thumbnail.htm ) , niestety kiedy chciałem go połączyć z moją stronką pojawia się problem.

Mianowicie kiedy następuję przeładowanie strony ładowany jest skrypcik i wszystko działa. Ale w momencie kiedy spróbuję użyć AJAX'a do przeładowania stronki (mam menu w którym jak klikam to przeładowywana jest środkowa część strony) to już mi nie działa skrypt :/

Skrypt działa tak, że podajemy na stronce link:
  1. <?php
  2. <a href="http://img184.imageshack.us/img184/1159/castleyi6.gif" rel="thumbnail" title="This is beautiful castle for sale!">Castle</a>
  3. ?>


Po kliknieciu w niego ładuje się graficzka... w nagłówku mam zadeklarowane:
  1. <link rel="stylesheet" href="thumbnailviewer.css" type="text/css" />
  2. <script src="thumbnailviewer.js" type="text/javascript">


A sam js:
  1. // -------------------------------------------------------------------
  2. // Image Thumbnail Viewer Script- By Dynamic Drive, available at: http://www.dynamicdrive.com
  3. // Last updated: Jan 22nd, 2007
  4. // -------------------------------------------------------------------
  5.  
  6. var thumbnailviewer={
  7. enableTitle: true, //Should "title" attribute of link be used as description?
  8. enableAnimation: true, //Enable fading animation?
  9. definefooter: '<div class="footerbar">zamknij <b>X</b></div>', //Define HTML for footer interface
  10. defineLoading: 'Trwa ładowanie...<br /><img src="images/ajax-loader.gif" /> ', //Define HTML for "loading" div
  11.  
  12. /////////////No need to edit beyond here/////////////////////////
  13.  
  14. scrollbarwidth: 16,
  15. opacitystring: 'filter:progid:DXImageTransform.Microsoft.alpha(opacity=10); -moz-opacity: 0.1; opacity: 0.1',
  16. targetlinks:[], //Array to hold links with rel="thumbnail"
  17.  
  18. createthumbBox:function(){
  19. //write out HTML for Image Thumbnail Viewer plus loading div
  20. document.write('<div id="thumbBox" onClick="thumbnailviewer.closeit()"><div id="thumbImage"></div>'+this.definefooter+'</div>')
  21. document.write('<div id="thumbLoading">'+this.defineLoading+'</div>')
  22. this.thumbBox=document.getElementById("thumbBox")
  23. this.thumbImage=document.getElementById("thumbImage") //Reference div that holds the shown image
  24. this.thumbLoading=document.getElementById("thumbLoading") //Reference "loading" div that will be shown while image is fetched
  25. this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
  26. },
  27.  
  28.  
  29. centerDiv:function(divobj){ //Centers a div element on the page
  30. var ie=document.all && !window.opera
  31. var dom=document.getElementById
  32. var scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
  33. var scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
  34. var docwidth=(ie)? this.standardbody.clientWidth : window.innerWidth-this.scrollbarwidth
  35. var docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
  36. var docheightcomplete=(this.standardbody.offsetHeight>this.standardbody.scrollHeight)? this.standardbody.offsetHeight : this.standardbody.scrollHeight //Full scroll height of document
  37. var objwidth=divobj.offsetWidth //width of div element
  38. var objheight=divobj.offsetHeight //height of div element
  39. var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2+"px" : scroll_top+10+"px" //Vertical position of div element: Either centered, or if element height larger than viewpoint height, 10px from top of viewpoint
  40. divobj.style.left=docwidth/2-objwidth/2+"px" //Center div element horizontally
  41. divobj.style.top=Math.floor(parseInt(topposition))+"px"
  42. divobj.style.visibility="visible"
  43. },
  44.  
  45. showthumbBox:function(){ //Show ThumbBox div
  46. this.centerDiv(this.thumbBox)
  47. if (this.enableAnimation){ //If fading animation enabled
  48. this.currentopacity=0.1 //Starting opacity value
  49. this.opacitytimer=setInterval("thumbnailviewer.opacityanimation()", 20)
  50. }
  51. },
  52.  
  53.  
  54. loadimage:function(link){ //Load image function that gets attached to each link on the page with rel="thumbnail"
  55. if (this.thumbBox.style.visibility=="visible") //if thumbox is visible on the page already
  56. this.closeit() //Hide it first (not doing so causes triggers some positioning bug in Firefox
  57. var imageHTML='<img src="'+link.getAttribute("href")+'" style="'+this.opacitystring+'" />' //Construct HTML for shown image
  58. if (this.enableTitle && link.getAttribute("title")) //Use title attr of the link as description?
  59. imageHTML+='<br />'+link.getAttribute("title")
  60. this.centerDiv(this.thumbLoading) //Center and display "loading" div while we set up the image to be shown
  61. this.thumbImage.innerHTML=imageHTML //Populate thumbImage div with shown image's HTML (while still hidden)
  62. this.featureImage=this.thumbImage.getElementsByTagName("img")[0] //Reference shown image itself
  63. this.featureImage.onload=function(){ //When target image has completely loaded
  64. thumbnailviewer.thumbLoading.style.visibility="hidden" //Hide "loading" div
  65. thumbnailviewer.showthumbBox() //Display "thumbbox" div to the world!
  66. }
  67. if (document.all && !window.createPopup) //Target IE5.0 browsers only. Address IE image cache not firing onload bug: panoramio.com/blog/onload-event/
  68. this.featureImage.src=link.getAttribute("href")
  69. this.featureImage.onerror=function(){ //If an error has occurred while loading the image to show
  70. thumbnailviewer.thumbLoading.style.visibility="hidden" //Hide "loading" div, game over
  71. }
  72. },
  73.  
  74. setimgopacity:function(value){ //Sets the opacity of "thumbimage" div per the passed in value setting (0 to 1 and in between)
  75. var targetobject=this.featureImage
  76. if (targetobject.filters && targetobject.filters[0]){ //IE syntax
  77. if (typeof targetobject.filters[0].opacity=="number") //IE6
  78. targetobject.filters[0].opacity=value*100
  79. else //IE 5.5
  80. targetobject.style.filter="alpha(opacity="+value*100+")"
  81. }
  82. else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax
  83. targetobject.style.MozOpacity=value
  84. else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax
  85. targetobject.style.opacity=value
  86. else //Non of the above, stop opacity animation
  87. this.stopanimation()
  88. },
  89.  
  90. opacityanimation:function(){ //Gradually increase opacity function
  91. this.setimgopacity(this.currentopacity)
  92. this.currentopacity+=0.1
  93. if (this.currentopacity>1)
  94. this.stopanimation()
  95. },
  96.  
  97. stopanimation:function(){
  98. if (typeof this.opacitytimer!="undefined")
  99. clearInterval(this.opacitytimer)
  100. },
  101.  
  102.  
  103. closeit:function(){ //Close "thumbbox" div function
  104. this.stopanimation()
  105. this.thumbBox.style.visibility="hidden"
  106. this.thumbImage.innerHTML=""
  107. this.thumbBox.style.left="-2000px"
  108. this.thumbBox.style.top="-2000px"
  109. },
  110.  
  111. cleanup:function(){ //Clean up routine on page unload
  112. this.thumbLoading=null
  113. if (this.featureImage) this.featureImage.onload=null
  114. this.featureImage=null
  115. this.thumbImage=null
  116. for (var i=0; i<this.targetlinks.length; i++)
  117. this.targetlinks[i].onclick=null
  118. this.thumbBox=null
  119. },
  120.  
  121. dotask:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
  122. var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
  123. if (target.addEventListener)
  124. target.addEventListener(tasktype, functionref, false)
  125. else if (target.attachEvent)
  126. target.attachEvent(tasktype, functionref)
  127. },
  128.  
  129. init:function(){ //Initialize thumbnail viewer script by scanning page and attaching appropriate function to links with rel="thumbnail"
  130. if (!this.enableAnimation)
  131. this.opacitystring=""
  132. var pagelinks=document.getElementsByTagName("a")
  133. for (var i=0; i<pagelinks.length; i++){ //BEGIN FOR LOOP
  134. if (pagelinks[i].getAttribute("rel") && pagelinks[i].getAttribute("rel")=="thumbnail"){ //Begin if statement
  135. pagelinks[i].onclick=function(){
  136. thumbnailviewer.stopanimation() //Stop any currently running fade animation on "thumbbox" div before proceeding
  137. thumbnailviewer.loadimage(this) //Load image
  138. return false
  139. }
  140. this.targetlinks[this.targetlinks.length]=pagelinks[i] //store reference to target link
  141. } //end if statement
  142. } //END FOR LOOP
  143. //Reposition "thumbbox" div when page is resized
  144. this.dotask(window, function(){if (thumbnailviewer.thumbBox.style.visibility=="visible") thumbnailviewer.centerDiv(thumbnailviewer.thumbBox)}, "resize")
  145.  
  146.  
  147. } //END init() function
  148.  
  149. }
  150.  
  151. thumbnailviewer.createthumbBox() //Output HTML for the image thumbnail viewer
  152. thumbnailviewer.dotask(window, function(){thumbnailviewer.init()}, "load") //Initialize script on page load
  153. thumbnailviewer.dotask(window, function(){thumbnailviewer.cleanup()}, "unload")


Bardzo proszę o pomoc jak sobie poradzić z tym problemem :/ Wnioskuję, że w momencie kiedy przy użyciu Ajaxa ładuję content w którym jest omawiany <a href... on poprostu nie dopisuje do niego właściwego kodu z skryptu sad.gif