function getBodyHeight() {
	if (self.innerWidth) return self.innerHeight;
	else if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientHeight;
	else if (document.body) return document.body.clientHeight;
}

function showPic(id) {
	if (currentId == id) return false;
	currentId = id;
	
	var el = document.getElementsByTagName('LI');
	for(var i = 0; i < el.length; i++) {
		if (el[i].getAttribute('picid') == id)
			el[i].className += ' current';
		else
			el[i].className = el[i].className.replace(/\s*current/, '');
	}
	
	$('picture').src = picPath + id + '.jpg';
	$('picture').onload = function() {
//			window.resizeBy($('picture').offsetWidth - getInnerWidth(), $('picture').offsetHeight - getInnerHeight());
	//		window.resizeTo($('picture').offsetWidth, $('picture').offsetHeight);
			$('picture').onload = new function() { return false; }
		}
	return false;
}

function showNext(curEl, direction) {
	if (direction == null) direction = 1;
	var cur;
	var el = document.getElementsByTagName('LI');
	for(var i = 0; i < el.length; i++) {
		if (el[i].getAttribute('picid') == currentId) {
			cur = i + direction;
			if (cur < 0) cur = el.length - 1;
			if (cur >= el.length) cur = 0;
			break;
		}
	}
	showPic(el[cur].getAttribute('picid'));
	cur += direction;
	if (cur < 0) cur = el.length - 1;
	if (cur >= el.length) cur = 0;
	$('thumbnail').src = thumbPath + el[cur].getAttribute('picid') + '.jpg';
}

function getInnerWidth() {
	if (self.innerWidth) {
		return self.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth) {
		return document.documentElement.clientWidth;
	} else if (document.body) {
		return document.body.clientWidth;
	}
}

function getInnerHeight() {
	if (self.innerHeight) {
		return self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		return document.documentElement.clientHeight;
	} else if (document.body) {
		return document.body.clientHeight;
	}
}

function TT(el, id) {
	nextF = el.className == 'next' || el.className == 'prev';
	if (currentId == id) return false;
	if (scTM) clearTimeout(scTM);
	var x = getRelLeft(el) - 75,
		y = getRelTop(el) + 25;
	if (nextF) y += 4;
	$('thumbnail').src = thumbPath + id + '.jpg';
	
	$('thumbwrapper').style.left = x + 'px';
	$('thumbwrapper').style.top = y + 'px';
	$('thumbwrapper').style.visibility = 'visible';
$('shadow').style.width = 95 + 40 + 'px'
	$('shadow').style.height = 95 + 40 + 'px'
	$('shmiddle').style.height = 95 - 20 + 'px'
	$('shadow').style.left = x - 10 + 'px';
	$('shadow').style.top = y - 10 + 'px';
	$('shadow').style.visibility = 'visible';
}

function TTnext(curEl, direction) {
	if (direction == null) direction = 1;
	var cur;
	var el = document.getElementsByTagName('LI');
	for(var i = 0; i < el.length; i++) {
		if (el[i].getAttribute('picid') == currentId) {
			cur = i + direction;
			if (cur < 0) cur = el.length - 1;
			if (cur >= el.length) cur = 0;
			break;
		}
	}
	TT(curEl, el[cur].getAttribute('picid'));
}

function hideTT() {
	scTM = setTimeout('hideTT2()', 50)
}

function hideTT2() {
//	cInactive(true);
	$('shadow').style.visibility = 'hidden';
	$('thumbwrapper').style.visibility = 'hidden';
}

function cInactive(state) {
	if (state) {
		$('nav').className = 'inactive';
	} else {
		$('nav').className = '';
	}
}

var scTM, curH = null;


 function op(x1,x2,x3,x4,x5){
 
 	//var width=1150;
 	//var height=700;
 	if (self.screen){
 		width = screen.width;
 		height = screen.height;}
 
 	var urll = "'"+x1+"'";
 	var name = "'"+x2+"'";
 	var par = "'"+x5+",width="+x3+",height="+x4+"'";
 	eval("tex=window.open("+urll+","+name+","+par+");");
 	tex.self.moveTo((width-x3)/2,(height-x4-25)/2);
 }
 
