window.onload = function()
{
	if (document.images.length === 0) {
		return;
	}

	var colors = ['#FFF', '#AAA', '#555', '#000'];
	var colors_count = colors.length;
	var click = 1;
	var _bgcolor = function()
	{
		if (click >= colors_count) {
			click = 0;
		}
		document.body.style.backgroundColor = colors[click];
		++click;
	};

	var img = document.images[0];
	var src_w = img.width;
	var src_h = img.height;
	var msec  = 15;
	var pixel = 10;
	var count = 0;
	var timer = 0;
	var _contract = function()
	{
		timer = setInterval('zoomout();', msec);
	};
	var _expand = function()
	{
		timer = setInterval('zoomin();', msec);
	};
	var _stop = function()
	{
		clearInterval(timer);
	};
	zoomout = function()
	{
		if (count > 0) {
			--count;
			zoom(img, -pixel);
		}
	};
	zoomin = function()
	{
		++count;
		zoom(img, pixel);
	};
	var zoom = function(img, pixel)
	{
		img.height += pixel;
		document.title = imginfo(img);
	};
	var imginfo = function(img)
	{
		var w = img.width;
		var h = src_h + (count * pixel);
		var per  = Math.round((h / src_h) * 100);
		var size = per + '% ' + w + 'x' + h;
		return size;
	};

	// onkeydownは止まらなくなるので未定義
	var elem;
	elem = document.getElementById('contract');
	elem.onmouseover = elem.onfocus = null;
	elem.onclick = function() {return false;};
	elem.onmousedown = _contract;
	elem.onmouseup = elem.onmouseout = _stop;

	elem = document.getElementById('expand');
	elem.onmouseover = elem.onfocus = null;
	elem.onclick = function() {return false;};
	elem.onmousedown = _expand;
	elem.onmouseup = elem.onmouseout = _stop;

	elem = document.getElementById('bgcolor');
	elem.onmouseover = elem.onfocus = null;
	elem.onclick = function() {return false;};
	elem.onmousedown = _bgcolor;
};

