function getwwidth () {
	return ((document.documentElement) ? document.documentElement.clientWidth : document.body.clientWidth) - 18;
}

function handle (element, event, func) {
    if (element.attachEvent) {
        element.attachEvent ('on' + event, func);
    } else {
        element.addEventListener (event, func, false);
    }
    return { e: element, fun : func, name : event }
}

function resize(photo) {
    var windowwidth = getwwidth();
    var notice = document.getElementById('body-notice');
    var cursor = document.getElementById('image');
    if(width != 0) {
        if ((!photo._clicked) && (width > windowwidth)) {
	    photo.width = windowwidth;
	    photo.height = (photo.width / width) * height;
            cursor.style.cursor = 'pointer';
            notice.style.display = 'block';

        } else {
	    photo.width = width;
	    photo.height = height;
	    cursor.style.cursor = 'default';
	    notice.style.display = 'none';
        }
    }
}

handle (window, 'load', function () {
    var photo = document.getElementById('image');
    if (photo) {
	photo._clicked = false;
	handle (photo, 'click', function () {
	    if (width > getwwidth ()) {
		photo._clicked = !photo._clicked;
		resize(photo);
	    }
	})
		
	handle (window, 'resize', function () {
	    if (t)
	        window.clearTimeout(t);
	    var t = window.setTimeout(function() { resize(photo) }, 20);
	})
	    resize(photo);
	}
})
