function ExpandedViewCycle(increment)
{
var iCurrTempSelection = iCurrThumbId + increment;
if(iCurrTempSelection <0)
	iCurrTempSelection = eval("a" + aMainSections[iCurrSectionId] + "GallerySections["+iCurrSubSectionId+"].length" )-1;
if(iCurrTempSelection> eval("a" + aMainSections[iCurrSectionId] + "GallerySections["+iCurrSubSectionId+"].length" )-1)
	iCurrTempSelection = 0;
//alert(iCurrSectionId + " total thumbs: " + eval("a" + aMainSections[iCurrSectionId] + "GallerySections["+iCurrSubSectionId+"].length" ));
ShowExpandedGallery(iCurrSectionId,iCurrSubSectionId,iCurrTempSelection );

}
function openViewer(divId)
{
	objDiv = document.getElementById(divId);
	viewportTop = getViewportScrollY();
	viewportBottom = getViewportHeight() + getViewportScrollY();
	viewPortMiddle = (viewportBottom + viewportTop) / 2;
	objDivHeight = objDiv.offsetHeight;
	objDivWidth = objDiv.offsetWidth;
	
	if(objDiv.style.visibility != 'visible')
	{
		objDiv.style.visibility = 'visible';
		objDiv.style.top = (viewPortMiddle - (objDivHeight / 2)) + 'px';
		objDiv.style.left = ((getViewportWidth() / 2) - (objDivWidth / 2)) + 'px';
	}
}

function centerViewer(divId)
{
	objDiv = document.getElementById(divId);
	viewportTop = getViewportScrollY();
	viewportBottom = getViewportHeight() + getViewportScrollY();
	viewPortMiddle = (viewportBottom + viewportTop) / 2;
	objDivHeight = objDiv.offsetHeight;
	objDivWidth = objDiv.offsetWidth;
	objDiv.style.top = (viewPortMiddle - (objDivHeight / 2)) + 'px';
	objDiv.style.left = ((getViewportWidth() / 2) - (objDivWidth / 2)) + 'px';
}

function showDiv(divId)
{
	objDiv = document.getElementById(divId);
	objDiv.style.visibility = 'visible';
}

function hideDiv(divId)
{
	objDiv = document.getElementById(divId);
	objDiv.style.visibility = 'hidden';
}

window.onload = function()
{
	MM_preloadImages('/SFXPictures/sfxGallery/viewer/closeOn.gif','/SFXPictures/sfxGallery/viewer/arrowLeftOn.gif','/SFXPictures/sfxGallery/viewer/arrowRightOn.gif','/SFXPictures/sfxGallery/viewer/questionsOn.gif','/SFXPictures/sfxGallery/viewer/viewer.png');
}
window.onresize = function()
{
	centerViewer('divDraggableViewer');	
}

function enforceBoundaries(divId)
{
	objDiv = document.getElementById(divId);
	objDivHeight = objDiv.offsetHeight;
	browserBottom = getViewportHeight() + getViewportScrollY();
	
	if(parseInt(objDiv.style.top) < getViewportScrollY())
	{
		objDiv.style.top = getViewportScrollY() + 'px';
	}
	else if((parseInt(objDiv.style.top) + objDivHeight) > browserBottom)
	{
		objDiv.style.top = (browserBottom - objDivHeight) + 'px';
	}
}

getViewportHeight = function() {
	var height = 0;
	if( document.documentElement && document.documentElement.clientHeight ) {
		height = document.documentElement.clientHeight;
	}
	else if( document.body && document.body.clientHeight ) {
		height = document.body.clientHeight;
	}
	else if( window.innerHeight ) {
		height = window.innerHeight;
	}
	return height;
}

getViewportWidth = function() {
	var width = 0;
	if( document.documentElement && document.documentElement.clientWidth ) {
		width = document.documentElement.clientWidth;
	}
	else if( document.body && document.body.clientWidth ) {
		width = document.body.clientWidth;
	}
	else if( window.innerWidth ) {
		width = window.innerWidth;
	}
	return width;
}

getViewportScrollY = function() {
	var scrollY = 0;
	if( document.documentElement && document.documentElement.scrollTop ) {
		scrollY = document.documentElement.scrollTop;
	}
	else if( document.body && document.body.scrollTop ) {
		scrollY = document.body.scrollTop;
	}
	else if( window.pageYOffset ) {
		scrollY = window.pageYOffset;
	}
	else if( window.scrollY ) {
		scrollY = window.scrollY;
	}
	return scrollY;
}

getViewportScrollX = function() {
	var scrollX = 0;
	if( document.documentElement && document.documentElement.scrollLeft ) {
		scrollX = document.documentElement.scrollLeft;
	}
	else if( document.body && document.body.scrollLeft ) {
		scrollX = document.body.scrollLeft;
	}
	else if( window.pageXOffset ) {
		scrollX = window.pageXOffset;
	}
	else if( window.scrollX ) {
		scrollX = window.scrollX;
	}
	return scrollX;
}