<!--//

var preloaded = false;

var catNumber = 1;

var ImgNum = 0;
var lstr = window.location.href;
var epos = lstr.lastIndexOf("?");
var ImgNum = (epos != -1) ? lstr.substring(epos+1,lstr.length) : 0;
ImgNum = ImgNum - 0;

function beginSetup() {
	if (document.images) {
		document.slideshow.src = "images/photo_house_loading.gif";
		catNumber = NewImg[ImgNum][2];
		document.photoForm['category'].selectedIndex = NewImg[ImgNum][2];
		setupThumbnails();
		document.caption.src = NewImg[ImgNum][1];
		showIndicator();
		document.slideshow.src = NewImg[ImgNum][0];
	}
}

function showIndicator() {
	if (document.images) {
		if (NewImg[ImgNum][3] == 1) {
			document.indicator1.src = "images/prev_bug.gif";
		} else {
			document.indicator1.src = "images/pixel.gif";
		}
		if (NewImg[ImgNum][3] == 2) {
			document.indicator2.src = "images/prev_bug.gif";
		} else {
			document.indicator2.src = "images/pixel.gif";
		}
		if (NewImg[ImgNum][3] == 3) {
			document.indicator3.src = "images/prev_bug.gif";
		} else {
			document.indicator3.src = "images/pixel.gif";
		}
		if (NewImg[ImgNum][3] == 4) {
			document.indicator4.src = "images/prev_bug.gif";
		} else {
			document.indicator4.src = "images/pixel.gif";
		}
		if (NewImg[ImgNum][3] == 5) {
			document.indicator5.src = "images/prev_bug.gif";
		} else {
			document.indicator5.src = "images/pixel.gif";
		}
		if (NewImg[ImgNum][3] == 6) {
			document.indicator6.src = "images/prev_bug.gif";
		} else {
			document.indicator6.src = "images/pixel.gif";
		}
	}
}

NewImg = new Array();
//			[0=main image, 1=caption, 2=category, 3=indicator position]

//MAIN HOUSE
NewImg[0] = ["images/photo_house_front1.jpg", "images/caption_front1.gif", 1, 1];
NewImg[1] = ["images/photo_house_frontdoor.jpg", "images/caption_frontdoor.gif", 1, 2];
NewImg[2] = ["images/photo_house_hall1.jpg", "images/caption_hall1.gif", 1, 3];
NewImg[3] = ["images/photo_house_dine1a.jpg", "images/caption_dine1.gif", 1, 4]; //
NewImg[4] = ["images/photo_house_dine2.jpg", "images/caption_dine2.gif", 1, 5];
NewImg[5] = ["images/photo_house_live1a.jpg", "images/caption_live1.gif", 1, 6]; //

//COURTYARD
NewImg[6] = ["images/photo_house_ctyd1.jpg", "images/caption_ctyd1.gif", 2, 1];
NewImg[7] = ["images/photo_house_ctyd2.jpg", "images/caption_ctyd2.gif", 2, 2];
NewImg[8] = ["images/photo_house_ctyd3.jpg", "images/caption_ctyd3.gif", 2, 3];
NewImg[9] = ["images/photo_house_ctyd4.jpg", "images/caption_ctyd4.gif", 2, 4];

//GUEST ROOMS: GREEN ROOM
NewImg[10] = ["images/photo_house_green1.jpg", "images/caption_green1.gif", 3, 1];
NewImg[11] = ["images/photo_house_green3.jpg", "images/caption_green3.gif", 3, 2];
NewImg[12] = ["images/photo_house_green4.jpg", "images/caption_green4.gif", 3, 3];

//GUEST ROOMS: RED ROOM
NewImg[13] = ["images/photo_house_red1.jpg", "images/caption_red1.gif", 4, 1];
NewImg[14] = ["images/photo_house_red2.jpg", "images/caption_red2.gif", 4, 2];
NewImg[15] = ["images/photo_house_red3.jpg", "images/caption_red3.gif", 4, 3];

//GUEST ROOMS: BALCONY ROOM
NewImg[16] = ["images/photo_house_balc1.jpg", "images/caption_balc1.gif", 5, 1];
NewImg[17] = ["images/photo_house_balc2.jpg", "images/caption_balc2.gif", 5, 2];
NewImg[18] = ["images/photo_house_balc3.jpg", "images/caption_balc3.gif", 5, 3];

