
$.fn.image = function(src, f){ 
   return this.each(function(){
     var i = new Image(); 
     this.onload = f;
     this.src = src; 
     //this.appendChild(i);
   }); 
 } 

preloadImages = function() {
var a = (typeof arguments[0] == 'object')? arguments[0] : arguments;
for(var i = a.length -1; i > 0; i--) {
jQuery("<img>").attr("src", a[i]);
}
}

function doSwapImg(imgid){
new_img = new Image();
new_img.src = imgList[imgid];

$('#gallery_image').fadeTo(500, 0, function(){

$("#gallery_image").image(new_img.src,function(){
$('#gallery_image').fadeTo(500,1); 
});

var thumbs = document.getElementById("thumbnails").getElementsByTagName("a");
for (var i=0;i<thumbs.length; ++i){$("#thumbs"+i).removeClass('active')}

$("#thumbs"+imgid).addClass('active');
$('#image_title').attr("innerHTML",unescape((new_img.src).substring(35,(new_img.src).length - 4)));
//img_height =  ((530 / new_img.width) * new_img.height)+20;
//$('#picture').animate({height: img_height},250,"linear",function(){
 
//});
});
}