function changeImage(img)
{
    var newImg = new Image();
    newImg.src = img;
    var height = newImg.height;
    var width = newImg.width;
    var varwidth;
	var varheight;
	if(width > 400){varwidth = 420; }
	if(height >500){varheight = 500; }  
    var imgNew = '<img src="'+img+'" style = "width:'+varwidth+'px;height:'+varheight+'px" alt="" />'; 

	setTimeout('insert(\''+img+'\')',200);
}
function insert(imgNew)
{
	document.getElementById('mainImg').src = imgNew;
}
