// copyright 2009 Laura Shaffer Mills// set up "onload" to initializewindow.onload = function(){	initialize();	initializeImages("spotlights","pt.gif");	sizeDiv("spotlights");		// adjust the div size if necessary	drawClock("spotlights");		// draw the spotlights}			// window.onload()// paint the combination color in center, based on paint "on" or pouredfunction paintColor() {	var centerColor = document.getElementById("paintcolor");	var colorList = new Array;	var numColors = 0;				// number of paints "on"	var newColor = 0xffffff;		// default to white if no paint	// find paints that are used	for (var i = 0; i < 12; i++) {		if (gColorSources.isOn[i] > 0) {		// is it currently on?			colorList[numColors++] = gColorSources.colors[i];		// add to my list of colors		}	}	if (0 != numColors) {		// calculate color combination		var red = 0; green = 0; blue = 0;		// get component parts (red, green, and blue) for each color		for (var i = 0; i < numColors; i++) {			red += (colorList[i] >> 16) & 0x0ff;			green += (colorList[i] >> 8) & 0x0ff;			blue += colorList[i] & 0x0ff;		}		// average		red /= numColors;		green /= numColors;		blue /= numColors;// ### try using color math with yellow being brighter etc. (LAB or HSL/HSV)?  Use CMY?//	multiply two colors together and take the square root (geometric mean)?// ### would it be better to darken by a percentage? (darken larger amount per color, for fewer colors)		var subtract = 0;		if (numColors > 1)			subtract = 0x20 * (numColors - 1);		// make blacker as add more colors		red -= subtract;		blue -= subtract;		green -= subtract;		// make sure all colors in range		red = Math.min(red,0xff);		green = Math.min(green,0xff);		blue = Math.min(blue,0xff);		red = Math.max(red,0);		green = Math.max(green,0);		blue = Math.max(blue,0);		newColor = (parseInt(red,10) << 16) + (parseInt(green,10) << 8) + parseInt(blue,10);	}	// paint color	var temp = newColor.toString(16);	var oldLength = temp.length;	// now add leading zeros if needed	if (temp.length < 6) {		for (var i = 0; i < (6 - oldLength); i++)			temp = "0" + temp;	}	// paint it	centerColor.style.backgroundColor = "#" + temp;}			// paintColor()
