$(document).ready(function(){

//Larger thumbnail preview 
var oldW;
var oldH;
$(".zoom").each(function(){
				$(this).wrap('<div align="'+ $(this).attr('align') +'" style="float:'+ $(this).attr('align') +'; width:'+ $(this).width() +'px; height:'+ $(this).height() +'px;" class="zoomParent" />');
			})

$(".zoom").hover(function() {
	oldW=$(this).width();
	oldH=$(this).height();
	$(this).css({'z-index' : '10'});
	var imgs=getImgSize($(this).attr('src'));
	$(this).addClass("hover").stop()
		.animate({
			width: imgs[0].width, 
			height: imgs[0].height,
			borderWidth: 7
		}, 200);
	
	} , function() {
	$(this).css({'z-index' : '0'});
	$(this).removeClass("hover").stop()
		.animate({
			width: oldW, 
			height: oldH,
			borderWidth:0
		}, 400);
});

//Swap Image on Click
	$(".zoom a").click(function() {
		
		var mainImage = $(this).attr("href"); //Find Image Name
		$("#main_view img").attr({ src: mainImage });
		return false;		
	});
 
});

function getImgSize(imgSrc){
    var newImg = new Image();
    newImg.src = imgSrc;
    var height = newImg.height;
    var width = newImg.width;
    p = $(newImg).ready(function(){
        return {width: newImg.width, height: newImg.height};
    });
	 return p;
}

