var currVisProj = null;
var tempImage = null;
var theInterval = null;
var prevThumbId = null;

// controls pop-up/preview window of project
function showProject(whichProject) {
	if (currVisProj) {
		currVisProj.style.display = 'none';
	}
	var projDiv = document.getElementById('featuredProj_'+whichProject);
	projDiv.style.display = 'block';
	currVisProj = projDiv;
}

function closeFeature(whichProject) {
	var projDiv = document.getElementById('featuredProj_'+whichProject);
	projDiv.style.display = 'none';
}



// called from project detail page -- loads an image into the main photo area
function showPhoto(whichThumbnail,imgWidth,imgHeight,thumbnailId) {
	//var mainPhoto = document.getElementById('mainImg');
	if (!prevThumbId) {
		prevThumbId = 1;
	}
	var makeOpaque = document.getElementById('thumb'+prevThumbId);
	var makeTrans = document.getElementById('thumb'+thumbnailId);
	makeOpaque.style.opacity = 1;
	makeTrans.style.opacity = .3;
	prevThumbId = thumbnailId;
	currFeatureImg = whichThumbnail;
	loadBigImage(imgWidth,imgHeight);
	return;

}

// function that loads the requested image into the user's cache
// [ this function is called by the function showImg() ]
function loadBigImage(imgWidth,imgHeight) {

	//alert("loading "+whichImage);
	tempImage = null;
	if (theInterval) {
		clearInterval(theInterval);
	}
	if (document.images) {
		var photoHolder = document.getElementById('mainProjPhoto');
		photoHolder.innerHTML = '<p class="loaderP" style="width:'+imgWidth+'px; height:'+imgHeight+'px; line-height:'+imgHeight+'px; margin-bottom:12px;">Loading...</p>';
		tempImage = new Image();
		tempImage.src = 'images/'+currFeatureImg+'Lg.jpg';
		theInterval = setInterval("showBigImage()", 100);
	}
	return;
}

// function that checks to see whether the selected image has downloaded to the user's cache
// if the current image has downloaded to the user's cache, we load that image into the browser window
// [ this function is called by the function loadBigImage() ]
function showBigImage() {
	if (tempImage.complete) {
		clearInterval(theInterval);
		var photoHolder = document.getElementById('mainProjPhoto');
		photoHolder.innerHTML = '<img src="images/'+currFeatureImg+'Lg.jpg" />';
		tempImage = null;
	} else {
		return false;
	}
}
