if(!window.MMFX)
	MMFX=new Object();

var browserNs = (navigator.appName.indexOf("Netscape") != -1) && (navigator.userAgent.indexOf("Firefox") == -1);
var browserNs4 = (browserNs && !document.getElementById);
var browserNs6 = (browserNs && !browserNs4);

MMFX.ThumbnailScroller = function(x, y, w, h)
{
	this.state = "NOT_BUILT";
	this.dirX = 0;
	this.dirY = 0;
	this.x = x;
	this.y = y;
	this.sx = 0;
	this.sy = 0;
	this.w = w;
	this.h = h;
	this.scrollLayer = null;
	this.outerLayer = null;
	this.bgColor = null;
	this.imageSrcs = new Array();
	this.links = new Array();
	this.hovers = new Array();
	this.images = new Array();
	this.content = "";
	this.step = 2;
	this.id = "MMFXScroll" + MMFX.ThumbnailScroller.no++;
	window[this.id]=this;
}
MMFX.ThumbnailScroller.no = 0;
MMFX.ThumbnailScroller.prototype.build = function(horizontal, onload, tableParams)
{
	this.outerLayer = new JSFX.Layer(" ");
	this.outerLayer.moveTo(this.x, this.y);
	this.outerLayer.resizeTo(this.w, this.h);
	this.outerLayer.show();
	this.outerLayer.clip(0,0,this.w, this.h);

	this.scrollLayer = new JSFX.Layer(" ", this.outerLayer);
	this.scrollLayer.moveTo(0,0);
	this.scrollLayer.resizeTo(this.w, this.h);
	this.scrollLayer.show();
	this.scrollLayer.setzIndex(100);

	if (tableParams)
		this.content="<table " + tableParams + ">"
	else
		this.content="<table>"
	if (horizontal)
		this.content += "<tr>";
	for (i = 0; i < this.imageSrcs.length; i++)
	{
		onloadStr = "";
		if (onload)
			onloadStr = " onLoad=" + onload;
		if (!horizontal)
			this.content += "<tr>";
		this.content += "<td align=center valign=center>" + this.links[i] + 
				"<img border=0 src=" + this.imageSrcs[i] +
				    " alt=\"" + this.hovers[i] + "\"" + onloadStr +"></a></td>";
		if (!horizontal)
			this.content += "</tr>";
	}
	if (horizontal)
		this.content += "<td align=center valign=center><img id=scrollEnd src=/images/spacer.gif width=1 height=" + this.getHeight() + "></td></tr>";
	else
		this.content += "<tr><td align=center valign=center><img id=scrollEnd src=/images/spacer.gif width=" + this.getWidth() + " height=1></td></tr>";
	this.content += "</table>"

	this.scrollLayer.setContent(this.content);
	if (!ns4)
		this.scrollLayer.setOpacity(100);
	var scrollEnd = new MMFX.Element("scrollEnd");
	this.scrollLayer.realWidth = scrollEnd.x;
//	alert("scrollLayer.width " + this.scrollLayer.style.clip.right);

	this.state = "OFF";
}
MMFX.ThumbnailScroller.prototype.setBgColor = function(color)
{
	this.bgColor = color;
	if(this.state != "NOT_BUILT")
		this.outerLayer.setBgColor(color);
}
MMFX.ThumbnailScroller.prototype.addImage = function(image, link, hover)
{
	this.imageSrcs[this.imageSrcs.length] = image;
	this.links[this.links.length] = link;
	this.hovers[this.hovers.length] = hover;
}

