private void writeLights(Document document) {
		for (int i = 0; i < lights.size(); i++) {
			Element lightNode = document.createElement("light");
			Element color = document.createElement("color");
			color.appendChild(document.createTextNode(write3Tuple(lights.get(i)
					.getColor())));
			lightNode.appendChild(color);

			if (lights.get(i) instanceof AmbientLightObject) {
				lightNode.setAttribute("type", "ambient");
				document.getFirstChild().appendChild(lightNode);
			} else if (lights.get(i) instanceof PointLightObject) {
				lightNode.setAttribute("type", "point");
				PointLightObject pLight = (PointLightObject) lights.get(i);
				Element attenuation = document.createElement("attenuation");
				attenuation.appendChild(document
						.createTextNode(write3Tuple(pLight.getAttenuation())));
				lightNode.appendChild(attenuation);
			} else if (lights.get(i) instanceof DirectionalLightObject) {
				lightNode.setAttribute("type", "directional");
				DirectionalLightObject dLight = (DirectionalLightObject) lights
						.get(i);
				Element direction = document.createElement("direction");
				direction.appendChild(document
						.createTextNode(write3Tuple(dLight.getDirection())));
				lightNode.appendChild(direction);
			}
			Element bounds = document.createElement("bounds");
			Element position = document.createElement("position");
			position.appendChild(document.createTextNode(write3Tuple(lights
					.get(i).getPosition())));
			bounds.appendChild(position);
			Element radius = document.createElement("radius");
			radius.appendChild(document.createTextNode(Double.toString(lights
					.get(i).getRadius())));
			bounds.appendChild(radius);
			lightNode.appendChild(bounds);
			document.getFirstChild().appendChild(lightNode);
		}

	}