function dotnet(addr, i, w, h) {
	var html = '<object id="Image' + i + '" width="' + w + '" height="' + h + '" classid="StarDotNet.dll#StarDotNet.HttpImage"><param name="url" value="http://' + addr + '/nph-mjpeg.cgi?' + i + '"><param name="status" value="1"></object>';
	document.write(html);
}

function imageCheck(e, img, w, h)
{
	var c;
	if (img.complete === null || img.complete === false) {
		setTimeout(function() {
				imageCheck(e, img, w, h);
			}, 250);
		return;
	}

	c = e.getElementsByTagName("img")[0];
	if (c)
		e.replaceChild(img, c);
	else
		e.appendChild(img);
	imageLoad(e, w, h);
}

function imageLoad(e, w, h)
{
	var img, now, id;
	if (!e)
		return;
	img = new Image();
	now = new Date();
	id = e.id;
	img.src = '/jpeg.cgi?' + id.slice(5) + '&' + now.getTime();
	img.width = w;
	img.height = h;
	img.style.width = w;
	img.style.height = h;
	img.onload = function() {
		imageCheck(e, img, w, h);
	}
}

/*@cc_on
  @if (@_jscript)
function doSaveAs(w)
{
	w.document.execCommand("SaveAs");
}
  @end
  @*/

function saveImage(img)
{
/*@cc_on
  @if (@_jscript)
	if (typeof img == 'object')
		img = img.src;
	var win = window.open(img);
                                                                                
	if (win.addEventListener) {
		win.addEventListener("load", function() { doSaveAs(win); }, false);
	} else if (win.attachEvent) {
		win.attachEvent("onload", function() { doSaveAs(win); } );
	}
  @else*/
	var win = window.open();
	win.document.write("<img src='" + img + "'><br>");
	win.document.write("<span style='font: 80% tahoma, verdana, sans-serif !important;'>Right click on the image, then select 'Save Image As...'</span>");
	win.document.close();
/*@end
  @*/
}