MMFX.ThumbnailScroller.prototype.clearImages = function()
{
	this.imageSrcs = new Array();
}
MMFX.ThumbnailScroller.prototype.animate = function()
{
	if (MMFX.ThumbnailScroller.prototype.animate.arguments.length > 0)
	{
		this.dirX = MMFX.ThumbnailScroller.prototype.animate.arguments[0];
		this.dirY = MMFX.ThumbnailScroller.prototype.animate.arguments[1];
	}

	if ((this.dirX == 0) && (this.dirY == 0))
	{
		return;
	}
	if(this.state == "OFF")
	{
		this.scrollLayer.setOpacity(100);
		this.scrollLayer.moveTo(this.sx, this.sy);
		this.state = "ANIMATING";	
		this.setTimeout("animate()", 40);
	}
	else if(this.state == "ANIMATING")
	{
		this.moveRel(this.dirX * this.step, this.dirY * this.step);
		this.setTimeout("animate()", 40);
	}
}
MMFX.ThumbnailScroller.prototype.moveRel= function(relX, relY)
{	
	this.sx += relX;
	this.sy += relY;
	if (this.sx > 0)
	{
		this.sx = 0;
	}
	if (this.sy > 0)
	{
		this.sy = 0;
	}
	if ((this.w > this.scrollLayer.realWidth + this.sx))
	{
		this.sx = this.w - this.scrollLayer.realWidth;
	}

	this.scrollLayer.moveTo(this.sx, this.sy);
	if (browserNs4)
		this.scrollLayer.resizeTo(this.w - this.sx, this.h);
}
MMFX.ThumbnailScroller.prototype.getWidth = function() 
{
	return (this.w);
}
MMFX.ThumbnailScroller.prototype.getHeight = function() 
{
	return (this.h);
}
MMFX.ThumbnailScroller.prototype.setTimeout = function(f, t) 
{
	setTimeout("window."+this.id+"."+f, t);
}
MMFX.ThumbnailScroller.prototype.hide = function()
{	
	this.outerLayer.hide();
	this.scrollLayer.hide();
}

MMFX.Photo = function(photoname)
{
	this.name = "";
	this.url = "";
	this.thumbnailUrl = "";
	this.width = 0;
	this.height = 0;
	this.thumbnailWidth = 0;
	this.thumbnailHeight = 0;
	this.category = "";
	this.description = "";
	this.date = "";
	this.people = "";
	
	if (photoArr && photoname)
	{
		for (i = 0; i < photoArr.length; i++)
		{
			arrayOfStrings = photoArr[i].split(":");
			if (arrayOfStrings[1] == photoname)
			{
				this.parse(photoArr[i]);
				return;
			}
		}
	}
}
MMFX.Photo.prototype.parse = function(str)
{
	arrayOfStrings = str.split(":");

	this.category = arrayOfStrings[0];
	this.name = arrayOfStrings[1];
	this.thumbnailWidth  = parseInt(arrayOfStrings[2], 10);
	this.thumbnailHeight = parseInt(arrayOfStrings[3], 10);
	this.width  = parseInt(arrayOfStrings[4], 10);
	this.height = parseInt(arrayOfStrings[5], 10);
	this.description = arrayOfStrings[6];
	this.url = MMFX.PHOTOSITE + this.name + ".jpg";
	this.thumbnailUrl = MMFX.PHOTOSITE + this.name + "tn.jpg";
}
MMFX.Photo.prototype.writeThumbnail = function(args)
{
	extraArgs = '';
	if (args)
		extraArgs += args;
	document.write("<a href=javascript:MMFX.PhotoLoad('" + this.name + "') onMouseOut=\"MM.StatusMsg(null)\""
			+ "onMouseOver=\"MM.StatusMsg('Click on thumbnail to see larger version.')\"><img src=" +
			this.thumbnailUrl + " width=" + this.thumbnailWidth + " height= " + this.thumbnailHeight +
			" alt=\"" + this.description + "\" " + extraArgs + " border=1></a>");
}
MMFX.PhotoWriteThumbnail = function(name, args)
{
	photo = new MMFX.Photo(name);
	photo.writeThumbnail(args);
}

