var resized_images_width = new Array();
var resized_images_height = new Array();
var max_width = 400;

function img_fullscreen(){
	scrollbars = 0;
	var oSource = window.event.srcElement.src;
	i_width = resized_images_width[oSource];
	i_height = resized_images_height[oSource];

	img_url = "http://www.flyengravity.com/forum_image.html?"+oSource;

	if (i_width > screen.availWidth) {
		i_width = screen.availWidth;
		scrollbars = 1;
	}

	if (i_height > screen.availHeight) {
		i_height = screen.availHeight;
		scrollbars = 1;
	}

	fullscr = window.open(img_url, "_blank","toolbar=no,location=no,menubar=no,fullscreen="+scrollbars+",channelmode="+scrollbars+",scrollbars="+scrollbars+",status=no,left=0,top=0,width="+i_width+",height="+i_height);
}

function img_resize(image){
	if (!image) {
		var image = window.event.srcElement;
	}

	i_width = image.width;
	i_height = image.height;
	var img_url = image.src;

	if (i_width > max_width) {
		resized_images_width[img_url] = i_width;
		resized_images_height[img_url] = i_height;
		image.width = max_width;
		image.alt = i_width+'x'+i_height+' pixels';
		image.style.border = "dashed 1px black";
		image.style.cursor = "hand";
		image.onclick = img_fullscreen;
		image.height = Math.floor(i_height/(i_width/max_width));
	}
}

function check_images() {
	i_count = document.images.length;
	i = 0;

	while (i_count>i) {
		img_url = document.images[i].src;

		if (!img_url.match(/www.flyengravity.com\/img/)) {
			if (document.images[i].complete) {
				img_resize(document.images[i]);
			} else {
				document.images[i].onload = img_resize;
				document.images[i].onerror = document.images[i].src = 'http://www.flyengravity.com/x.gif';
			}
		}
		i++;
	}
}