function setLinks() {
	if (!document.getElementById) return;
	var gallery = document.getElementById('gallery');
	var main_cont = document.getElementById('main_content');
	var close = document.getElementById('close');
	var next = document.getElementById('next');
	var prev = document.getElementById('prev');
	var pic = document.getElementById('pic');
	var orientation = new Array();

	var thumbs = document.getElementById('thumbs').getElementsByTagName('a');
		base = thumbs[0].firstChild.src.replace('thumbs', 'gallery');
		base = base.substring(0, base.indexOf('0.gif'));
	for (var i=0; i<thumbs.length; i++) {
		orientation[i] = thumbs[i].firstChild.className;
		thumbs[i].className= i;
		thumbs[i].onclick = function() {
			var no = this.className*1;
			if(orientation[no].indexOf('h') != -1) {
				pic.style.right = '30px';
				pic.style.bottom = '89px';
			} else {
				pic.style.right = '94px';
				pic.style.bottom = '20px';
			}
			pic.src = '/images/tr.gif';
			pic.src = base + no + '.jpg';
			next.className = (no+1==thumbs.length?0:no+1);
			prev.className = (no-1<0?thumbs.length-1:no-1);
			gallery.style.display = 'block';
			main_cont.style.display = 'none';
			return false;
		}
	}
	close.onclick = function() {
		main_cont.style.display = 'block';
		gallery.style.display = 'none';
		return false;
	}
	next.onclick = function() {
		this.blur();
		pic.src = '/images/tr.gif';
		var no = this.className*1;
		if(orientation[no].indexOf('h') != -1) {
			pic.style.right = '30px';
			pic.style.bottom = '89px';
		} else {
			pic.style.right = '94px';
			pic.style.bottom = '20px';
		}
		next.className = (no+1==thumbs.length?0:no+1);
		prev.className = (no-1<0?thumbs.length-1:no-1);
		pic.src = base + no + '.jpg';
		return false;
	}
	prev.onclick = function() {
		this.blur();
		pic.src = '/images/tr.gif';
		var no = this.className*1;
		if(orientation[no].indexOf('h') != -1) {
			pic.style.right = '30px';
			pic.style.bottom = '89px';
		} else {
			pic.style.right = '94px';
			pic.style.bottom = '20px';
		}
		next.className = (no+1==thumbs.length?0:no+1);
		prev.className = (no-1<0?thumbs.length-1:no-1);
		pic.src = base + no + '.jpg';
		return false;
	}
}
function init() {
	bgrCache();
	defocus();
	setLinks();
	var a = new Image();
	a.src = '/images/tr.gif';
}
window.onload = init;

