function getWindowInnerXY() { // 1.0
	var winX, winY;
	if(typeof(window.innerWidth) == 'number') {
		winX = window.innerWidth;
		winY = window.innerHeight;
	} 
	else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		winX = document.documentElement.clientWidth;
		winY = document.documentElement.clientHeight;
	}
	else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
		winX = document.body.clientWidth;
		winY = document.body.clientHeight;
	}
	return Array(winX, winY);
}

function getScrollTop() { // 1.0
	var pos = 0;
	if(window.innerHeight) { 
		pos = window.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop) {
		pos = document.documentElement.scrollTop;
	}
	else if (document.body) {
		pos = document.body.scrollTop;
	}
	return pos;
}

function imager(id) { // 1.2
	this.placeImage = function() {
		var winXY = getWindowInnerXY();
		var half = parseInt(this.img.width / 2);
		this.div.style.marginLeft = '-' + (half > winXY[0] / 2 ? parseInt(winXY[0] / 2) - 10 : half ) + 'px';
		this.div.style.width = (winXY[0] - 40 < this.img.width ? winXY[0] - 40 + 'px' : '');
		this.div.style.height = (winXY[1] - 40 < this.img.height ? winXY[1] - 40 + 'px' : '');
		this.div.style.top = getScrollTop() + 10 + 'px';
		this.div.style.display = 'block';
	}
	this.s = function (link) {
		if(!(alt=link.firstChild.alt)) {
			var alt = link.href.substring(link.href.lastIndexOf('/') + 1);
		}
		this.img.src = link.href;
		this.img.alt = alt;
		this.img.title = 'Close ' + alt;
		return false;
	}
	this.div = document.createElement('DIV');
	this.div.id = id;
    this.div.onclick = function() { this.style.display = 'none' };
	this.img = document.createElement('IMG');
	this.img.obj = this;
	this.img.onload = function() { this.obj.placeImage(); return false };
	this.div.appendChild(this.img);
	document.body.appendChild(this.div);
}

function blank(link) {
	link.target='_blank';
}

function imgSwap(p) {
	var src=p.src.replace('_m.', '_v.');
	document.getElementById('gal').src=src;
}
