﻿var oldMenu = 0;
var oldpsSubID = 1;
var oldWhoID =0;
var oldfpMenuID = 0;
var oldmdMenuID = 0;
var oldfpSubID = 0;
var oldThumbID = 0;
var orgFpText = "To see a larger image, click on the picture"
var oldFpText = "";
var ownerPic = 0;
var oldGalPicID = 0;
var oldSoonPicID = 0;
var oldModelPicID = 0;
var oldMenuColor = "";

function makeCool2(menuItem) {
	if (menuItem.style.color != "#0000c8" && menuItem.style.color != "rgb(0, 0, 200)") {
		oldMenuColor = menuItem.style.color;
		menuItem.style.color = "#ab0104";
		menuItem.style.backgroundColor = "#ab0104";

	}
}

function makeNormal2(menuItem) {
	if (menuItem.style.color != "#0000c8" && menuItem.style.color != "rgb(0, 0, 200)") {
		menuItem.style.color = oldMenuColor;
		menuItem.style.backgroundColor = oldMenuColor;
	}
}
function makeCool(menuItem) {
	if (menuItem.style.color != "#00d5d5" && menuItem.style.color != "rgb(0, 213, 213)") {
		oldMenuColor = menuItem.style.color;
		menuItem.style.color = "#ab0104";
	}
}

function makeNormal(menuItem) {
	if (menuItem.style.color != "#00d5d5" && menuItem.style.color != "rgb(0, 213, 213)") {
		menuItem.style.color = oldMenuColor;
	}
}


function showPage(numMenu) {
	if (oldMenu == 1) {
		// Who We Are section was open - retore to default
		restoreWho();
	}
	if (oldMenu == 2) {
		// Products and Services section was open - restore to default settings
		restorePS();
	}
	if (oldMenu == 3) {
		// Floor plan section was open - restore to default settings
		restoreFP();
	}
	if (oldMenu == 4) {
		// Floor plan section was open - restore to default settings
		restoreMD();
	}
	if (oldMenu == 5) {
		// Gallery was open - restore to default settings
		restoreGallery();
	}
	if (oldMenu == 6) {
		// Coming Soon was open - restore to default settings
		restoreSoon();
	}
	if (numMenu == 9) {
		// clicked on home, so hide any active and show welcome
		if (oldMenu != 0) {
			document.getElementById("content" + oldMenu).style.display = "none";
			document.getElementById("content" + 0).style.display = "";
			document.getElementById("menu" + oldMenu).style.color = oldMenuColor;
			document.getElementById("menu" + oldMenu).style.backgroundColor = oldMenuColor;
			document.getElementById("menu" + oldMenu).style.fontWeight = "normal";
			oldMenu = 0;
		}
	}
	if (oldMenu == numMenu) {
		// selecting already open menu item, so close it and open welcome
		document.getElementById("content" + numMenu).style.display = "none";
		document.getElementById("content" + 0).style.display = "";
		document.getElementById("menu" + oldMenu).style.color = oldMenuColor;
		document.getElementById("menu" + oldMenu).style.backgroundColor = oldMenuColor;
		document.getElementById("menu" + numMenu).style.fontWeight = "normal";
		oldMenu = 0;
	}
	else {
		if (oldMenu == 0 && numMenu != 9) {
		// Welcome page is showing and all menus in native state.  Open selected and change menu bg
			oldMenu = numMenu;
			document.getElementById("content" + 0).style.display = "none";
			document.getElementById("content" + numMenu).style.display = "";
			document.getElementById("menu" + numMenu).style.color = "#0000c8";
			document.getElementById("menu" + oldMenu).style.backgroundColor = "#0000c8";
			document.getElementById("menu" + numMenu).style.fontWeight = "bold";
		}
		else {
		// some other page is open, so close it, restore old menu item to native state and change current menu item
			if(numMenu != 9) {
				document.getElementById("content" + oldMenu).style.display = "none";
				document.getElementById("menu" + oldMenu).style.color = oldMenuColor;
				document.getElementById("menu" + oldMenu).style.backgroundColor = oldMenuColor;
				document.getElementById("menu" + oldMenu).style.fontWeight = "normal";
				oldMenu = numMenu;
				document.getElementById("content" + numMenu).style.display = "";
				document.getElementById("menu" + numMenu).style.color = "#0000c8";
				document.getElementById("menu" + oldMenu).style.backgroundColor = "#0000c8";
				document.getElementById("menu" + numMenu).style.fontWeight = "bold";
			}
		}
	}
}