//GUEST ROOMS: COURTYARD ROOM
NewImg[19] = ["images/photo_house_ctrm1.jpg", "images/caption_ctrm1.gif", 6, 1];
NewImg[20] = ["images/photo_house_ctrm2.jpg", "images/caption_ctrm2.gif", 6, 2];
NewImg[21] = ["images/photo_house_ctrm3.jpg", "images/caption_ctrm3.gif", 6, 3];
NewImg[22] = ["images/photo_house_ctrm4.jpg", "images/caption_ctrm4.gif", 6, 4];

//DETAILS
NewImg[23] = ["images/photo_house_det1.jpg", "images/caption_det1.gif", 7, 1];
NewImg[24] = ["images/photo_house_det3.jpg", "images/caption_det3.gif", 7, 2];
NewImg[25] = ["images/photo_house_det4.jpg", "images/caption_det4.gif", 7, 3];
NewImg[26] = ["images/photo_house_det6.jpg", "images/caption_det6.gif", 7, 4];
NewImg[27] = ["images/photo_house_det7.jpg", "images/caption_det7.gif", 7, 5];
NewImg[28] = ["images/photo_house_det8.jpg", "images/caption_det8.gif", 7, 6];

var ThumbImg = new Array();
ThumbImg[0] = [null];
//MAIN HOUSE
ThumbImg[1] = ["images/photo_thumb_house_front1.jpg", "images/photo_thumb_house_frontdoor.jpg", "images/photo_thumb_house_hall1.jpg", "images/photo_thumb_house_dine1.jpg", "images/photo_thumb_house_dine2.jpg", "images/photo_thumb_house_live1.jpg"];
//COURTYARD
ThumbImg[2] = ["images/photo_thumb_house_ctyd1.jpg", "images/photo_thumb_house_ctyd2.jpg", "images/photo_thumb_house_ctyd3.jpg", "images/photo_thumb_house_ctyd4.jpg", "images/pixel.gif", "images/pixel.gif"];
//GREEN ROOM
ThumbImg[3] = ["images/photo_thumb_green1.jpg", "images/photo_thumb_green3.jpg", "images/photo_thumb_green4.jpg", "images/pixel.gif", "images/pixel.gif", "images/pixel.gif"];
//RED ROOM
ThumbImg[4] = ["images/photo_thumb_red1.jpg", "images/photo_thumb_red2.jpg", "images/photo_thumb_red3.jpg", "images/pixel.gif", "images/pixel.gif", "images/pixel.gif"];
//BALCONY ROOM
ThumbImg[5] = ["images/photo_thumb_balc1.jpg", "images/photo_thumb_balc2.jpg", "images/photo_thumb_balc3.jpg", "images/pixel.gif", "images/pixel.gif", "images/pixel.gif"];
//COURTYARD ROOM
ThumbImg[6] = ["images/photo_thumb_ctyd1.jpg", "images/photo_thumb_ctyd2.jpg", "images/photo_thumb_ctyd3.jpg", "images/photo_thumb_ctyd4.jpg", "images/pixel.gif", "images/pixel.gif"];
//DETAILS
ThumbImg[7] = ["images/photo_thumb_house_det1.jpg", "images/photo_thumb_house_det3.jpg", "images/photo_thumb_house_det4.jpg", "images/photo_thumb_house_det6.jpg", "images/photo_thumb_house_det7.jpg", "images/photo_thumb_house_det8.jpg"];

var CatImg = new Array();
CatImg[0] = [null];
CatImg[1] = [null, 0, 1, 2, 3, 4, 5];
CatImg[2] = [null, 6, 7, 8, 9, null, null];
CatImg[3] = [null, 10, 11, 12, null, null, null];
CatImg[4] = [null, 13, 14, 15, null, null, null];
CatImg[5] = [null, 16, 17, 18, null, null, null];
CatImg[6] = [null, 19, 20, 21, 22, null, null];
CatImg[7] = [null, 23, 24, 25, 26, 27, 28];

var ImgLength = NewImg.length - 1;

//Time delay between Slides in milliseconds
var delay = 3000;

var lock = false;
var run;

function chgImg(direction) {
	if (document.images) {
		ImgNum = ImgNum + direction;
		if (ImgNum > ImgLength) {
			ImgNum = 0;
		}
		if (ImgNum < 0) {
			ImgNum = ImgLength;
		}
		beginSetup();
	}
}

function jumpImg(jumpNum) {
	if (document.images) {
		if (CatImg[catNumber][jumpNum] != null) {
			ImgNum = CatImg[catNumber][jumpNum];
			beginSetup();
		} 
	}
}

