				$(document).ready(function() {

					$('.thumbs a span').click(function() {
						var caption = $(this).attr('title');
						var thumb = $(this).css('background-image');
						thumb = thumb.split('thumbs/');
						var main_image = thumb[0] + thumb[1];
						var main_image_tmp = main_image.split('url(');
						var tmp = main_image_tmp[1].split(')');
						var main_image_url = tmp[0];
						
						var data_tmp = "image-url=" + main_image_url;
						$('.caption').text('');
						$('.main-image').fadeOut(1000, function() {
							$('.image').css({ "background-image": main_image });
							 
							$.ajax({
								type: "POST",
								url: "../inc/image_size.php",
								data: data_tmp,
								success: function(result){
									var image_width = 0;
									var image_height = 0;
									var tmp = result.split(' ');
									image_width = tmp[0];
									image_height = tmp[1];
									
									var width_main = eval(image_width) + 35;
						
									$('.image').css({ "width": image_width + "px", "height": image_height + "px" });
									$('.main-image').animate({ "width": width_main + "px" }, function() { 
										$('.caption').text(caption);
										$(this).fadeIn(1000); 
									});
																			
								}
							});
						});

					return false;
					});
					
					var left_pos = 0;
					var max_width = $('.thumbs-inner').css('width');
					var width_tmp = max_width.split('px');
					max_width = width_tmp[0];
					var bumper = 0;
					bumper = max_width - 610;
					
					$('.arrow-forward').click(function() {
						if(max_width == "auto") {
							max_width = document.getElementById('thumbs-inner').offsetWidth;
							bumper = max_width - 610;
						}
						if((bumper + left_pos) >= 122) {
							left_pos = eval(left_pos) - 122;
							$('.thumbs-content').animate({ "left": left_pos });
						}
						return false;
					});
					
					$('.arrow-back').click(function() {
						if(left_pos < 0) {
							left_pos = eval(left_pos) + 122;
							$('.thumbs-content').animate({ "left": left_pos });
						}
						return false;
					});
					
				});