// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function preloadIt(image_array) {

   for(var count = 0; count < image_array.length; count++)
   {
 	var new_image = new Image();
	new_image.src = image_array[count];
   }
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------

// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
var lastGallery = "0";

function mapSwapIn( imgGallery ) {
	var imgId = "01";
	if ((imgGallery == "aip9a") || (imgGallery == "aip9b"))
		imgId = "aip9";
	else
		imgId = imgGallery;

	if ( document.images && ( preloadFlag == true ) )
	{
		document["AIP_MAP3_AIP_MAP3_"+imgId].src = "art/AIP_MAP3_AIP_MAP3_" + imgGallery + "_on.gif";
		showMainImage( imgGallery );
		lastGallery = imgGallery;
	}
}

function mapSwapOut( imgGallery ) {
	var imgId = "01";

	if ((imgGallery == "aip9a") || (imgGallery == "aip9b"))
		imgId = "aip9";
	else
		imgId = imgGallery;

	document["AIP_MAP3_AIP_MAP3_"+imgId].src = "art/AIP_MAP3_AIP_MAP3_" + imgGallery + ".gif";
	hideMainImage(lastGallery);
}

function mapSwapInSmall( imgGallery ) {
	var imgId = "aip1";
	var jId = "aip1";
	
//	if ((imgGallery == "aip9a") || (imgGallery == "aip9b"))
//		imgId = "aip9";
//	else
		imgId = imgGallery;

//	if ((jGallery == "aip9a") || (jGallery == "aip9b"))
//		jId = "aip9";
//	else
		jId = jGallery;

	if ( document.images && ( preloadFlag == true ) )
	{
		document["aip"+imgId].src = "art/aip_leftNav_map_" + imgGallery + "_on.gif";
		if ((imgId != jId) && (jId != ""))
			document["aip"+jId].src = "art/aip_leftNav_map_" + jGallery + "_off.gif";
		lastGallery = imgGallery;
	}
}

function mapSwapOutSmall( imgGallery ) {
	var imgId = "aip1";
	var jId = "aip1";
	
//	if ((imgGallery == "aip9a") || (imgGallery == "aip9b"))
//		imgId = "aip9";
//	else
		imgId = imgGallery;

//	if ((jGallery == "aip9a") || (jGallery == "aip9b"))
//		jId = "aip9";
//	else
		jId = jGallery;

	document["aip"+imgId].src = "art/aip_leftNav_map_" + imgGallery + "_off.gif";
	if (jId != "")
		document["aip"+jId].src = "art/aip_leftNav_map_" + jGallery + "_on.gif";

}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function showMainImage( galleryId ) {

	var layerName = "img_" + galleryId;

	if ( document.layers ) {
		document.layers["img"].document.layers["img_0"].visibility = "hidden";
		document.layers["img"].document.layers[layerName].visibility = "show";
	}
	else {
		if ( document.all ) {
			document.all["img_0"].style.visibility = "hidden";
			document.all[layerName].style.visibility = "visible";
		}
		else {
			document.getElementById("img_0").style.visibility = "hidden";
			document.getElementById(layerName).style.visibility = "visible";
		}
	}
}

