var img1 = new Image();
img1.onload = countPic;
img1.src = "new/b1.jpg";
var img2 = new Image();
img2.onload = countPic;
img2.src = "new/b2.jpg";
var img3 = new Image();
img3.onload = countPic;
img3.src = "new/b3.jpg";
var img4 = new Image();
img4.onload = countPic;
img4.src = "new/b4.jpg";
var img5 = new Image();
img5.onload = countPic;
img5.src = "new/b5.jpg";
var img6 = new Image();
img6.onload = countPic;
img6.src = "new/b6.jpg";
var img7 = new Image();
img7.onload = countPic;
img7.src = "new/b7.jpg";
var img8 = new Image();
img8.onload = countPic;
img8.src = "new/b8.jpg";
var img9 = new Image();
img9.onload = countPic;
img9.src = "new/b9.jpg";
var img10 = new Image();
img10.onload = countPic;
img10.src = "new/b10.jpg";
var img11 = new Image();
img11.onload = countPic;
img11.src = "new/b11.jpg";
var img12 = new Image();
img12.onload = countPic;
img12.src = "new/b12.jpg";
var img13 = new Image();
img13.onload = countPic;
img13.src = "new/b13.jpg";
var img14 = new Image();
img14.onload = countPic;
img14.src = "new/b14.jpg";
var img15 = new Image();
img15.onload = countPic;
img15.src = "new/b15.jpg";
var img16 = new Image();
img16.onload = countPic;
img16.src = "new/b16.jpg";
var img17 = new Image();
img17.onload = countPic;
img17.src = "new/b17.jpg";
var img18 = new Image();
img18.onload = countPic;
img18.src = "new/b18.jpg";
var img19 = new Image();
img19.onload = countPic;
img19.src = "new/b19.jpg";
var img20 = new Image();
img20.onload = countPic;
img20.src = "new/b20.jpg";
var img21 = new Image();
img21.onload = countPic;
img21.src = "new/b21.jpg";
var img22 = new Image();
img22.onload = countPic;
img22.src = "new/b22.jpg";
var img23 = new Image();
img23.onload = countPic;
img23.src = "new/b23.jpg";
var img24 = new Image();
img24.onload = countPic;
img24.src = "new/b24.jpg";
var img25 = new Image();
img25.onload = countPic;
img25.src = "new/b25.jpg";
var img26 = new Image();
img26.onload = countPic;
img26.src = "new/b26.jpg";
var img27 = new Image();
img27.onload = countPic;
img27.src = "new/b27.jpg";
var img28 = new Image();
img28.onload = countPic;
img28.src = "new/b28.jpg";
var img29 = new Image();
img29.onload = countPic;
img29.src = "new/b29.jpg";
var img30 = new Image();
img30.onload = countPic;
img30.src = "new/b30.jpg";
var img31 = new Image();
img31.onload = countPic;
img31.src = "new/b31.jpg";
var img32 = new Image();
img32.onload = countPic;
img32.src = "new/b32.jpg";
var img33 = new Image();
img33.onload = countPic;
img33.src = "new/b33.jpg";
var img34 = new Image();
img34.onload = countPic;
img34.src = "new/b34.jpg";
var img35 = new Image();
img35.onload = countPic;
img35.src = "new/b35.jpg";
var img36 = new Image();
img36.onload = countPic;
img36.src = "new/b36.jpg";
var img37 = new Image();
img37.onload = countPic;
img37.src = "new/b37.jpg";
var img38 = new Image();
img38.onload = countPic;
img38.src = "new/b38.jpg";
var img39 = new Image();
img39.onload = countPic;
img39.src = "new/b39.jpg";
var img40 = new Image();
img40.onload = countPic;
img40.src = "new/jirungvilla-s.jpg";

var ns = (navigator.appName.indexOf("Netscape") != -1);
var nCount = 0;
var nAll = 40;
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 + 4500;
	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 - 800 / 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 - 800 / 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 - 800 / 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;
	}
}

