Ara,
<!DOCTYPE HTML>
<html>
<head>
<title>JavaScript</title>
<meta charset="utf-8">
</head>
<body>
<img src = "http://javascript.ru/forum/images/ca_serenity/misc/logo.gif" name = "i" >
<br>
<script language="javascript">
var w = +prompt("Введите ширину", 400) || 400,
h = +prompt("Введите высоту", 200) || 200,
img = document.images.i,
hh = img.height,
ww = img.width,
k = hh,
z = ww,
i = setInterval(funMax, 100);
h < hh && (h = hh+50);
w < ww && (w = ww+100);
function funMax() {
k < h && (img.height = k++);
z < w && (img.width = z++);
k == h && z == w && (window.clearInterval(i), i = setInterval(funMin, 100))
}
function funMin() {
k > hh && (img.height = k--);
z > ww && (img.width = z--);
k == hh && z == ww && (window.clearInterval(i), i = setInterval(funMax, 100))
};
</script>
</body>
</html>