function generateGallery(imageList,path){
	var imageCounter = 0;
	
	while (imageCounter < imageList.length) {
		for (var loopCounter = 1;loopCounter<10;loopCounter++){		
			if (loopCounter == 1){
				document.write('<table width="738" border="0" cellspacing="0" cellpadding="0">');
				document.write('<tr>');
			}
			
			document.write('<td align="center" valign="middle"><a href="javascript:openViewer(\''+path+'\',\''+imageList[imageCounter]+'.jpg\')">');
			document.write('<img src="Thumbs/'+imageList[imageCounter]+'.gif"></a></td>');
			
			if (imageCounter == imageList.length-1){
				loopCounter = 9;
			}
			
			if (loopCounter == 9){
				document.write('</tr>');
				document.write('</table><br>');			
			}
			imageCounter++;
		}
	}
}

function openViewer (path,imageName){
	var left = Math.floor( (screen.width - 650) / 2);
	var top = Math.floor( (screen.height - 640) / 2);
	window.open ("http://www.pittsburghironlegion.com/viewer.html?"+imageName+"&"+path+"&", 'viewerWindow', config='height=640,width=650,top='+top+',left='+left+', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no')
}

function read_Query(whichValue) {
	theQuery = location.href.substring(location.href.indexOf("?")+1,location.href.length);
	for(var vc=0;vc < whichValue;vc++){
		var queryValue = theQuery.substring(0,theQuery.indexOf("&"));
		
		theQuery = theQuery.substring(theQuery.indexOf("&")+1,theQuery.length);
	}
	return queryValue;
}

function Go(where){
	var imageName = read_Query(1);
	var pathName = read_Query(2);
	var nav = getPageData(imageName);
	//alert(imageName);
	//alert(nav[where]);
	if(nav[where] != "NoNav"){
		document.location = "viewer.html?"+nav[where]+"&"+pathName+"&";
	}
}

function loadFooter(){
	var pilDate = new Date();
	document.write('<br>');
	document.write('<div id="PILFooter" style="position:absolute; width:100%; height:20; z-index:10;">');	
	document.write('	<table width="100%" border="0" cellspacing="0" cellpadding="0">');
	document.write('		<tr>');
	document.write('			<td height="20" width="30"><img src="http://www.pittsburghironlegion.com/images/spacer.gif"></td>');
	document.write('			<td width="700" class="captionBold" align="center" bgcolor="#7c7c7c">&copy; '+ pilDate.getFullYear() +' - Pittsburgh Iron Legion miniature Gaming Club</td>');
	document.write('			<td><img src="http://www.pittsburghironlegion.com/images/spacer.gif"></td>');
	document.write('		</tr>');
	document.write('	</table>');
	document.write('</div>');
	document.write('</div>');
	AW_PersistLayer('PILFooter','document.layers[!!PILFooter!!]','document.all[!!PILFooter!!]','true');
	positionFooter();
}

