var tid;
var curopac;
var arrimgs;
var imgcounter=0;
var loadingh;

loading=1;
numimages=5;
imgnames='mainphoto';
loadingh='';

function FadeOut() {
	if (loading) return;
	curopac-=4;
	if (curopac < 4) document.getElementById('head2').style.display = 'none';
	document.getElementById('head2').style.filter = 'alpha(opacity='+curopac+')';
	if (curopac > 0) setTimeout("FadeOut()", 1);
	else LoadNextImage('head2');
}

function FadeIn() {
	if (loading) return;
	curopac+=4;
	if (curopac > 0) document.getElementById('head2').style.display = 'block';
	document.getElementById('head2').style.filter = 'alpha(opacity='+curopac+')';
	if (curopac < 100) setTimeout("FadeIn()", 1);
	else LoadNextImage('head1');
}

function LoadNextImage(imgid) {
	if (loadingh == imgid) return;
	loadingh = imgid;
	imgcounter++;
	if (imgcounter > numimages) imgcounter = 1;
	document.getElementById(imgid).src='slideshow/'+imgnames+imgcounter+'.jpg';
}


function popup(url, winname, width, height) {
	if (winname == "") winname = "popup";
	if (width == "") width = "400";
	if (height == "") height = "300";
	var top = (screen.height) / 2 - (height / 2);
	var left = (screen.width) / 2 - (width / 2);
	var win_arg = "scrollbars=yes,status=yes,resizable=yes,location=no,toolbar=no,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left;
	window.open(url,winname,win_arg);
}

function FloorsMouseMove(e) {
	div = document.getElementById('floortip');
	x = findPosX(e);
	y = findPosY(e);
	div.style.left = x+'px';
	div.style.top = y+'px';
}

function findPosX(e) {
	var posx = 0;
	if (!e) var e = window.event;
	if (e.pageX) 	posx = e.pageX;
	else if (e.clientX) posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
	return posx;
}

function findPosY(e) {
	var posx = 0;
	if (!e) var e = window.event;
	if (e.pageY) posy = e.pageY;
	else if (e.clientY) posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	return posy;
}

function SetTip(x, y,contentid) {
	div = document.getElementById('tip');
	div.innerHTML = document.getElementById(contentid).innerHTML;
	div.style.display='block';
	div.style.left = x+'px';
	div.style.top = y+'px';
}

function SetTipBig(x, y,contentid) {
	div = document.getElementById('tipbig');
	div.innerHTML = document.getElementById(contentid).innerHTML;
	div.style.display='block';
	div.style.left = x+'px';
	div.style.top = y+'px';
}

var bigphotow;
var bigphotoh;
var destleft;
var desttop;
var stepw, steph, stept, stepl;
var curtop, curleft, startleft, starttop;
bigphotow = 0;
startleft = 500;
starttop = 300;


function ShowLoader(l, t) {
	d = document.getElementById('loading');
	d.style.top =  (t-10)+ 'px';
	d.style.left =  (l-10)+ 'px';
	d.style.visibility = 'visible';
}



function ShowDim() {
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = document.documentElement.clientWidth;
			winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.documentElement.clientWidth;
			winH = document.documentElement.clientHeight;
		}
	}
	d = document.getElementById('dimmer');
	d.style.visibility = 'visible';
	d.style.width = winW + 'px';
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			if (window.innerHeight > document.height) docH = window.innerHeight;
			else docH = document.height;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			if (document.documentElement.clientHeight > document.body.offsetHeight) docH = document.documentElement.clientHeight;
			else docH = document.body.offsetHeight;
		}
	}
	d.style.height = docH + 'px';
}


function ShowPhoto(photoname, w, h) {
	ShowLoader(startleft, starttop);
	bigphotow = w;
	bigphotoh = h;
	document.getElementById('bigphoto').src = photoname;
}

function ShowBigPhoto() {
	if (bigphotow == 0) return ;
	document.getElementById('loading').style.visibility='hidden';
	document.getElementById('bigphoto').style.visibility='visible';
	document.getElementById('bigphoto').width=1;
	document.getElementById('bigphoto').height=1;
	ShowDim();
	CalcPos();
	curtop = starttop;
	curleft = startleft;
	stepw = parseInt(bigphotow/10);
	steph = parseInt(bigphotoh/10);
	stept = parseInt((desttop-starttop)/11);
	stepl = parseInt((destleft-startleft)/11);
	AnimateBigPhoto();
}


function FindPos(e) {
	startleft = findPosX(e);
	starttop = findPosY(e);
}

function AnimateBigPhoto() {
	obj = document.getElementById('bigphoto');
	if (obj.height < bigphotoh) obj.height = obj.height+steph;
	if (obj.width < bigphotow) obj.width = obj.width+stepw;
	if (obj.height > bigphotoh) obj.height = bigphotoh;
	if (obj.width > bigphotow) obj.width = bigphotow;
	curtop = curtop+stept;
	obj.style.top = curtop+'px';
	curleft = curleft+stepl;
	obj.style.left = curleft+'px';
	if ((obj.height < bigphotoh) || (obj.width < bigphotow)) setTimeout("AnimateBigPhoto()", 1);
	else {
		obj.style.top = desttop+'px';
		obj.style.left = destleft+'px';
	}
}


function CalcPos() {
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = document.documentElement.clientWidth;
			winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.documentElement.clientWidth;
			winH = document.documentElement.clientHeight;
		}
	}
	destleft = parseInt((winW-bigphotow)/2);
	if (window.scrollY) scr = window.scrollY;
	else if (document.documentElement.scrollTop) scr = document.documentElement.scrollTop;
	else scr = 0;
	desttop = parseInt((winH-bigphotoh)/2+scr);
}

function HideBigPhoto() {
	document.getElementById('dimmer').style.visibility='hidden';
	document.getElementById('bigphoto').style.visibility='hidden';
}


function findPosX(e) {
	var posx = 0;
	if (!e) var e = window.event;
	if (e.pageX) 	posx = e.pageX;
	else if (e.clientX) posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
	return posx;
}

function findPosY(e) {
	var posx = 0;
	if (!e) var e = window.event;
	if (e.pageY) posy = e.pageY;
	else if (e.clientY) posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	return posy;
}
