var wbe=d=dl=f=false,t=true,w=window,gI;

function ob(o) {return (typeof(o)=='object')?o:ge(o);}
function ge(s) {var x=document.getElementById(s);return (x)?x:f;}
function ce(x,cn,id,ih) {var e = document.createElement(x);if (cn) e.className=cn;if (id) e.id=id;if (ih) e.innerHTML=ih;return e;}
function cn(e,s) {if(s) ob(e).className=s; s=ob(e).className;return(s)?s:'';}
function min(x,y) {return (x<y)?x:y;}
function max(x,y) {return (x>y)?x:y;}
function wWid() {d=document;de=d.documentElement;return (typeof(w.innerWidth)=='number')?w.innerWidth:(de.clientWidth || de.clientHeight)?de.clientWidth:d.body.clientWidth;}
function sWE(mn,mx,mnp){var ww=wWid()-40; if (ww<=0 || !ge('we')) return max(mnp,ww)+'px'; var eW=Math.round(ge('we').offsetWidth/46);mnp=max(mnp,mn*eW);var mxp=max(mnp,mx*eW);if ( ww>mxp ) ge('wp').margin='0 auto';else ge('wp').margin='0';var z=(eW==0)?mnp:(ww>mxp)?mxp:(ww<mnp)?mnp:ww;return z+'px';}
function DOM() {if(document && document.body) {clearInterval(gI);d=document;d.body.className+=' js';wbe=ge('wb');tnlinks();}}gI=setInterval(DOM,20);// paf:path and file name: returns the path plus filename plus extension If it is passed an object, it assumes the window object.
function paf(x) {if(typeof(x)=='object') {if(x.location) x=x.location.pathname;else x=x.pathname;x=(x.substr(0,1)=='/')?x.substr(1):x;} var y=min(x.indexOf('?'),x.indexOf('&'));return (y>-1)?x.substr(0,y):x;}
//fnm:filename returns the file name (page name plus extension.  If it is passed an object, it assumes the window object.  If it finds no file name it assumes index.php
function fnm(x) {x=paf(x);return x.substring(x.lastIndexOf('/')+1);}

function tnexp(fn) {
	var x,e=ce('div');
	e.id="ios__imgexp";
	e.innerHTML='<div class="ios__imgbtn" onclick="tndel();">Hide Image</div><img src="'+fn+'"><div class="ios__imgbtn" onclick="tndel();">Hide Image</div>'
	wbe.appendChild(e);  // do not attempt to use the offsetheight of e here.  If image hasn't downloaded the height will be too small.
	x=max(0,Math.round((e.offsetWidth-806)/2));
	e.style.margin="0 "+x+"px";
	e.style.width=min(e.offsetWidth,806)+"px";
	wbe.style.height=Math.round(e.offsetWidth*3/4)+150+"px";// 150 px is an approximation as the 'buttons' are set in ems
	wbe.firstChild.style.visibility='hidden';
	return false;
}
function tndel() {
	var e=ge('ios__imgexp')
	e.parentNode.removeChild(e);
	wbe.style.height='auto';
	wbe.firstChild.style.visibility='visible';

}
function tnlinks() { //sets the links on thumbnails when js enabled
	var t=wbe.getElementsByTagName("img");
	for (var i=0;i < t.length;i++) {
		if (t[i].className=='tn') t[i].onclick=new Function ('return tnexp("i/ss/'+fnm(t[i].src)+'");');
	}
}