function showWho(whoID) {
	if (oldWhoID == 0) {
		// no other item open, so just close default and open current
		document.getElementById("whoWeAre" + oldWhoID).style.display = "none";
		document.getElementById("whoWeAre" + whoID).style.display = "";
		document.getElementById("whoMenu" + whoID).style.color = "#00d5d5";
		document.getElementById("whoMenu" + whoID).style.fontWeight = "bold";
		oldWhoID = whoID;
	}
	else {
		if (oldWhoID == whoID) {
			// clicked on open item, so just close it
			document.getElementById("whoWeAre" + whoID).style.display = "none";
			document.getElementById("whoWeAre" + 0).style.display = "";
			document.getElementById("whoMenu" + whoID).style.color = "#ffffff";
			document.getElementById("whoMenu" + whoID).style.fontWeight = "normal";
			oldWhoID = 0;
		}
		else {
			// some other item is open, so close it and open this item
			document.getElementById("whoWeAre" + oldWhoID).style.display = "none";
			document.getElementById("whoMenu" + oldWhoID).style.color = "#ffffff";
			document.getElementById("whoMenu" + oldWhoID).style.fontWeight = "normal";
			document.getElementById("whoWeAre" + whoID).style.display = "";
			document.getElementById("whoMenu" + whoID).style.color = "#00d5d5";
			document.getElementById("whoMenu" + whoID).style.fontWeight = "bold";
			oldWhoID = whoID;
		}
	}
}

function psShowSub(psSubID) {
	if (oldpsSubID == 0) {
		// no subID is opened, so just open current
		document.getElementById("sub" + psSubID).style.display = "";
		document.getElementById("subTitle" + psSubID).style.color = "#00d5d5";
		document.getElementById("subTitle" + psSubID).style.fontWeight = "bold";
		oldpsSubID = psSubID;
	}
	else {
		if (oldpsSubID == psSubID) {
			// clicked on open subID, so just close it
			document.getElementById("sub" + psSubID).style.display = "none";
			document.getElementById("subTitle" + psSubID).style.color = "#FFFFFF";
			document.getElementById("subTitle" + psSubID).style.fontWeight = "normal";
			oldpsSubID = 0;
		}
		else {
			// some subID is open, so close it and open clicked on subID
			document.getElementById("sub" + oldpsSubID).style.display = "none";
			document.getElementById("subTitle" + oldpsSubID).style.color = "#FFFFFF";
			document.getElementById("subTitle" + oldpsSubID).style.fontWeight = "normal";
			document.getElementById("sub" + psSubID).style.display = "";
			document.getElementById("subTitle" + psSubID).style.color = "#00d5d5";
			document.getElementById("subTitle" + psSubID).style.fontWeight = "bold";
			oldpsSubID = psSubID;
		}
	}
}

function mdShowSub(mdSubID) {
	if (oldmdMenuID == 0) {
		// no other menu item open, so just open current
		document.getElementById("mdSub" + mdSubID).style.display = "";
		document.getElementById("mdMenu" + mdSubID).style.color = "#00d5d5";
		document.getElementById("mdMenu" + mdSubID).style.fontWeight = "bold";
		oldmdMenuID = mdSubID;
	}
	else {
		if (oldmdMenuID == mdSubID) {
			// clicked on open subID, so just close it and restore menu font styles
			document.getElementById("mdSub" + mdSubID).style.display = "none";
			document.getElementById("mdMenu" + mdSubID).style.color = "#FFFFFF";
			document.getElementById("mdMenu" + mdSubID).style.fontWeight = "normal";
			document.getElementById("modelPic").style.backgroundImage = "url(images/floorplans/fall.jpg)";
			// subMenu items may have been clicked.  If so, bulk restore since we're going back to native state
			if (oldThumbID != 0) {
				document.getElementById("pic" + oldThumbID).style.color = "#ffffff";
				document.getElementById("pic" + oldThumbID).style.fontWeight = "normal";
				oldThumbID = 0;
				// restore picture cursor and text
				document.getElementById("mdText").innerHTML = oldFpText;
				document.getElementById("modelPic").style.cursor = "";
			}
			oldmdMenuID = 0;
		}
		else {
			// some other menu item open, close and restore old and open new
			// close and restore old
			document.getElementById("mdSub" + oldmdMenuID).style.display = "none";
			document.getElementById("mdMenu" + oldmdMenuID).style.color = "#FFFFFF";
			document.getElementById("mdMenu" + oldmdMenuID).style.fontWeight = "normal";
			document.getElementById("modelPic").style.backgroundImage = "url(images/floorplans/fall.jpg)";
			// subMenu items may have been clicked.  If so, bulk restore since we're going back to native state
			if (oldThumbID != 0) {
				document.getElementById("pic" + oldThumbID).style.color = "#ffffff";
				document.getElementById("pic" + oldThumbID).style.fontWeight = "normal";
				oldThumbID = 0;
				// restore picture cursor and text
				document.getElementById("mdText").innerHTML = oldFpText;
				document.getElementById("modelPic").style.cursor = "";
			}
			// open new menu item
			document.getElementById("mdSub" + mdSubID).style.display = "";
			document.getElementById("mdMenu" + mdSubID).style.color = "#00d5d5";
			document.getElementById("mdMenu" + mdSubID).style.fontWeight = "bold";
			oldmdMenuID = mdSubID;
		}
	}
}

