There are 5 copies of the same images are placed in a folder i.e. large(1024*768),medium(500*375),small(240*180),thu mnail(75*75),square(100*50) in size....
The following code upload number of Geocoded images(square size) when the page loads.I want when someone click on the any Geocoded image on the page ,it should show the large image(1024*768) of the same.And further click on the large image it must show again the square size image of the same.
Following is the actual code.It is in .js file.



1. var epsg4326 = new OpenLayers.Projection("EPSG:4326");
2. var OSVMain = (function() {
3. var map, markers, map_move_timeout;
4. var photos = {};
5. function mapChange() {
6. if( map_move_timeout )
7. clearTimeout(map_move_timeout);
8. map_move_timeout = setTimeout(mapChangeTimeout, 500);
9. updateLinks();
10. }
11. function updateLinks() {
12. var center = OSV.getMapCenter(map);
13. var zoom = map.getZoom();
14. $('#permalink').attr('href',OSV.getURLBase()+'?lat='+center.lat+'&lon='+center.lon+'&zoom='+zoom);
15. $('#kmllink').attr('href',getLocateLink('kml'));
16. }
17. function getLocateLink(format) {
18. var extent = OSV.getMapExtent(map);
19. var url = OSV.getURLBase()+'/api/photos/locate.'+format+'?bbox=';
20. url += [ extent.left, extent.bottom, extent.right, extent.top].join(',');
21. return url;
22. }
23. function mapChangeTimeout() {
24. map_move_timeout = null;
25. var url = getLocateLink('json');
26. $.get( url, null, photosLoaded, 'json' );
27. }
28. function photosLoaded(json) {
29. var new_photos = {};
30. var size = new OpenLayers.Size(50, 50);
31. var offset = new OpenLayers.Pixel(-25, -25);
32. for( var i = 0, l = json.length; i < l; ++i ) {
33. var p = new OSVPhoto(json[i]);
34. if( photos[p.data.id] ) {
35. new_photos[p.data.id] = photos[p.data.id];
36. photos[p.data.id] = null;
37. } else {
38. var position = new OpenLayers.LonLat(p.data.lon,p.data.lat);
39. var icon = new OpenLayers.Icon(p.url('square'), size, offset);
40. p.marker = new OpenLayers.Marker(position.clone().transform(epsg4326, map.getProjectionObject()), icon);
41. new_photos[p.data.id] = p;
42. markers.addMarker(p.marker);
43.
44. }
45. }
46. for( var k in photos ) {
47. var p = photos[k];
48. if( p && p.marker )
49. markers.removeMarker(p.marker);
50. }
51. photos = new_photos;
52. }
53. function setup() {
54. var vectors;
55. var popup;
56.
57. map = new OpenLayers.Map($('#map').get(0), {
58. controls: [
59. new OpenLayers.Control.ArgParser(),
60. new OpenLayers.Control.Attribution(),
61. new OpenLayers.Control.LayerSwitcher(),
62. new OpenLayers.Control.Navigation(),
63. new OpenLayers.Control.PanZoomBar()
64. ],
65. units: "m",
66. maxResolution: 156543.0339,
67. numZoomLevels: 20,
68. displayProjection: new OpenLayers.Projection("EPSG:4326")
69. });
70.
71. var mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {
72. displayOutsideMaxExtent: true,
73. wrapDateLine: true
74. });
75. map.addLayer(mapnik);
76.
77. var osmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender", {
78. displayOutsideMaxExtent: true,
79. wrapDateLine: true
80. });
81. map.addLayer(osmarender);
82.
83. var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels);
84.
85. var start = OSV.getStartLocation();
86. var numzoom = map.getNumZoomLevels();
87. if (start.zoom >= numzoom) start.zoom = numzoom - 1;
88. map.setCenter(start.pos.clone().transform(epsg4326, map.getProjectionObject()), start.zoom);
89. OSV.setupMapEventHandlers(map);
90. map.events.register("moveend", map, mapChange);
91. map.events.register("zoomend", map, mapChange);
92. mapChange();
93.
94.
95.
96. markers = new OpenLayers.Layer.Markers("Markers", {
97. displayInLayerSwitcher: false,
98. numZoomLevels: numZoomLevels,
99. maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
100. maxResolution: 156543,
101. units: "m",
102. projection: "EPSG:900913"
103. });
104. map.addLayer(markers);
105.
106. }
107. return {
108. setup: setup,
109. 1:1
110. };
111. })();
112. $(function(){
113. OSVMain.setup();
114. });



Any suggestions ?
Thanking you