The Splitter

Instructions

Test UI

				
		/* The code that makes the magic on this HTML document ^^ */
		window.onload = function() {
			document.getElementById('sandbox').onclick = function(e) { catchClick(e); }
		}
		function catchClick(e) {
			var el  = e.target;
			var w   = e.target.offsetWidth;
			var h   = e.target.offsetHeight;
			var el2;
			for(var i=0;i<2;i++) {
				el2 			= document.createElement("div");
				el2.className 		= (el.className=="v") ? "h":"v";
				el2.offsetWidth  	= w/2;
				el2.offsetHeight 	= h/2;
				el2.setAttribute("style",nextColor());
				el.appendChild(el2);
			}
		}