if (!window.LightSwitch) { // in case this script gets loaded multiple times

	var LightSwitch = function () {
		this.swtch = document.getElementById('lightSwitch'); // use this.swtch because 'switch' is a reserved keyword		
		this.headerPicL = document.getElementById('headerPicL');		
		this.headerPicR = document.getElementById('headerPicR');
		this.status = 'on';		
		var oThis = this;
		
		// Assign event handlers
		YAHOO.util.Event.addListener(this.swtch, 'mouseup', function(e) {
			oThis.handleMouseUp(e);
		});
		
		// Preload night images
		(new Image()).src = 'images/kids/lightSwitchDown.gif';
		(new Image()).src = 'images/kids/headerPicLOff.jpg';
		(new Image()).src = 'images/kids/headerPicROff.jpg';
	}

	LightSwitch.prototype.handleMouseUp = function (e) {
		var target = YAHOO.util.Event.getTarget(e);
		
		
		if (this.status == 'on') {
			YAHOO.util.Dom.addClass(this.swtch, 'off');
			YAHOO.util.Dom.addClass(this.headerPicL, 'off');
			YAHOO.util.Dom.addClass(this.headerPicR, 'off');
			this.status = 'off'
		} else {
			YAHOO.util.Dom.removeClass(this.swtch, 'off');
			YAHOO.util.Dom.removeClass(this.headerPicL, 'off');
			YAHOO.util.Dom.removeClass(this.headerPicR, 'off');
			this.status = 'on'
		}
	}
	
	YAHOO.util.Event.addListener(window, 'load', function() {
		var lightSwitch = new LightSwitch();
	});
}
