var img1 = new Image();
img1.onload = countPic;
img1.src = "images/gallery/gall1.jpg";
var img2 = new Image();
img2.onload = countPic;
img2.src = "images/gallery/gall2.jpg";
var img3 = new Image();
img3.onload = countPic;
img3.src = "images/gallery/gall3.jpg";
var img4 = new Image();
img4.onload = countPic;
img4.src = "images/gallery/gall4.jpg";
var img5 = new Image();
img5.onload = countPic;
img5.src = "images/gallery/gall5.jpg";
var img6 = new Image();
img6.onload = countPic;
img6.src = "images/gallery/gall6.jpg";
var img7 = new Image();
img7.onload = countPic;
img7.src = "images/gallery/gall7.jpg";
var img8 = new Image();
img8.onload = countPic;
img8.src = "images/gallery/gall8.jpg";
var img9 = new Image();
img9.onload = countPic;
img9.src = "images/gallery/gall9.jpg";
var img10 = new Image();
img10.onload = countPic;
img10.src = "images/gallery/gall10.jpg";
var img11 = new Image();
img11.onload = countPic;
img11.src = "images/gallery/gall11.jpg";
var img12 = new Image();
img12.onload = countPic;
img12.src = "images/gallery/gall12.jpg";
var img13 = new Image();
img13.onload = countPic;
img13.src = "images/gallery/gall13.jpg";
var img14 = new Image();
img14.onload = countPic;
img14.src = "images/gallery/gall14.jpg";
var img15 = new Image();
img15.onload = countPic;
img15.src = "images/gallery/gall15.jpg";
var img16 = new Image();
img16.onload = countPic;
img16.src = "images/gallery/gall16.jpg";
var img17 = new Image();
img17.onload = countPic;
img17.src = "images/gallery/gall17.jpg";
var img18 = new Image();
img18.onload = countPic;
img18.src = "images/gallery/gall18.jpg";
var img19 = new Image();
img19.onload = countPic;
img19.src = "images/gallery/gall19.jpg";
var img20 = new Image();
img20.onload = countPic;
img20.src = "images/gallery/gall20.jpg";

var ns = (navigator.appName.indexOf("Netscape") != -1);
var nCount = 0;
var nAll = 20;
var alpMain = 0;
var objMain;
var objDivPic;
var objPicMain;
var bLocked = false;
var beginX = 0;
var beginY = 0;
var stWidth = 0;
var stHeight = 0;
var stLeft = 0;
var stTop = 0;
var destLeft = 0;
var destTop = 0;
var durX = 0;
var durY = 0;
var nPic = 0;
var bReady = false;
var picNow;
function setAlpha(obj,per) {
	if (!bReady) return;
	inone = per / 100;
	if (inone >= 1) inone = 0.99;
	obj.style.opacity = inone;
	obj.style.MozOpacity = inone;
	obj.style.KhtmlOpacity = per / 100;
	obj.style.filter = "alpha(opacity=" + per + ")";
}
function fillAll(evt,n) {
	if (bLocked) return;
	obj = document.getElementById("divFilter");
	nPic = n;
	setAlpha(obj,1);
	obj.style.left = obj.style.top = 0;
	obj.style.height = document.body.clientHeight + 525;
	obj.style.width = document.body.clientWidth;
	objMain = obj;
	bLocked = true;
	beginX = mouseX(evt);
	beginY = mouseY(evt);
	alphaBegin();
}
function alphaBegin() {
	alpMain = 0;
	setTimeout("alphaGo()",50);
}
function alphaGo() {
	alpMain += 10;
	if (alpMain > 70) {
		bLocked = false;
		spBegin();
		return;
	}
	setAlpha(objMain,alpMain);
	setTimeout("alphaGo()",50);
}
function spBegin() {
	objPicMain = document.getElementById("picMain");
	objDivPic = document.getElementById("divPic");
	objPicMain.src = eval("img" + nPic).src;
	objPicMain.width = 5;
	objPicMain.height = 5;
	objDivPic.style.left = beginX;
	objDivPic.style.top = beginY;
	stLeft = stTop = stWidth = stHeight = 0;
	picNow = eval("img" + nPic);
	destLeft = document.body.clientWidth / 2 - 600 / 2;
	//destTop = document.body.clientHeight / 2 - picNow.height / 2;
	destTop = ns ? pageYOffset + 10 : document.body.scrollTop + 10;
	stLeft = beginX;
	stTop = beginY;
	if (beginX < destLeft) durX = 1;
	else if (beginX > destLeft) durX = 2;
	else durX = 0;
	if (beginY < destTop) durY = 1;
	else if (beginY > destTop) durY = 2;
	else durY = 0;
	spGo();
}
function spGo() {
	stWidth += 50;
	stHeight += 50;
	if (durX == 1) {
		stLeft += 50;
		if (stLeft >= destLeft) {
			stLeft = destLeft;
			durX = 0;
		}
	}
	else if (durX == 2) {
		stLeft -= 50;
		if (stLeft <= destLeft) {
			stLeft = destLeft;
			durX = 0;
		}
	}
	if (durY == 1) {
		stTop += 50;
		if (stTop >= destTop) {
			stTop = destTop;
			durY = 0;
		}
	}
	else if (durY == 2) {
		stTop -= 50;
		if (stTop <= destTop) {
			stTop = destTop;
			durY = 0;
		}
	}
	if (stWidth > picNow.width) stWidth = picNow.width;
	if (stHeight > picNow.height) stHeight = picNow.height;
	objPicMain.width = stWidth;
	objPicMain.height = stHeight;
	objDivPic.style.left = stLeft;
	objDivPic.style.top = stTop;
	if (stWidth == picNow.width && stHeight == picNow.height && durX == 0 && durY == 0) return;
	setTimeout("spGo()",50);
}
function closePic() {
	objDivPic.style.left = -5000;
	obj = document.getElementById("divFilter");
	obj.style.width = 5;
	obj.style.height = 5;
	obj.style.left = -1000;
}
function mouseX(evt) {
	if (evt.pageX) return evt.pageX;
	else if (evt.clientX)
		return evt.clientX + (document.documentElement.scrollLeft ?
		document.documentElement.scrollLeft :
		document.body.scrollLeft);
	else return null;
}
function mouseY(evt) {
if (evt.pageY) return evt.pageY;
	else if (evt.clientY)
		return evt.clientY + (document.documentElement.scrollTop ?
		document.documentElement.scrollTop :
		document.body.scrollTop);
	else return null;
}
function slideBack() {
	nPic--;
	if (nPic < 0) nPic = nAll;
	picNow = eval("img" + nPic);
	objPicMain.src = eval("img" + nPic).src;
	destLeft = document.body.clientWidth / 2 - 600 / 2;
	destTop = document.body.clientHeight / 2 - picNow.height / 2;
	objPicMain.width = picNow.width;
	objPicMain.height = picNow.height;
	objDivPic.style.left = destLeft;
	//objDivPic.style.top = destTop;
}
function slideNext() {
	nPic++;
	if (nPic > nAll) nPic = 1;
	picNow = eval("img" + nPic);
	objPicMain.src = eval("img" + nPic).src;
	destLeft = document.body.clientWidth / 2 - 600 / 2;
	destTop = document.body.clientHeight / 2 - picNow.height / 2;
	objPicMain.width = picNow.width;
	objPicMain.height = picNow.height;
	objDivPic.style.left = destLeft;
	//objDivPic.style.top = destTop;
}
function countPic() {
	nCount++;
	if (nCount >= nAll) {
		bReady = true;
	}
}
