// copyright 2009 Laura Shaffer Mills// set up "onload" to initializewindow.onload = function(){	initialize();	initializeImages("spotlights",".gif");	sizeDiv("spotlights");		// adjust the div size if necessary	drawClock("spotlights");		// draw the spotlights}			// window.onload()// paint the combination color in center, based on color sources "on"function paintColor() {	var centerLight = document.getElementById("lightcolor");	var colorList = new Array;	var numColors = 0;				// number of color sources "on"	var newColor = 0x000000;		// default to black if nothing	// find color sources that are on	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;		var maxValue = 0;		// add component parts (red, green, and blue) for each color		for (var i = 0; i < numColors; i++) {			red += (colorList[i] >> 16) & 0xff;			green += (colorList[i] >> 8) & 0xff;			blue += colorList[i] & 0xff;		}		// make the largest into "ff" at the most		maxValue = Math.max( Math.max(red,green), blue );		if (maxValue > 0xff) {			var percent = 0xff / maxValue;			red *= percent;			green *= percent;			blue *= percent;			// set maximum values			if (red > 0xff)				red = 0xff;			if (green > 0xff)				green = 0xff;			if (blue > 0xff)				blue = 0xff;		}		newColor = (parseInt(red,10) << 16) + (parseInt(green,10) << 8) + parseInt(blue,10);	}			// calculating color combination	// 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	centerLight.style.backgroundColor = "#" + temp;}			// paintColor()
