// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
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( imgId, imgGallery ) {
	if ( document.images && ( preloadFlag == true ) )
	{
		document[imgId].src = "art/byz_map_" + imgId + "_" + imgGallery + ".gif";
		showMainImage( imgGallery );
		lastGallery = imgGallery;
	}
}

function mapSwapOut( imgId ) {
	document[imgId].src = "art/byz_map_" + imgId + ".gif";
	hideMainImage(lastGallery);
}


function mapSwapInSmall( imgGallery ) {
	if ( document.images && ( preloadFlag == true ) )
	{
		document['leftNavMap'].src = "art/byz_map_leftNav_" + imgGallery + ".gif";
	}
}

function mapSwapOutSmall( imgGallery ) {
	document['leftNavMap'].src = "art/byz_map_leftNav_" + imgGallery + ".gif";
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function showLayer( layerName ) {
	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 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 lastFoot;
var footFlag = false;

function showFoot( footId, e ) {
	if (footFlag == true)
		hideFoot( lastFoot );

	lastFoot = footId;
	footFlag = true;

	var winWidth = document.width ? document.width : document.body && document.body.scrollWidth ? document.body.scrollWidth : null;
	var winHeight = document.height ? document.height : document.body && document.body.offsetHeight ? document.body.offsetHeight : null;

    if (e != '') {
        if (document.layers) {
            x = e.pageX;
            y = e.pageY;
        }
        else if (document.all) {
//            x = e.offsetX;
//            y = e.offsetY;
            x = e.clientX + document.body.scrollLeft;
            y = e.clientY + document.body.scrollTop;
        }
        else if (document.getElementById) {
            x = e.pageX;
            y = e.pageY;
        }
    }

	if (x > (winWidth / 2))
		x -= 100;
	
	if (y > (winHeight / 2))
		y -= 50;
	
    if (document.layers && document.layers[footId] != null) {
        document.layers[footId].left = x;
        document.layers[footId].top = y;
    }
    else if (document.all) {
        document.all[footId].style.posLeft = x;
        document.all[footId].style.posTop = y;
    }
	else {
        document.getElementById(footId).style.left = x;
        document.getElementById(footId).style.top = y;
	}

    if (document.layers && document.layers[footId] != null)
        document.layers[footId].visibility = 'visible';
    else if (document.all)
        document.all[footId].style.visibility = 'visible';
	else
		document.getElementById(footId).style.visibility = 'visible';

}

function hideFoot( footId ) {
    if (document.layers && document.layers[footId] != null)
        document.layers[footId].visibility = 'hidden';
    else if (document.all)
        document.all[footId].style.visibility = 'hidden';
	else
		document.getElementById(footId).style.visibility = 'hidden';

	footFlag = false;
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
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 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;
	}		


//	winHeight = screen.height - 100;

	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();
		}
	}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
