function printWin(www) {
	win = open(www,'printWin','width=840,height=500,toolbar=yes,menubar=yes,scrollbars=yes,copyhistory=no,status=no,resizable=yes,location=no');
	posY = screen.availHeight;
	posX = screen.availWidth;
	win.moveTo((posX/2)-420,(posY/2)-250);
	win.focus();
}
function colorscale(hexstr, scalefactor) {
	/* declared variables first, in order;
	afterwards, undeclared local variables */
	var r = scalefactor;
	var a, i;
	if (r < 0 || typeof(hexstr) != 'string'){
		return hexstr;
	}
	hexstr = hexstr.replace(/[^0-9a-f]+/ig, '');
	if (hexstr.length == 3) {
		a = hexstr.split('');
	} else if (hexstr.length == 6) {
		a = hexstr.match(/(\w{2})/g);
	} else {
		return hexstr;
	}
	for (i=0; i<a.length; i++) {
		if (a[i].length == 2) {
			a[i] = parseInt(a[i], 16);
		} else {
			a[i] = parseInt(a[i], 16);
			a[i] = a[i]*16 + a[i];
		}
	}
	
	var maxColor = parseInt('ff', 16);

	function relsize(a) {
		if (a == maxColor)
			return Infinity;
		return a/(maxColor-a);
	}
	
	function relsizeinv(y) {
		if (y == Infinity)
			return maxColor;
		return maxColor*y/(1+y);
	}
	
	for (i=0; i<a.length; i++) {
		a[i] = relsizeinv(relsize(a[i])*r);
		a[i] = Math.floor(a[i]).toString(16);
		if (a[i].length == 1)
			a[i] = '0' + a[i];
	}
	return a.join('');
}