MMFX.currPhoto = null;
MMFX.imgLayer = null;
MMFX.PhotoLoad = function(name)
{
	if (MMFX.imgLayer != null)
			MMFX.PhotoClicked();

	MM.StatusMsg("Loading photo ... please wait.  When loaded click on photo to make it disappear.");
	MMFX.currPhoto = new MMFX.Photo(name);

	currImage = new Image();
	currImage.onload = MMFX.PhotoLoaded;
	currImage.src = MMFX.currPhoto.url;
}

MMFX.PhotoLoaded = function()
{
	MMFX.imgLayer = new JSFX.Layer(" ");
	MMFX.imgLayer.moveTo((JSFX.Browser.getWindowWidth() - MMFX.currPhoto.width) / 2,
					(JSFX.Browser.getWindowHeight() - MMFX.currPhoto.height) / 2 + JSFX.Browser.getMinY());
	MMFX.imgLayer.hide();
	MM.StatusMsg("Click on photo to make it disappear.");
	MMFX.imgLayer.setContent(
			"<table border=0 cellpadding=15 cellspacing=0><tr><td><a href=javascript:MMFX.PhotoClicked()" + 
			" onMouseOut=\"MM.StatusMsg(null)\" " +
			"onMouseOver=\"MM.StatusMsg('Click on photo to make it disappear.')\" ><IMG border=0 SRC='" +
			MMFX.currPhoto.url	+ "' WIDTH='" + MMFX.currPhoto.width	+ "' HEIGHT='" + MMFX.currPhoto.height + "' alt=\"" +
			MMFX.currPhoto.description + "\"></a></td></tr></table>");

	MMFX.imgLayer.resizeTo(MMFX.currPhoto.width + 30, MMFX.currPhoto.height + 30);
	MMFX.imgLayer.setBgColor("white");
	MMFX.imgLayer.setzIndex(101);
	MMFX.imgLayer.show();
}
MMFX.PhotoClicked = function()
{
	MMFX.imgLayer.hide();
	MMFX.imgLayer = null;
}

MMFX.photoCategories = null;
MMFX.photoCategoryNumbers = null;
MMFX.PhotoCategories = function()
{
	if (MMFX.photoCategories == null)
	{
		MMFX.CalcCategories();
	}
	
	return (MMFX.photoCategories);
}
MMFX.PhotoCategoryNumbers = function()
{
	if (MMFX.photoCategoryNumbers == null)
	{
		MMFX.CalcCategories();
	}
	
	return (MMFX.photoCategoryNumbers);
}
MMFX.CalcCategories = function()
{
	var currCategory = "";
	var photo = new MMFX.Photo();
	var numPhotosInCategory = 0;
	MMFX.photoCategories = new Array();
	MMFX.photoCategoryNumbers = new Array();
	numCats = 0;
	for (i = 0; i < photoArr.length; i++)
	{
		photo.parse(photoArr[i]);
		if (photo.category != currCategory)
		{
			if (numPhotosInCategory != 0)
				MMFX.photoCategoryNumbers[numCats - 1] = numPhotosInCategory;
			numPhotosInCategory = 0;
			currCategory = photo.category;
			MMFX.photoCategories[numCats++] = currCategory;
		}
		numPhotosInCategory ++;
	}
	MMFX.photoCategoryNumbers[numCats - 1] = numPhotosInCategory;
}

MMFX.Element = function(name)
{
	this.name = name;
	if (document.getElementById && (navigator.userAgent.indexOf("Firefox") == -1))
	{
		var pic = document.getElementById(name);
		this.x = pic.offsetLeft;
		this.y = pic.offsetTop;
		this.width = pic.width;
		this.height = pic.height;
		tempEl = pic.offsetParent;
		while (tempEl != null)
		{
			this.x += tempEl.offsetLeft;
			this.y += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
	}
	else
	{
		var pic = document.images[name];
		this.x = pic.x;
		this.y = pic.y;
		this.width = pic.width;
		this.height = pic.height;
	}
}