function loadHeader(section){
	//Netscape Redirect
	init = true;
	//if (init==true) with (navigator) {
	//	if (appName=="Netscape") {
	//		document.location = "http://www.google.com"; 
	//	}
	//}

	document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
	document.write('  <tr>');
	document.write('    <td height="154" width="769" valign="top"><img src="http://www.pittsburghironlegion.com/images/header.gif"></td>');
	document.write('    <td><img src="http://www.pittsburghironlegion.com/images/spacer.gif">');
	document.write('		<div id="Menu" style="position:absolute; width:200px; height:40px; z-index:2; left: 101px; top: 113px;">');
	document.write('			<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="635" height="25">');
	document.write('				<param name="movie" value="http://www.pittsburghironlegion.com/images/Menu.swf?sectionNum='+section+'">');
	document.write('				<param name="quality" value="high">');
	document.write('				<param name="wmode" value="transparent">');
	document.write('				<embed src="http://www.pittsburghironlegion.com/images/Menu.swf?sectionNum='+section+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="635" height="25" wmode="transparent"></embed>');
	document.write('			</object>');
	document.write('	  </div></td>');
	document.write('  </tr>');
	document.write('</table>');
}

function menuGo(where){
	var newLoc = "";
	if (where == 1){
		newLoc = "http://www.pittsburghironlegion.com/home.htm";
	} else if (where == 2){
		newLoc = "http://www.pittsburghironlegion.com/phpBB/";
	} else if (where == 3){
		newLoc = "http://www.pittsburghironlegion.com/info.htm";
	} else if (where == 4){
		newLoc = "http://www.pittsburghironlegion.com/news.htm";
	} else if (where == 5){
		newLoc = "http://www.pittsburghironlegion.com/hobby.htm";
	} else if (where == 6){
		newLoc = "http://www.pittsburghironlegion.com/events.htm";
	} else if (where == 7){
		newLoc = "http://www.pittsburghironlegion.com/links.htm";
	} else if (where == 8){
		newLoc = "http://www.pittsburghironlegion.com/downloads.htm";
	}
	document.location = newLoc;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function positionFooter(){
	if (document.layers) {
		if (screen.width < 800 | window.innerWidth < 800){
			var myOffset = 20;
		} else {
			var myOffset = 10;
		}
		document.PILFooter.top = window.innerHeight - document.PILFooter.clip.height - myOffset;
	} else if (document.all) {
		if (screen.width < 800 | document.body.offsetWidth < 800){
			var myOffset = 20;
		} else {
			var myOffset = 5;
		}
		PILFooter.style.top = document.body.offsetHeight - parseInt(PILFooter.style.height) -myOffset;
	} else if (document.getElementById){
		document.getElementById("PILFooter").style.top = window.innerHeight - parseInt(document.getElementById("PILFooter").style.height);
	}
}

function AW_PersistLayer(layerName,NSpath,IEpath,firstTime){
	
	NSpath = NSpath.replace(/!!/g,"'");
	IEpath = IEpath.replace(/!!/g,"'");
	
	var offset;
	
	//test browser version------------------------------------------------------------------
	var isIE=(document.all) ? 1 : 0;
	var isNav4=(document.layers) ? 1 : 0;
	var isNav6=(!isIE && document.getElementById) ? 1 : 0;
	//--------------------------------------------------------------------------------------

	//set layer reference-------------------------------------------------------------------	
	if (document.getElementById){
		var theLayer = document.getElementById(layerName);
	} else if (document.all){
		var theLayer = document.all[layerName];
		alert("top "+document.all[layerName].style.pixelTop);
	} else if (document.layers){
		var theLayer = document.layers[layerName];
	}
	//--------------------------------------------------------------------------------------	

	//set offset (change is layer loc)------------------------------------------------------
	if(eval(firstTime)){
		theLayer.XPOS = 0;
		theLayer.YPOS = 0;
	}
	//--------------------------------------------------------------------------------------
	
	//Find the browser bottom---------------------------------------------------------------	
	if(isNav4){	
		offsetX = window.self.pageXOffset;			
		offsetY = window.self.pageYOffset;
	}
	else if(isNav6){
		offsetX = window.self.pageXOffset;			
		offsetY = window.self.pageYOffset;
	}
	else{
		offsetX = window.document.body.scrollLeft;	
		offsetY = window.document.body.scrollTop;
	}
	//--------------------------------------------------------------------------------------
	
	
	// Adjust X loc-------------------------------------------------------------------------
	if (offsetX != theLayer.XPOS){
		var oldOffsetX=offsetX;
		offsetX=offsetX-theLayer.XPOS;
		theLayer.XPOS = oldOffsetX;
		if(isNav4){ theLayer.left+=offsetX}
		else if(isNav6){ theLayer.style.left+=offsetX+"px";}
		else{ theLayer.style.pixelLeft+=offsetX}
	}	
	//--------------------------------------------------------------------------------------
	
	
	// Adjust Y loc-------------------------------------------------------------------------
	if (offsetY != theLayer.YPOS){		
		var oldOffsetY=offsetY;
		offsetY=offsetY-theLayer.YPOS;
		theLayer.YPOS = oldOffsetY;
		if(isNav4){ theLayer.top+=offsetY }
		else if(isNav6){ theLayer.style.top=(parseInt(theLayer.style.top)+offsetY)+"px";}
		else{ theLayer.style.pixelTop+=offsetY }
	}	
	//--------------------------------------------------------------------------------------
	
	theLayer.timerid = setTimeout("AW_PersistLayer(\""+layerName+"\",\""+NSpath+"\",\""+IEpath+"\",'false')",50);
}