function hideMainImage( galleryId ) {
	var layerName = "img_" + galleryId;

	if ( document.layers ) {
		document.layers["img"].document.layers[layerName].visibility = "hidden";
		document.layers["img"].document.layers["img_0"].visibility = "show";
	}
	else {
		if ( document.all ) {
			document.all[layerName].style.visibility = "hidden";
			document.all["img_0"].style.visibility = "visible";
		}
		else {
			document.getElementById(layerName).style.visibility = "hidden";
			document.getElementById("img_0").style.visibility = "visible";
		}
	}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
var lastLayer = "";
var openFlag = false;

function openLayer( layerName ) {
	lastLayer = layerName;
	if ( document.layers ) {
		document.layers["img"].document.layers[layerName].visibility = "show";
	}
	else {
		if ( document.all ) {
			document.all[layerName].style.visibility = "visible";
		}
		else {
			document.getElementById(layerName).style.visibility = "visible";
		}
	}
	openFlag = true;
}

function showLayer( layerName ) {
	if ( openFlag == true ) {
		if ( document.layers ) {
			document.layers["img"].document.layers[lastLayer].visibility = "hidden";
			document.layers["img"].document.layers[layerName].visibility = "show";
		}
		else {
			if ( document.all ) {
				document.all[lastLayer].style.visibility = "hidden";
				document.all[layerName].style.visibility = "visible";
			}
			else {
				document.getElementById(lastLayer).style.visibility = "hidden";
				document.getElementById(layerName).style.visibility = "visible";
			}
		}
		lastLayer = layerName;
	}
}

function fauxLayer( layerName ) {
	lastLayer = layerName
}

function redirPrint( pageName, valueFlag ) {
	var redirUrl;

	if ( valueFlag == "1" )
		redirUrl = pageName + "?printFlag=1&showImg=" + lastLayer;
	else
		redirUrl = pageName + "?showImg=" + lastLayer;

	location.href = redirUrl;
}

function redirEnlarge( pageName, zoomFlag ) {
	var redirUrl;

	if ( zoomFlag == "1" )
		redirUrl = pageName + "?showImg=" + lastLayer + "&zoomFlag=1";
	else
		redirUrl = pageName + "?showImg=" + lastLayer;

	location.href = redirUrl;
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function checkWindowName( windowName )
{
	var newWindowName;

	if (window.name == windowName) {
		newWindowName = windowName+'2';
	}
	else {
		newWindowName = windowName;
	}

	return newWindowName;
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function metPopSmall( fileName )
{
	var newWinName = checkWindowName('metSmall');
	
	openPop = this.open(fileName,newWinName,'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=800,height=1,left=100,top=5,screenX=100,screenY=5');

	openPop.focus();

	// close the old pop if metResized pop was blocked
	if ((window.name != newWinName) && ((window.name == 'metSmall') || (window.name == 'metSmall2'))) {
		window.close();
	}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function metPopSplash( fileName )
{
	openPop = this.open(fileName,'metSplash','toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=600,height=321,left=100,top=5,screenX=100,screenY=5');
	openPop.focus();
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------

// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function metPopIntro( fileName )
{
	openPop = this.open(fileName,'metIntro','toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,width=618,height=400,left=100,top=5,screenX=100,screenY=5');
	openPop.focus();
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------

// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function metPop( fileName, winType )
{
	var newWinName;
	var winX, winY;
	var winWidth, winHeight;
		
	if (winType == "1") {
		newWinName = checkWindowName('metWide');
		winWidth = 768;
		if (screen.height > 600) {
			winHeight = 550;
		}
		else {
			winHeight = 515;
		}
		winX = 16;
		winY = 5;
	}
	else {
		newWinName = checkWindowName('metTall');
		winWidth = 618;
		if (screen.height > 600) {
			winHeight = 550;
		}
		else {
			winHeight = 515;
		}
		winX = 100;
		winY = 5;
	}		


	openPop = this.open(fileName,newWinName,'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,width='+winWidth+',height='+winHeight+',left='+winX+',top='+winY+',screenX='+winX+',screenY='+winY);
	openPop.focus();
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function openAndClose( loadPage, pageType ) {
	newPop = metPop( loadPage, pageType );
	window.close();
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------

// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function resizeMe( pageName, winWidth )
{
	var newWinName = checkWindowName('metResized');

	var agt = navigator.userAgent.toLowerCase();
	var is_mac = (agt.indexOf("mac")!=-1);

	var winX, winY;
	if (winWidth > 600) {
		winX = 16;
	}
	else {
		winX = 100;
	}
	winY = 5;
	
	var docHeight = document.height ? document.height : is_mac && document.body && document.body.scrollHeight ? document.documentElement.offsetHeight : document.body && document.body.scrollHeight ? document.body.scrollHeight: null;

	var winHeight;
	var vertScroll;
	var forceResize;
	if ((screen.height - 85) < docHeight) {
		newWinName = checkWindowName('metTest');
		winHeight = screen.height - 100;
		vertScroll = "yes";

		if ((window.name != 'metTest') || ((document.referrer != '') && (document.referrer.indexOf(pageName) == -1))) {
			winWidth += 18;
			newPopResized = window.open(pageName,newWinName,'toolbar=no,menubar=no,location=no,scrollbars='+vertScroll+',resizable=no,width='+winWidth+',height='+winHeight+',left='+winX+',top='+winY+',screenX='+winX+',screenY='+winY);
				if (!newPopResized) {
					winWidth += 30;
					winHeight += 30;
					window.resizeTo(winWidth,winHeight);
					window.moveTo(winX,winY);
				}
			newPopResized.focus();
			window.close();
		}

		forceResize = true;
	}
	else {
		winHeight = docHeight;
		vertScroll = "no";
		forceResize = false;
	}

	if (winWidth && docHeight) {
		if ((((docHeight) == (window.innerHeight ? window.innerHeight : document.body && document.body.scrollHeight ? document.body.clientHeight : null))) || (forceResize)) {
			void(0);
		}
		else {
			newPopResized = window.open(pageName,newWinName,'toolbar=no,menubar=no,location=no,scrollbars='+vertScroll+',resizable=no,width='+winWidth+',height='+winHeight+',left='+winX+',top='+winY+',screenX='+winX+',screenY='+winY);

			// if newPop fails, resize and move old pop
			if (!newPopResized) {
				winWidth += 30;
				winHeight += 30;
				window.resizeTo(winWidth,winHeight);
				window.moveTo(winX,winY);
			}
		newPopResized.focus();
		window.close();
		}
	}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------

// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function resizeReg( pageName, winWidth )
{
	var newWinName = checkWindowName('metResized');

	var agt = navigator.userAgent.toLowerCase();
	var is_mac = (agt.indexOf("mac")!=-1);

	var winX, winY;
	if (winWidth > 600) {
		winX = 16;
	}
	else {
		winX = 100;
	}
	winY = 5;
	
	var docHeight = document.height ? document.height : is_mac && document.body && document.body.scrollHeight ? document.documentElement.offsetHeight : document.body && document.body.scrollHeight ? document.body.scrollHeight: null;

	var winHeight;
	var vertScroll;
	var forceResize;
	if ((screen.height - 85) < docHeight) {
		newWinName = checkWindowName('metTest');
		winHeight = screen.height - 100;
		vertScroll = "yes";

		if ((window.name != 'metTest') || ((document.referrer != '') && (document.referrer.indexOf(pageName) == -1))) {
			winWidth += 18;
			newPopResized = window.open(pageName,newWinName,'toolbar=no,menubar=no,location=no,scrollbars='+vertScroll+',resizable=no,width='+winWidth+',height='+winHeight+',left='+winX+',top='+winY+',screenX='+winX+',screenY='+winY);
				if (!newPopResized) {
					winWidth += 30;
					winHeight += 30;
					window.resizeTo(winWidth,winHeight);
					window.moveTo(winX,winY);
				}
			newPopResized.focus();
			window.close();
		}

		forceResize = true;
	}
	else {
		winHeight = docHeight;
		vertScroll = "no";
		forceResize = false;
	}

	if (winWidth && docHeight) {
		if ((((docHeight) == (window.innerHeight ? window.innerHeight : document.body && document.body.scrollHeight ? document.body.clientHeight : null))) || (forceResize)) {
			void(0);
		}
		else {
			newPopResized = window.open(pageName,newWinName,'toolbar=no,menubar=no,location=no,scrollbars='+vertScroll+',resizable=no,width='+winWidth+',height='+winHeight+',left='+winX+',top='+winY+',screenX='+winX+',screenY='+winY);

			// if newPop fails, resize and move old pop
			if (!newPopResized) {
				winWidth += 30;
				winHeight += 30;
				window.resizeTo(winWidth,winHeight);
				window.moveTo(winX,winY);
			}
		newPopResized.focus();
		window.close();
		}
	}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
