// prep global array that will hold all the widget dots.
var widget_dots = new Array();
var last_dot_clicked;

function kill_dot_outlines() {
	var arr_a = document.getElementsByTagName('a');
	for(var i = 0; i < arr_a.length; i++) {
		arr_a[i].onfocus= function() { this.blur() };
	}
}

function loadpic(who, what, width, height) {
	str = '';
	str += '<img src="'+ what +'" width="'+ width +'" height="'+ height +'" alt=""/>';
	document.getElementById(who).innerHTML = str;
	return false;
}

//alt version for the solutions pages to add captions under the pics
function loadpicture(who, captiondiv, what, caption, width, height) {
	str = '';
	str += '<img src="'+ what +'" width="'+ width +'" height="'+ height +'" alt="'+ caption + '"/>';
	document.getElementById(who).innerHTML = str;
	document.getElementById(captiondiv).innerHTML = caption;
	return false;
}

window.onload = function() {
	widget_dot_count = 0;
	// find all the widget dots.
	arr_img = document.getElementsByTagName('img');
		for(var i = 0; i < arr_img.length; i++) {
			if(null !== arr_img[i].getAttribute("type") && arr_img[i].getAttribute("type") == 'widget_dot') {
				// copy the widget dot to the global 'widget_dots' array.
				widget_dots[widget_dot_count] = arr_img[i];
				// give them their onclick behavior.
				widget_dots[widget_dot_count].onclick = function() { clear_set_widget_dots(this, this.name);};
				// prep for the next widget dot.
				widget_dot_count++;
			}
		}
	kill_dot_outlines();
}

function clear_set_widget_dots(obj, objName){
	// reset all the widget dots. 
	for(var i = 0; i < widget_dots.length; i++) { if (widget_dots[i].name == objName) {widget_dots[i].src = "img/dot_off.gif";} }
	// set the clicked dot to 'on'
	obj.src="img/dot_on.gif";
	last_dot_clicked = obj;
}