onload = function() {
	var e, i = 0;
	while (e = document.getElementById('gallery').getElementsByTagName ('DIV') [i++]) {
		if (e.className == 'on1' || e.className == 'off1') {
		e.onclick = function () {
			var getEls = document.getElementsByTagName('DIV');
				for (var z=0; z<getEls.length; z++) {
				getEls[z].className=getEls[z].className.replace('show', 'hide');
				getEls[z].className=getEls[z].className.replace('on1', 'off1');
				}
			this.className = 'on1';
			var max = this.getAttribute('title');
			document.getElementById(max).className = "show";
			}
		}
	}
}