//globals
var ie = (document.all) ? true : false;

var ns = (document.layers) ? true : false;

var dom = (!document.all && document.getElementById) ? true : false;

//set the toggle switch for the portfolio section
var toggleSwitch = 2;



//nav

preload('nFirm_on','images/nav/firm_on.gif');
preload('nFirm_off','images/nav/firm_off.gif');
preload('nPortfolio_on','images/nav/portfolio_on.gif');
preload('nPortfolio_off','images/nav/portfolio_off.gif');
preload('nRecognition_on','images/nav/recognition_on.gif');
preload('nRecognition_off','images/nav/recognition_off.gif');
preload('nLinks_on','images/nav/links_on.gif');
preload('nLinks_off','images/nav/links_off.gif');

function preload(imgObj,imgSrc) {

	if (document.images) {

		eval(imgObj+' = new Image()')

		eval(imgObj+'.src = "'+imgSrc+'"')

	}

}

function chgImg(imgField,newImg) {

	if (ns) {eval('document.images[imgField].src = '+newImg+'.src')}

	if (ie) {document[imgField].src = eval(newImg+'.src')}

	if (dom) {document.images[imgField].src = eval(newImg+'.src');}

}

//toggle detail functionality for portfolio section
function toggleDetails() {
	switch (toggleSwitch) {
	case 1:
		document.getElementById('pDetailToggleIndicator').innerHTML = "+";
		document.getElementById('pDetails').style.display = "none";
		toggleSwitch = 2;
		return(false);
	case 2:
		document.getElementById('pDetailToggleIndicator').innerHTML = "-";
		document.getElementById('pDetails').style.display = "block";
		toggleSwitch = 1;
		return(false);
	}				
}

//toggle thumbnail opacity functionality for portfolio section
function toggleThumbnail(obj,thumbID) {
	x=document.getElementById(obj);
	x.className = 'pThumbSelected';
	//cycle through others to de-select
	for (y=1;y<=6;y++) {
		if (y != thumbID) {
			var z = document.getElementById("thumb"+y);
			if (z != null) {
				z.className = 'pThumb';
			}
		}
	}
	hideCaption();
}

function showCaption(captionID) {
	x=document.getElementById("caption");

	if (captionID == "olive6") {
		x.innerHTML = "Before remodel";	
	}
	if (captionID == "caroline1") {
		x.innerHTML = "House circa 1915";	
	}
	
	x.style.display = "block";
}

function hideCaption() {
	x=document.getElementById("caption");
	if (x != null) {
		x.style.display = "none";
	}
}

// css menus: http://www.alistapart.com/articles/dropdowns

startList = function() {

	if (document.all&&document.getElementById) {

		navRoot = document.getElementById("nFirmMenu");

		for (i=0; i<navRoot.childNodes.length; i++) {

			node = navRoot.childNodes[i];

			if (node.nodeName=="LI") {

				node.onmouseover=function() {

					this.className+=" over";

				}

				node.onmouseout=function() {

					this.className=this.className.replace(" over", "");

				}

			}

		}



		navRoot = document.getElementById("nPortfolioMenu");

		for (i=0; i<navRoot.childNodes.length; i++) {

			node = navRoot.childNodes[i];

			if (node.nodeName=="LI") {

				node.onmouseover=function() {

					this.className+=" over";

				}

				node.onmouseout=function() {

					this.className=this.className.replace(" over", "");

				}

			}

		}



		navRoot = document.getElementById("nRecognitionMenu");

		for (i=0; i<navRoot.childNodes.length; i++) {

			node = navRoot.childNodes[i];

			if (node.nodeName=="LI") {

				node.onmouseover=function() {

					this.className+=" over";

				}

				node.onmouseout=function() {

					this.className=this.className.replace(" over", "");

				}

			}

		}



		navRoot = document.getElementById("nLinksMenu");

		for (i=0; i<navRoot.childNodes.length; i++) {

			node = navRoot.childNodes[i];

			if (node.nodeName=="LI") {

				node.onmouseover=function() {

					this.className+=" over";

				}

				node.onmouseout=function() {

					this.className=this.className.replace(" over", "");

				}

			}

		}




	}

}

window.onload=startList;

