<!--
//-----------------------------------------------------------------------------
// GLOBALS
//-----------------------------------------------------------------------------
var ie5 = document.all && document.getElementById;
var ns6 = document.getElementById && ! document.all;
var photototal = 1;
var colmax = 1;
var rowmax = 1;
var basePath = "images/pics_tb/";
var ext = ".jpg";
var page = eval(document.location.search.substr(1)) || 1;

//-----------------------------------------------------------------------------
// FUNCTIONS
//-----------------------------------------------------------------------------
/*
Assigns a new function to the onload handler without overriding 
a previously defined function. Multiple functions are executed in the order 
in which they were assigned
USAGE:
	addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);
	addLoadEvent( function() { ; } );
*/
function addLoadEvent(func) 
{
  var oldonload = window.onload;
  if (typeof window.onload != 'function') window.onload = func;
  else
  {
		window.onload = function()
		{
			oldonload();
			func();
    }
  }
}

function DEC_docObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
		this.obj = document.all[name];
		this.style = document.all[name].style;
  }
  else if (document.layers)
  {
		this.obj = __getObjNN4(document,name);
		this.style = this.obj;
  }
}

function openWin(url,name,parms)
{
	if (!url) return;
	name = name || "NEWWINDOW";
	parms = parms || "width=500,height=400,scrollbars=yes";
	newWindow = window.open(url,name,parms);
	newWindow.focus();
}

function addPanel(row, index)
{
	var panel = document.createElement("div");
	(ie5) ? panel.setAttribute("className", "panel") : panel.className = "panel";
	var a = document.createElement("a");
	a.setAttribute("href", "javascript:openWin('pic.html?" + index + "');void(0);");
	a.setAttribute("title", "Click to enlarge");
	var img = document.createElement("img");
	img.setAttribute("src", basePath + index + ext);
	a.appendChild(img);	
	panel.appendChild(a);	
	row.appendChild(panel);	
}

function layoutPhotos()
{
	var layout = new DEC_docObj("photolayout");
	var offset = (page - 1) * rowmax * colmax;
	var index;		
	for (i = 0; i < rowmax; i++)
	{
		var row = document.createElement("div");
		(ie5) ? row.setAttribute("className", "row") : row.className = "row";
		for (j = 1; j <= colmax; j++)
		{
			index = (i * colmax) + j + offset;		
			if (index <= photototal) addPanel(row, index);
			else break;
		}
		layout.obj.appendChild(row);
		if (index == photototal) break;
	}
}

function defineNavigation()
{
	if (photototal > rowmax * colmax)
	{
		var nav = new DEC_docObj("navigation");
		var text = document.createTextNode("page: ");
		nav.obj.appendChild(text);
		if (page > 1)
		{
			var back = document.createElement("a");
			back.setAttribute("href", "?" + (page - 1));
			text = document.createTextNode("back");
			back.appendChild(text);	
			nav.obj.appendChild(back);			
		}
		if (page * rowmax * colmax < photototal)
		{
			if (page > 1)
			{
				var separator = document.createTextNode(" | ");
				nav.obj.appendChild(separator);
			}
			var next = document.createElement("a");
			next.setAttribute("href", "?" + (page + 1));
			text = document.createTextNode("next");
			next.appendChild(text);	
			nav.obj.appendChild(next);
		}
	}
}

//-----------------------------------------------------------------------------
// GLOBAL EVENTS
//-----------------------------------------------------------------------------
function initialize()
{
	layoutPhotos();
	defineNavigation();
}

//-----------------------------------------------------------------------------
// ASSIGN GLOBAL EVENTS
//-----------------------------------------------------------------------------
addLoadEvent( function () { initialize(); } );
addLoadEvent( function () { P7_initPM(1,0,0,10,0); } );

/*
<div class="row">
	<div class="panel"><a href="javascript:openWin('pic.html?1');void(0);"><img src="images/pics_tb/1.jpg"></a></div>
	<div class="panel"><a href="javascript:openWin('pic.html?2');void(0);"><img src="images/pics_tb/2.jpg"></a></div>
	<div class="panel"><a href="javascript:openWin('pic.html?3');void(0);"><img src="images/pics_tb/3.jpg"></a></div>
	<div class="panel"><a href="javascript:openWin('pic.html?4');void(0);"><img src="images/pics_tb/4.jpg"></a></div>
</div>
*/
//-->