function fpShowSub(fpSubID) {
	if (fpSubID == 4 || fpSubID == 6) {
		// opening picture of person's house
		document.getElementById("floorPlanPic").style.backgroundImage = "url(images/floorplans/owner" + fpSubID + ".jpg)";
		ownerPic = fpSubID;
	}
	else {
		// opening waves.jpg
		document.getElementById("floorPlanPic").style.backgroundImage = "url(images/waves.jpg)";
		ownerPic = 0;
	}
	if (oldfpMenuID == 0) {
		// no other menu item open, so just open current
		document.getElementById("fpSub" + fpSubID).style.display = "";
		document.getElementById("fpMenu" + fpSubID).style.color = "#00d5d5";
		document.getElementById("fpMenu" + fpSubID).style.fontWeight = "bold";
		oldfpMenuID = fpSubID;
	}
	else {
		if (oldfpMenuID == fpSubID) {
			// clicked on open subID, so just close it and restore menu font styles
			document.getElementById("fpSub" + fpSubID).style.display = "none";
			document.getElementById("fpMenu" + fpSubID).style.color = "#FFFFFF";
			document.getElementById("fpMenu" + fpSubID).style.fontWeight = "normal";
			document.getElementById("floorPlanPic").style.backgroundImage = "url(images/waves.jpg)";
			// subMenu items may have been clicked.  If so, bulk restore since we're going back to native state
			if (oldThumbID != 0) {
				document.getElementById("pic" + oldThumbID).style.color = "#ffffff";
				document.getElementById("pic" + oldThumbID).style.fontWeight = "normal";
				oldThumbID = 0;
				// restore picture cursor and text
				document.getElementById("fpText").innerHTML = oldFpText;
				document.getElementById("floorPlanPic").style.cursor = "";
			}
			oldfpMenuID = 0;
		}
		else {
			// some other menu item open, close and restore old and open new
			// close and restore old
			document.getElementById("fpSub" + oldfpMenuID).style.display = "none";
			document.getElementById("fpMenu" + oldfpMenuID).style.color = "#FFFFFF";
			document.getElementById("fpMenu" + oldfpMenuID).style.fontWeight = "normal";
			// subMenu items may have been clicked.  If so, bulk restore since we're going back to native state
			if (oldThumbID != 0) {
				document.getElementById("pic" + oldThumbID).style.color = "#ffffff";
				document.getElementById("pic" + oldThumbID).style.fontWeight = "normal";
				oldThumbID = 0;
				// restore picture cursor and text
				document.getElementById("fpText").innerHTML = oldFpText;
				document.getElementById("floorPlanPic").style.cursor = "";
			}
			// open new menu item
			document.getElementById("fpSub" + fpSubID).style.display = "";
			document.getElementById("fpMenu" + fpSubID).style.color = "#00d5d5";
			document.getElementById("fpMenu" + fpSubID).style.fontWeight = "bold";
			oldfpMenuID = fpSubID;
		}
	}
}

