onload = function() {
	var e, i = 0;
	while (e = document.getElementById('gallery').getElementsByTagName ('DIV') [i++]) {
		if (e.className == 'onn' || e.className == 'off') {
		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('onn', 'off');
				}
			this.className = 'onn';
			var max = this.getAttribute('title');
			document.getElementById(max).className = "show";
			}
		}
	}
	
	var e1, j = 0;
	while (e1 = document.getElementById('gallery1').getElementsByTagName ('DIV') [j++]) {
		if (e1.className == 'od' || e1.className == 'ofd') {
		e1.onclick = function () {
			var getEls = document.getElementsByTagName('DIV');
				for (var z=0; z<getEls.length; z++) {
				getEls[z].className=getEls[z].className.replace('shod', 'hidd');
				getEls[z].className=getEls[z].className.replace('od', 'ofd');
				}
			this.className = 'od';
			var max = this.getAttribute('title');
			document.getElementById(max).className = "shod";
			}
		}
	}
}