function auto() {
	if (preloaded) {
		if (lock == true) {
			lock = false;
			document.auto.src = "images/autostart.gif";
			window.clearInterval(run);
		} else if (lock == false) {
			lock = true;
			document.auto.src = "images/autostop.gif";
			run = setInterval("chgImg(1)", delay);
		}
	} else {
		document.slideshow.src = "images/photo_house_loading.gif";
		preloadImgs();
	}
}

function setupThumbnails() {
	document.thumbnail1.src = ThumbImg[catNumber][0];
	document.thumbnail2.src = ThumbImg[catNumber][1];
	document.thumbnail3.src = ThumbImg[catNumber][2];
	document.thumbnail4.src = ThumbImg[catNumber][3];
	document.thumbnail5.src = ThumbImg[catNumber][4];
	document.thumbnail6.src = ThumbImg[catNumber][5];
}

function selectMenu(catNum, formName) {
	if (catNum == 0) {
		formName['category'].selectedIndex = 0;
		catNumber = 0;
		ImgNum = 0;
	} else {
		formName['category'].selectedIndex = catNum;
		catNumber = catNum;
		if (catNum == 1) {
			ImgNum = 0;
		}
		if (catNum == 2) {
			ImgNum = 6;
		}
		if (catNum == 3) {
			ImgNum = 10;
		}
		if (catNum == 4) {
			ImgNum = 13;
		}
		if (catNum == 5) {
			ImgNum = 16;
		}
		if (catNum == 6) {
			ImgNum = 19;
		}
		if (catNum == 7) {
			ImgNum = 23;
		}
	}
	beginSetup();
}

function preloadImgs() {
	if (document.images) {
		pImg1 = new Image();
		pImg1.src = "images/photo_house_front1.jpg";
		pImg2 = new Image();
		pImg2.src = "images/photo_house_frontdoor.jpg";
		pImg3 = new Image();
		pImg3.src = "images/photo_house_hall1.jpg";
		pImg4 = new Image();
		pImg4.src = "images/photo_house_dine1a.jpg";
		pImg5 = new Image();
		pImg5.src = "images/photo_house_dine2.jpg";
		pImg6 = new Image();
		pImg6.src = "images/photo_house_live1a.jpg";
		pImg7 = new Image();
		pImg7.src = "images/photo_house_ctyd1.jpg";
		pImg8 = new Image();
		pImg8.src = "images/photo_house_ctyd2.jpg";
		pImg9 = new Image();
		pImg9.src = "images/photo_house_ctyd3.jpg";
		pImg10 = new Image();
		pImg10.src = "images/photo_house_ctyd4.jpg";
		pImg11 = new Image();
		pImg11.src = "images/photo_house_green1.jpg";
		pImg12 = new Image();
		pImg12.src = "images/photo_house_green3.jpg";
		pImg13 = new Image();
		pImg13.src = "images/photo_house_green4.jpg";
		pImg14 = new Image();
		pImg14.src = "images/photo_house_red1.jpg";
		pImg15 = new Image();
		pImg15.src = "images/photo_house_red2.jpg";
		pImg16 = new Image();
		pImg16.src = "images/photo_house_red3.jpg";
		pImg17 = new Image();
		pImg17.src = "images/photo_house_balc1.jpg";
		pImg18 = new Image();
		pImg18.src = "images/photo_house_balc2.jpg";
		pImg19 = new Image();
		pImg19.src = "images/photo_house_balc3.jpg";
		pImg20 = new Image();
		pImg20.src = "images/photo_house_ctrm1.jpg";
		pImg21 = new Image();
		pImg21.src = "images/photo_house_ctrm2.jpg";
		pImg22 = new Image();
		pImg22.src = "images/photo_house_ctrm3.jpg";
		pImg23 = new Image();
		pImg23.src = "images/photo_house_ctrm4.jpg";
		pImg24 = new Image();
		pImg24.src = "images/photo_house_det1.jpg";
		pImg25 = new Image();
		pImg25.src = "images/photo_house_det3.jpg";
		pImg26 = new Image();
		pImg26.src = "images/photo_house_det4.jpg";
		pImg27 = new Image();
		pImg27.src = "images/photo_house_det6.jpg";
		pImg28 = new Image();
		pImg28.src = "images/photo_house_det7.jpg";
		pImg29 = new Image();
		pImg29.src = "images/photo_house_det8.jpg";
		preloaded = true;
		auto();
	}
}
//-->