function showThumb(thumbID,sectionID,sectionTxt) {
	if (oldThumbID <= 6) {
		// no other thumb is open, so just open current
		document.getElementById(sectionID).style.backgroundImage = "url(images/floorplans/thumb" + thumbID + ".jpg)";
		document.getElementById(sectionID).style.cursor = "pointer";
		document.getElementById("pic" + thumbID).style.color = "#00d5d5";
		document.getElementById("pic" + thumbID).style.fontWeight = "bold";
		oldFpText = document.getElementById(sectionTxt).innerHTML;
		document.getElementById(sectionTxt).innerHTML = orgFpText;
		oldThumbID = thumbID;
		if (sectionID == "soonPic") {
			oldSoonPicID = thumbID;
		}
	}
	else {
		if (oldThumbID == thumbID) {
			// clicked on open thumb, so just close it
			if (ownerPic != 0) {
				// pic of owner house needs to open instead of waves
				document.getElementById(sectionID).style.backgroundImage = "url(images/floorplans/owner" + ownerPic + ".jpg)";
			}
			else {
				if (sectionID == "floorPlanPic") {
					document.getElementById(sectionID).style.backgroundImage = "url(images/waves.jpg)";
				}
				if (sectionID == "modelPic") {
					document.getElementById(sectionID).style.backgroundImage = "url(images/floorplans/fall.jpg)";
				}
				if (sectionID == "soonPic") {
					document.getElementById(sectionID).style.backgroundImage = "url(images/gallery/flower.jpg)";
					oldSoonPicID = 0;
				}
			}
			document.getElementById(sectionID).style.cursor = "";
			document.getElementById("pic" + thumbID).style.color = "#FFFFFF";
			document.getElementById("pic" + thumbID).style.fontWeight = "normal";
			document.getElementById(sectionTxt).innerHTML = oldFpText;
			oldThumbID = 0;
		}
		else {
			// some thumb is open, so close it and open this thumb
			document.getElementById("pic" + oldThumbID).style.color = "#FFFFFF";
			document.getElementById("pic" + oldThumbID).style.fontWeight = "normal";
			document.getElementById(sectionID).style.backgroundImage = "url(images/floorplans/thumb" + thumbID + ".jpg)";
			document.getElementById("pic" + thumbID).style.color = "#00d5d5";
			document.getElementById("pic" + thumbID).style.fontWeight = "bold";
			oldThumbID = thumbID;
			if (sectionID == "soonPic") {
				oldSoonPicID = thumbID;
			}
		}
	}
}

function trickShow(bigPic) {
		picWindow = window.open('','_blank','width=1024,height=697,directories=no,location=no,menubar=no,resizeable=no,scrollbars=no,status=no,toolbar=no');
		picWindow.document.open();
			picWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
			picWindow.document.write('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>' + bigPic + '</title></head>');
			picWindow.document.write('<body style=" width:100%; height: 100%; margin-top: 0px; margin-left: 0px; background-color: #000000"><img style="width:1024px; height:769px;" src="images/' + bigPic + '" />');
			picWindow.document.write('</body></html>');
		picWindow.document.close();
}

function showBigPic(picToShow) {
	if (oldThumbID != 0) {
		// if oldThumbID == 0 then no floorplan selected so don't run. Otherwise show big pic
		picWindow = window.open('','_blank','width=1024,height=697,directories=no,location=no,menubar=no,resizeable=no,scrollbars=no,status=no,toolbar=no');
		picWindow.document.open();
			picWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
			picWindow.document.write('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>pic' + oldThumbID + '.jpg</title></head>');
			picWindow.document.write('<body style="background-color: #264059"><div style="position:absolute; top:0px; left:0px; width:100%; height:100%; background-image:url(\'images/floorplans/pic' + oldThumbID + '.jpg\'); background-repeat:no-repeat">');
			picWindow.document.write('</div></body></html>');
		picWindow.document.close();
	}
}

function showGallery(galPicID) {
	if (oldGalPicID == 0) {
		// no pic is open, so just open current
		document.getElementById("galleryPic").style.backgroundImage = "url(images/gallery/pic0" + galPicID + ".jpg)";
		document.getElementById("galPic" + galPicID).style.color = "#00d5d5";
		document.getElementById("galPic" + galPicID).style.fontWeight = "bold";
		oldGalPicID = galPicID;
	}
	else {
		if (oldGalPicID == galPicID) {
			// clicked on open pic, so just close it
			document.getElementById("galleryPic").style.backgroundImage = "url(images/gallery/knotted_logs.jpg)";
			document.getElementById("galPic" + oldGalPicID).style.color = "#ffffff";
			document.getElementById("galPic" + oldGalPicID).style.fontWeight = "normal";
			oldGalPicID = 0;
		}
		else {
			// some pic is open, close it and restore its text and open new
			document.getElementById("galPic" + oldGalPicID).style.color = "#ffffff";
			document.getElementById("galPic" + oldGalPicID).style.fontWeight = "normal";
			document.getElementById("galleryPic").style.backgroundImage = "url(images/gallery/pic0" + galPicID + ".jpg)";
			document.getElementById("galPic" + galPicID).style.color = "#00d5d5";
			document.getElementById("galPic" + galPicID).style.fontWeight = "bold";
			oldGalPicID = galPicID;
		}
	}

}

function restoreWho() {
	if (oldWhoID != 0) {
		document.getElementById("whoWeAre" + oldWhoID).style.display = "none";
		document.getElementById("whoMenu" + oldWhoID).style.color = "#ffffff";
		document.getElementById("whoMenu" + oldWhoID).style.fontWeight = "normal";
		document.getElementById("whoWeAre" + 0).style.display = "";
		oldWhoID = 0;
	}
	return;
}
function restoreFP () {
	if (oldfpMenuID != 0) {
		document.getElementById("fpSub" + oldfpMenuID).style.display = "none";
		document.getElementById("fpMenu" + oldfpMenuID).style.color = "#FFFFFF";
		document.getElementById("fpMenu" + oldfpMenuID).style.fontWeight = "normal";
		// subMenu items may have been clicked.  If so, bulk restore since we're going back to native state
		if (oldThumbID != 0) {
			document.getElementById("pic" + oldThumbID).style.color = "#ffffff";
			document.getElementById("pic" + oldThumbID).style.fontWeight = "normal";
			oldThumbID = 0;
			// restore picture cursor and text
			document.getElementById("fpText").innerHTML = oldFpText;
			document.getElementById("floorPlanPic").style.cursor = "";
		}
		document.getElementById("floorPlanPic").style.backgroundImage = "url(images/waves.jpg)";
		oldfpMenuID = 0;
		ownerPic = 0;
	}
	return;
}
function restoreMD() {
	if (oldmdMenuID != 0) {
		document.getElementById("mdSub" + oldmdMenuID).style.display = "none";
		document.getElementById("mdMenu" + oldmdMenuID).style.color = "#FFFFFF";
		document.getElementById("mdMenu" + oldmdMenuID).style.fontWeight = "normal";
		// subMenu items may have been clicked.  If so, bulk restore since we're going back to native state
		if (oldThumbID != 0) {
			document.getElementById("pic" + oldThumbID).style.color = "#ffffff";
			document.getElementById("pic" + oldThumbID).style.fontWeight = "normal";
			oldThumbID = 0;
			// restore picture cursor and text
			document.getElementById("mdText").innerHTML = oldFpText;
			document.getElementById("modelPic").style.cursor = "";
		}
		document.getElementById("modelPic").style.backgroundImage = "url(images/floorplans/fall.jpg)";
		oldmdMenuID = 0;
	}
	return;
}

function restorePS() {
	if (oldpsSubID != 0) {
		document.getElementById("sub" + oldpsSubID).style.display = "none";
		document.getElementById("subTitle" + oldpsSubID).style.color = "#FFFFFF";
		document.getElementById("subTitle" + oldpsSubID).style.fontWeight = "normal";
	}
		document.getElementById("sub1").style.display = "";
		document.getElementById("subTitle1").style.color = "#00d5d5";
		document.getElementById("subTitle1").style.fontWeight = "bold";
		oldpsSubID = 1;
	return;
}

function restoreGallery() {
	if (oldGalPicID != 0) {
		document.getElementById("galPic" + oldGalPicID).style.color = "#ffffff";
		document.getElementById("galPic" + oldGalPicID).style.fontWeight = "normal";
		document.getElementById("galleryPic").style.backgroundImage = "url(images/gallery/knotted_logs.jpg)";
		oldGalPicID = 0;
	}
	return;
}

function restoreSoon() {
	if (oldSoonPicID != 0) {
			document.getElementById("soonPic").style.backgroundImage = "url(images/gallery/flower.jpg)";
			document.getElementById("soonPic").style.cursor = "";
			document.getElementById("pic" + oldSoonPicID).style.color = "#ffffff";
			document.getElementById("pic" + oldSoonPicID).style.fontWeight = "normal";
			document.getElementById("soonText").innerHTML = oldFpText;
			oldThumbID = 0;
	}
	return;
}