function sty(obj)
{
	var p = ref(obj);
	
	if(p)
	{
		p = p.style;
	}
		
	return(p);
}

function ref(obj)
{
	return($(obj));
}

function elemGetTop(obj)
{
	var t = 0;
	t = obj.style.top;
	return(t);
}

function elemGetHeight(obj)
{
	return(px(obj.offsetHeight));
}

function elemSetTop(obj, height)
{
	obj.style.top = height + 'px';
}

function px(str)
{
	var n;
	
	str = "" + str;
	if((n = str.indexOf('px')) != -1)
	{
		return(parseInt(str.substr(0, n), 10));
	}
	else
	{
		return(parseInt(str, 10));
	}
}

function TextWidth(str, width)
{
	var words = str.split(' ');
	var len = 0;
	var i;

	for(i = 0; i < words.length; i++)
	{
		var wlength = proportionalLength(words[i]);
		len = len + wlength + 1;
	}
	
	return(len);
}

function Prune(str, width)
{
	var words = str.split(' ');
	var ret = "";
	var count = 0;
	var len = 0;
	var i;

	for(i = 0; i < words.length; i++)
	{
		var wlength = proportionalLength(words[i]);
		if(len + wlength > width)
		{
			ret = ret + "...";
			return(ret);
		}
		
		if(ret.length > 0)
		{
			ret = ret + " ";
		}
		
		ret = ret + words[i];
		len = len + wlength + 1;
	}
	
	return(ret); 
}

function proportionalLength(str)
{
	var len = 0;
	var i;
	for(i = 0; i < str.length; i++)
	{
		var c = str.substr(i, 1);
		if(c >= 'A' && c <= 'Z')
		{
			len += 1.55;
			continue;
		}
		
		if(c >= '0' && c <= '9')
		{
			len += 1.5;
			continue;
		}
		
		len += 1;
	}
	
	if(len > 9 && len < 14)
	{
		len *= 1.6;
	}
	
	return(len);
}

function waitimageload(imgid, callback, count)
{
	var img = ge(imgid);
	if(typeof(img.complete) != "undefined" && img.complete === false && count > 0)
	{
		window.setTimeout("waitimageload('" + imgid + "', '" + callback + "', " + (count - 20)+ ")", 20);
		return;
	}

	eval(callback + "()");
}

function ThumbViewer(element)
{
	// setup some private variables
	this.thumbURI = null;
	this.thumbDesc = null;
	this.thumbA = null;
	this.thumbIMG = null;
	this.thumbAlt = null;
	this.curleft = 0;
	this.element = element;
	this.styleClass = "";
	this.arrowPrevOff = '/images/cmpw-prevoff.gif';
	this.arrowPrevOn =  '/images/cmpw-prevon.gif';
	this.arrowNextOff = '/images/cmpw-nextoff.gif';
	this.arrowNextOn =  '/images/cmpw-nexton.gif';	
	this.blankImageURI = '/images/invisodot.gif';
	this.emptyViewerImageURI = '/images/unavailable.jpg';
	this.thumbover = null;
	this.thumbout = null;
	this.css = 'tvbar';
	this.divheight = 0;
	this.divcss = '';
	this.thumbcss = 'tvthumb';
	this.acss = 'photo';
	this.arrowcss = '';
	this.caption = null;
	this.widthArrow = 13;
	this.shadow = null;
	this.note = null;
	
	// setup some default parameters
	this.thumbSize = 50;
	this.thumbSlots = 4;
	this.thumbPad = 6;
	this.shadowh = null;
	this.shadown = null;

	this.clone = function(element)
	{
		var ret = new ThumbViewer(element);
		ret.arrowPrevOff = this.arrowPrevOff;
		ret.arrowPrevOn = this.arrowPrevOn;
		ret.arrowNextOff = this.arrowNextOff;
		ret.arrowNextOn = this.arrowNextOn;
		ret.blankImageURI = this.blankImageURI;
		ret.emptyViewerImageURI = this.emptyViewerImageURI;
		ret.css = this.css;
		ret.divheight = this.divheight;
		ret.divcss = this.divcss;
		ret.thumbcss = this.thumbcss;
		ret.acss = this.acss;
		ret.arrowcss = this.arrowcss;
		ret.caption = this.caption;
		ret.widthArrow = this.widthArrow;
		ret.shadow = this.shadow;
		ret.thumbSize = this.thumbSize;
		ret.thumbSlots = this.thumbSlots;
		ret.thumbPad = this.thumbPad;
		ret.shadowh = this.shadowh;
		ret.shadown = this.shadown;
		ret.thumbURI = this.thumbURI;
		ret.divheight = this.divheight;
		ret.divwidth = this.divwidth;
		return(ret);
	};

	this.setImageURIs = function(n)
	{
		this.thumbURI = n;
		var i;
		for(i = 0; i < this.thumbURI.length; i++)
		{
 			var img = ge(this.element + "_img" + i);
			if(img)
			{
				img.src = this.thumbURI[i];
			}
		}
	};
	
	this.setAlt = function(n)
	{
		this.thumbAlt = n;
	};

	this.setCaption = function(n)
	{
		this.caption = n;
	};

	this.generate = function()
	{
		var a, idiv, div, img, html = '';
		var i;

		wdiv = document.createElement("div");
		wdiv.setAttribute('class', this.css);
		
		div = document.createElement("div");
		div.setAttribute('class', this.css);
		div.style.position = 'absolute';
		wdiv.appendChild(div);
		wdiv = div;
		
		if(this.thumbURI.length > 0)
		{
			idiv = document.createElement("div");
			idiv.setAttribute('id', this.element + '_div_prev');
			idiv.style.position = 'absolute';
			idiv.style.top = '0px';
			idiv.style.left = '0px';
			idiv.style.height = '50px';
			idiv.style.width = this.widthArrow + 'px';
			
			img = document.createElement("img");
			img.setAttribute('class', this.arrowcss.length === 0 ? 'photo' : this.arrowcss);
			img.setAttribute('id', this.element + '_prev');
			img.style.border = 'none';
			img.setAttribute('src', this.arrowPrevOff);
	
			if(this.thumbURI.length > this.thumbSlots)
			{
				a = document.createElement("a");
				a._ThumbViewer = this;
				a.setAttribute('id', this.element + '_a_prev');
				a.setAttribute('href', "javascript:tvslideleft('" + this.element + "_a_prev');");
				a.setAttribute('class', 'photo');
				a.appendChild(img);
	
				idiv.appendChild(a);
			}
			else
			{
				idiv.appendChild(img);
			}
			
			wdiv.appendChild(idiv);
			
			var tvdiv = document.createElement("div");
//			var tvwidth = (this.thumbSlots * (this.thumbSize + this.thumbPad)) - this.thumbPad;
			var tvwidth = (this.thumbSlots * this.divwidth);
			tvdiv.style.width = tvwidth + 'px';
			tvdiv.style.height = (this.divheight === 0 ? this.thumbSize : this.divheight) + 'px';
			tvdiv.style.position = 'absolute';
			tvdiv.style.top = '0px';
			tvdiv.style.left = (this.widthArrow + this.thumbPad) + 'px';
			wdiv.appendChild(tvdiv);

			div = document.createElement("div");
			div.setAttribute('id', this.element + '_mask');
			div.style.position = "absolute";
			div.style.width = tvwidth + 'px';
			div.style.height = (this.divheight === 0 ? this.thumbSize : this.divheight) + 'px';
			div.style.overflow = 'hidden';
			tvdiv.appendChild(div);
			tvdiv = div;
			
			div = document.createElement("div");
			div.setAttribute('id', this.element + '_scroller');
			div.style.position = "absolute";
			div.style.width = tvwidth + 'px';
			div.style.height = (this.divheight === 0 ? this.thumbSize : this.divheight) + 'px';
			tvdiv.appendChild(div);
			tvdiv = div;
			
			for(i = 0; i < this.thumbURI.length; i++)
			{
				idiv = document.createElement("div");
				idiv.setAttribute('id', this.element + '_div' + i);
				if(this.divcss.length > 0)
				{
					idiv.setAttribute('class', this.divcss);
				}
				
				idiv.style.position = 'absolute';
				idiv.style.zIndex = "500000";
				idiv.style.top = '0px';
				idiv.style.left = (i * (this.thumbSize + this.thumbPad)) + 'px';
		
				img = document.createElement("img");
				img.setAttribute('class', this.thumbcss);
				img.setAttribute('id', this.element + '_img' + i);
				if(this.title)
				{
					if(this.title[i].length > 0)
					{
						img.setAttribute('title', this.title[i]);
					}
				}
				
				if(this.thumbSize == 50)
				{
					img.setAttribute('style', "width: " + this.thumbSize + "px; height: " + this.thumbSize + "px;");			}
					
				img.style.border = 'none';
		
				if(i < this.thumbURI.length)
				{
					img.setAttribute('src', this.thumbURI[i]);
				}
				else
				{
					img.setAttribute('src', this.blankImageURI);
				}
				img.setAttribute('alt','');
				if(this.thumbAlt)
				{
					img.setAttribute('title', this.thumbAlt[i]);
				}
				a = document.createElement("a");
				a.setAttribute('id', this.element + '_a' + i);
				a._ThumbViewer = this;
				if(i < this.thumbURI.length)
				{
					a.setAttribute('href', "javascript:tvdisplay('" + this.element + '_a' + i + "'," + i + ")");
				}

				if(this.thumbout)
				{
					a.setAttribute('onmouseout', "tvthumbout('" + this.element + '_a' + i + "'," + i + ")");
				}
				
				if(this.thumbover)
				{
					a.setAttribute('onmouseover', "tvthumbover('" + this.element + '_a' + i + "'," + i + ")");
				}
				
				a.setAttribute('class', this.acss);
				if(this.acss != 'photo')
				{
					a.style.cursor = 'url(/images/zoomcursorin.cur), pointer, default';
				}
				a.appendChild(img);
		
				idiv.appendChild(a);
				
				if(this.caption)
				{
					var p = document.createElement("p");
					p.innerHTML = this.caption[i];
					idiv.appendChild(p);
				}

				tvdiv.appendChild(idiv);

				if(this.shadow !== null && i < this.thumbURI.length)
				{
					idiv = document.createElement("div");
					idiv.setAttribute('id', this.element + '_shadow' + i);
					idiv.style.position = 'absolute';
					idiv.style.top = '0px';
					idiv.style.left = (i * (this.thumbSize + this.thumbPad)) + 'px';
					img = document.createElement("img");
					img.style.position = "absolute";
					img.style.top = "0px";
					img.style.left = "0px";
					if(this.shadoww)
					{
						img.style.width = this.shadoww[i] + "px";
					}
					
					if(this.shadowh)
					{
						img.style.height = this.shadowh[i] + "px";
					}
					
					img.style.zIndex = "400000";
					img.setAttribute('src', this.shadow);
					idiv.appendChild(img);
					tvdiv.appendChild(idiv);
				}
			}

			idiv = document.createElement("div");
			idiv.setAttribute('id', this.element + '_div_next');
			idiv.style.position = 'absolute';
			idiv.style.top = '0px';
			idiv.style.left = (tvwidth + this.widthArrow + (2 * this.thumbPad)) + 'px';
		
			img = document.createElement("img");
			img.setAttribute('class', this.arrowcss.length === 0 ? 'photo' : this.arrowcss);
			img.setAttribute('id', this.element + '_next');
			img.style.border = 'none';
			img.setAttribute('src',
				this.thumbURI.length > this.thumbSlots ? this.arrowNextOn : this.arrowNextOff);
	
			if(this.thumbURI.length > this.thumbSlots)
			{
				a = document.createElement("a");
				a._ThumbViewer = this;
				a.setAttribute('id', this.element + '_a_next');
				a.setAttribute('href', "javascript:tvslideright('" + this.element + "_a_next');");
				a.setAttribute('class', 'photo');
				a.appendChild(img);
				
				idiv.appendChild(a);
			}
			else
			{
				idiv.appendChild(img);
			}
			wdiv.appendChild(idiv);
		}
	
		var e = ge(this.element);
		e.appendChild(wdiv);

		if(InternetExploderFive || InternetExploderSix)
		{
			$("a").focus(function() { this.blur(); });
		}
	};
	
	this.getImage = function(i)
	{
		return('#' + this.element + '_img' + i);
	};
	
	this.setDisplayCallback = function(n)
	{
		this.displayCallback = n;
	};

	this.display = function(n)
	{
		if(typeof(this.displayCallback) == 'function')
		{
			this.displayCallback(this, n);
		}
	};

	this.slideright = function()
	{
		if(this.curleft + this.thumbSlots >= this.thumbURI.length)
		{
			return;
		}
		
		this.curleft += this.thumbSlots;
		this.slide();
	};

	this.slideleft = function()
	{
		if(this.curleft === 0)
		{
			return;
		}
		
		this.curleft -= this.thumbSlots;
		this.slide();
	};

	this.slide = function()
	{
		var a;
		var i;
		var div;
		var img;

		var newx = - this.curleft * (this.thumbSize + this.thumbPad);
		$('#' + this.element + '_scroller').animate({ left: newx}, 400, "linear");
	
		if(this.thumbURI.length > this.thumbSlots)
		{
			img = ge(this.element + '_next');
			if(this.thumbSlots + this.curleft >= this.thumbURI.length)
			{
				a = ge(this.element + '_a_next');
				a.style.cursor = 'default';
				a.removeAttribute('href');
				img.src = this.arrowNextOff;
			}
			else
			{
				a = ge(this.element + '_a_next');
				a.style.cursor = 'pointer';
				a.setAttribute('href', "javascript:tvslideright('" + this.element + "_a_next');");
				img.src = this.arrowNextOn;
			}

			img = ge(this.element + '_prev');
			if(this.curleft === 0)
			{
				a = ge(this.element + '_a_prev');
				a.style.cursor = 'default';
				a.removeAttribute('href');
				img.src = this.arrowPrevOff;
			}
			else
			{
				a = ge(this.element + '_a_prev');
				a.style.cursor = 'pointer';
				a.setAttribute('href', "javascript:tvslideleft('" + this.element + "_a_prev');");
				img.src = this.arrowPrevOn;
			}
		}
	};

	this.slider = function()
	{
		var a;
		var i;
		var img;
	
		for(i = 0; i < this.thumbSlots; i++)
		{
			img = ge(this.element + "_img" + i);
			if(i < this.thumbURI.length)
			{
				img.src = this.thumbURI[i + this.curleft];
		 	}
			else
			{
				img.src = this.blankImageURI;
			}
		}
	
		if(this.thumbURI.length > this.thumbSlots)
		{
			img = ge(this.element + '_next');
			if(this.thumbSlots + this.curleft >= this.thumbURI.length)
			{
				a = ge(this.element + '_a_next');
				a.style.cursor = 'default';
				a.removeAttribute('href');
				img.src = this.arrowNextOff;
			}
			else
			{
				a = ge(this.element + '_a_next');
				a.style.cursor = 'pointer';
				a.setAttribute('href', "javascript:tvslideright('" + this.element + "_a_next');");
				img.src = this.arrowNextOn;
			}

			img = ge(this.element + '_prev');
			if(this.curleft === 0)
			{
				a = ge(this.element + '_a_prev');
				a.style.cursor = 'default';
				a.removeAttribute('href');
				img.src = this.arrowPrevOff;
			}
			else
			{
				a = ge(this.element + '_a_prev');
				a.style.cursor = 'pointer';
				a.setAttribute('href', "javascript:tvslideleft('" + this.element + "_a_prev');");
				img.src = this.arrowPrevOn;
			}
		}
	};
}

function tvdisplay(e, n)
{
	e = ge(e);
	var tv = e._ThumbViewer;
	tv.display(n);
}

function tvslideright(e)
{
	e = ge(e);
	var tv = e._ThumbViewer;
	tv.slideright();
}

function tvthumbover(e, n)
{
	e = ge(e);
	var tv = e._ThumbViewer;
	tv.thumbover(tv, n + tv.curleft);
}

function tvthumbout(e, n)
{
	e = ge(e);
	var tv = e._ThumbViewer;
	tv.thumbout(tv, n + tv.curleft);
}

function tvslideleft(e)
{
	e = ge(e);
	var tv = e._ThumbViewer;
	tv.slideleft();
}

var modalctr = 0;

function modalMessage(title, msg, width)
{
	msg = msg + '<div class="button"><a class="button" href="javascript:modalClose()"><span>Close</span></a></div>';
	modalctr += 1;
	var id = "modalmsg" + modalctr;
	modalDialog(title, msg, width, id, null);
}

function modalDialog(title, msg, width, id, closefunc)
{
	if(closefunc === null)
	{
		closefunc = "modalClose()";
	}
	
	if(ge(id))
	{
		ge(id + "msg").innerHTML = msg;
		modalElement(id);
	}
	else
	{
		var html = new Array();

		html.push('<table class="rc" id="' + id + '" cellpadding="0" cellspacing="0">');
		html.push('<tr>');
		html.push('<td class="rctl"></td>');
		html.push('<td class="rctop" style="width: ' + width + 'px;"><table class="bare" cellspacing="0" cellpadding="0"><tr><td style="width: ' + width + 'px;">' + title + '</td><td style="text-align: right; width: 27px;">');
		if(closefunc != 'NoClOsE')
			html.push('<a class="titlelink"  href="javascript:' + closefunc + '">X</a>');
		html.push('</td></tr></table></td>');
		html.push('<td class="rctr"></td>');
		html.push('</tr>');
		html.push('<tr>');
		html.push('<td class="rcl"></td>');
		html.push('<td class="rcmid" id="' + id + 'msg" style="width: ' + width + 'px;">');
		html.push(msg);
	
		html.push('</td>');
		html.push('<td class="rcr"></td>');
		html.push('</tr>');
		html.push('<tr>');
		html.push('<td class="rcbl"></td>');
		html.push('<td class="rcbot"></td>');
		html.push('<td class="rcbr"></td>');
		html.push('</tr>');
		html.push('</table>');
		modalContent(html.join(''));
	}
}

function modalBackdrop(state)
{
	var modalbg = ge("modalbg");
	if(modalbg === null)
	{
		modalbg = document.createElement("div");
		modalbg.setAttribute('id', 'modalbg');
		document.body.appendChild(modalbg);
	}
	
	modalbg.style.display = 'block';
	modalbg.style.height = $(document).height() + "px";
}

function modalContent(s)
{
	var modal = modalDiv();
	if(modal.style.display == 'block')
	{
		window.setTimeout("modalContent('" + escape(s) + "')", 50);
		return;
	}
	
	modalReplaceContent(s);
}

function modalReplaceContent(s)
{
	var modal = modalDiv();
	s = unescape(s);
	modal.innerHTML = s;
	modal.style.display = 'block';
	if(typeof(pngifyTable) == 'function')
	{
		$("table", modal).each(function() { pngifyTable(this); });
	}
		
	modalCenter();
	modalBackdrop();
	hardenButtons();
	$("select").css("display","none");
}

function modalElement(id)
{
	var modal = modalDiv();
	if(modal.style.display == 'block' && modal.childNodes[0].id != id)
	{
		window.setTimeout("modalElement('" + id + "')", 50);
		return;
	}
	
	if(modal.childNodes[0].id != id)
	{
		modal.innerHTML = "";
		modal.appendChild(ge(id));
	}
	
	modal.style.display = 'block';
	modalCenter();
	modalBackdrop();
	hardenButtons();
}

function modalDiv()
{
	var modal = ge("modal");
	if(modal === null)
	{
		modal = document.createElement("div");
		modal.setAttribute('id', 'modal');
		document.body.appendChild(modal);
	}
	
	return(modal);
}

function modalCenter()
{
	var modal = ge("modal");
	var top = centerVertically(modal.clientHeight);
	if(top < 10)
	{
		top = 10;
	}
	
	modal.style.top = top + "px";
	modal.style.left = centerHorizontally(modal.clientWidth) + "px";
}
	
function modalHide()
{
	if(ge("modal"))
	{
		ge("modal").style.display = 'none';
	}
}

function modalClose()
{
	if(ge("modalbg"))
	{
		ge("modalbg").style.display = 'none';
	}
	
	if(ge("modal"))
	{
		ge("modal").style.display = 'none';
		ge("modal").innerHTML = '';
	}
	$("select").css("display","inline");
}

function bde(id, display, top, left, height, width, boffx, boffy, repeat)
{
	var img;
	var e = ge(id);
	
	if(display == "none")
	{
		if(e)
		{
			e.style.display = "none";
		}
		return;
	}
	
	if(e === null)
	{
		e = document.createElement("div");
		e.setAttribute('id', id);
		e.style.position = "absolute";
		e.style.zIndex = 950400;
		
		if(InternetExploderFive || InternetExploderSix)
		{
			img = document.createElement("img");
			img.src = "/images/" + id + ".png";
			img.setAttribute('id', id + 'png');
			img.style.width = width + "px";
			img.style.height = height + "px";
			el_fnFixPng(img);
			e.appendChild(img);
		}
		else
		{
			e.style.backgroundImage = "url('/images/dropshadow.png')";
			e.style.backgroundRepeat = repeat;
			e.style.backgroundPosition = (boffx === 0 ? "" : "-") + boffx + "px " + (boffy === 0 ? "" : "-") + boffy + "px"; 
		}

		document.body.appendChild(e);
	}

	e.style.top = top + "px";
	e.style.left = left + "px";
	e.style.width = width + "px";
	e.style.height = height + "px";
	if(InternetExploderFive || InternetExploderSix)
	{
		img = ge(id + "png");
		img.style.width = width + "px";
		img.style.height = height + "px";
	}
	
	e.style.display = display;
}

var zswapimg;

function Zdisplay(tv, imgno)
{
	var zoomer = tv.Zoomer;

	zoomer.cbtv = tv;
	zoomer.cbimgno = imgno;
	zoomer.imgno = imgno;
	zoomer.renderCaption();
	
	$("#zoomer").attr('src', zoomer.smURI[imgno]);
	$("#zoomer").attr('src', zoomer.zmURI[imgno]);
}

function Zoomer()
{
	this.gallery = false;
	this.gallerycb = null;
	
	this.zoomgallery = function(tv, imgid, imgno, smURI, zmURI, width, height, caption, by)
	{
		this.gallery = true;
		this.smURI = smURI;
		this.zmURI = zmURI;
		this.displayed = new Array();
		this.displayed[imgno] = true;
		this.width = width;
		this.height = height;
		this.imgno = imgno;
		
		this.tv = tv.clone("zoomertv");

		var profile = siteprofile[siteid];

		this.tv.shadow = profile.gvShadow;
		if(profile.ident == 'fl')
		{
			this.tv.arrowPrevOff = '/images/warrowprevoff.png';
			this.tv.arrowPrevOn =  '/images/warrowprevon.png';
			this.tv.arrowNextOff = '/images/warrownextoff.png';
			this.tv.arrowNextOn =  '/images/warrownexton.png';	
		}
		
		this.tv.original = tv;
		var div = ge("zoomertv");
		if(div === null)
		{
			div = document.createElement("div");
			div.setAttribute('id', "zoomertv");
			div.style.position = "absolute";
			div.style.display = "none";
			div.style.zIndex = 950400;
			div.style.background = "#fff";
			div.style.padding = "11px";
			div.style.width = (width - 22) + "px";
			div.style.height = this.tv.thumbSize + "px";
			document.body.appendChild(div);
		}
		
		$("#zoomertv").html('');
		
		this.tv.displayCallback = Zdisplay;
		this.tv.thumbSlots = 8;
		this.tv.generate();
		
		this.tv.Zoomer = this;
		this.caption = caption;
		this.by = by;
		
		this.zoom(imgid, this.smURI[imgno], this.zmURI[imgno], width, height);
	};
	
	this.zoom = function(imgid, src1, src2, width, height)
	{
		this.imgheight = height;
		this.imgwidth = width;

		var img = ge(imgid.substr(1));
		this.zoomedimg = img;
		this.zoomedimgid = imgid;
		this.dimensions = new Object;
		this.dimensions.width = $(imgid).width();
		this.dimensions.height = $(imgid).height();

		var top = findTopCoord(img);
		var left = findLeftCoord(img);
		var a;
		
		img = ge("zoomercl");
		if(img === null)
		{
			img = document.createElement("img");
			img.style.display = "none";
			img.Zoomer = this;
			img.setAttribute('src', '/images/close.png');
			img.setAttribute('id', 'zoomercl');

			img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/close.png', sizingMethod='crop');";
			img.style.zIndex = "950600";
			img.style.position = "absolute";
			img.style.width = "52px";
			img.style.height = "52px";
			img.style.border = "none";
			el_fnFixPng(img);
			a = document.createElement("a");
			a.appendChild(img);
			a.setAttribute('href', "javascript:zoomerCloseZoom()");
			a.style.cursor = "url('/images/zoomcursorout.cur'), pointer";
			document.body.appendChild(a);
		}		
	
		img = ge("zoomer");
		if(img === null)
		{
			img = document.createElement("img");
			img.setAttribute('id', 'zoomer');
			img.setAttribute('class', 'zphoto');
			img.style.display = "none";
			a = document.createElement("a");
			a.appendChild(img);
			a.setAttribute('href', "javascript:zoomerCloseZoom()");
			a.setAttribute('class', 'zphoto');
			a.style.cursor = "url('/images/zoomcursorout.cur'), pointer";
			document.body.appendChild(a);
		}
	
		img.Zoomer = this;
		img.setAttribute('src', '/images/invisodot.gif');
		img.setAttribute('src', src1);
		img.style.position = "absolute";
		img.style.top = top + "px";
		img.style.left = left + "px";
		img.style.width = this.dimensions.width + 'px';
		img.style.height = this.dimensions.height + 'px';
		img.style.border = "none";
		img.style.display = "block";
		img.style.zIndex = "950500";
		var totop = centerVertically(height);
		if(totop < 26)
		{
			totop = 26;
		}
		$("#zoomer").animate({ width: this.imgwidth + "px", height: this.imgheight + "px",
							   top: totop + "px", left: centerHorizontally(width) + "px"}, 150, "swing", this.backdropZoom);
		zswapimg = src2;
		if(Gecko && Macintosh)
		{
			$(".zphoto").each(function(i) { this.style.cursor = "-moz-zoom-out"; });
		}
	};

	this.backdropZoom = function()
	{
		modalBackdrop();
	
		var img = ge("zoomer");
		img.style.width = img.Zoomer.imgwidth + "px";
		img.style.height = img.Zoomer.imgheight + "px";
		img.src = zswapimg;

		var width = $("#zoomer").width();
		var height = $("#zoomer").height();

		var totop = centerVertically(height);
		if(totop < 26)
		{
			totop = 26;
		}
		
		var toleft = centerHorizontally(width);
		img = ge("zoomercl");
		img.style.top = (totop - 26) + "px";
		img.style.left = (toleft + width - 26) + "px";
		img.style.display = "block";
		
		if(this.Zoomer.gallery)
			height += 22 + this.Zoomer.tv.thumbSize;

		bde("zbdtl", "block", totop - 20, toleft - 20, 40, 40, 0, 0, "no-repeat");
		bde("zbdt", "block", totop - 20, toleft + 20, 20, width - 40, 0, 80, "repeat-x");
		bde("zbdtr", "block", totop - 20, toleft + width - 20, 40, 40, 40, 0, "no-repeat");
		bde("zbdl", "block", totop + 20, toleft - 20, height - 40, 20, 0, 120, "repeat-y");
		bde("zbdr", "block", totop + 20, toleft + width, height - 40, 20, 60, 120, "repeat-y");
		bde("zbdbr", "block", totop + height - 20, toleft - 20, 40, 40, 0, 40, "no-repeat");
		bde("zbdb", "block", totop + height, toleft + 20, 20, width - 40, 40, 100, "repeat-x");
		bde("zbdbl", "block", totop + height - 20, toleft + width - 20, 40, 40, 40, 40, "no-repeat");

		if(this.Zoomer.gallery)
		{
			$("#zoomertv").css({ 'top' : (totop + height - 22 - this.Zoomer.tv.thumbSize) + "px",
								 'left' : toleft + "px",
								 'display' : "block" });
		}

		this.Zoomer.renderCaption();
	};

	this.renderCaption = function()
	{
		var captioned = 0;
		if(this.caption)
		{
			if(this.caption[this.imgno])
			{
				var width = $("#zoomer").width();
				var height = $("#zoomer").height();
				var totop = centerVertically(height);
				if(totop < 26)
				{
					totop = 26;
				}
		
				var toleft = centerHorizontally(width);

				var div = ge("zoomercaption");
				if(div === null)
				{
					div = document.createElement("div");
					div.setAttribute('id', "zoomercaption");
	//				div.style.background = "#000";
	//				div.style.opacity = .60;
	//				div.style.filter = "alpha(opacity=60)";
					div.style.background = "transparent";
					div.style.width = "px";
					div.style.height = "54px";
					div.style.fontFamily = "arial, helvetica, sans-serif";
					div.style.fontSize = "9pt";
					div.style.textAlign = "center";
	//				div.style.color = "#eee";
					div.style.position = "absolute";
					div.style.zIndex = "950600";
					document.body.appendChild(div);
				}
			
				div.style.top = (totop + height - 54) + "px";
				div.style.left = toleft + "px";
				var html = '<div style="position: absolute; bottom: 0; background: #000; width: ' + width + 'px; color: #eee; opacity: 0.6; filter: alpha(opacity=60);">';
				html += '<p style="opacity: 1; filter: alpha(opacity=100); margin: 5px;">' +
						   this.caption[this.imgno] + '</p>';
				html += '<p style="opacity: 1; filter: alpha(opacity=100); margin: 5px;">Submitted by <b>' + this.by[this.imgno] + '</p></div>';
				$("#zoomercaption").html(html);
				$("#zoomercaption").css({ 'display' : 'block' });
				captioned = 1;
			}
		}
		
		if(! captioned)
		{
			$("#zoomercaption").css({ 'display' : 'none' });
		}
	}
	
	this.closeZoom = function()
	{
		ge("zoomercl").style.display = "none";
		ge("zbdtl").style.display = "none";
		ge("zbdt").style.display = "none";
		ge("zbdtr").style.display = "none";
		ge("zbdl").style.display = "none";
		ge("zbdr").style.display = "none";
		ge("zbdbr").style.display = "none";
		ge("zbdb").style.display = "none";
		ge("zbdbl").style.display = "none";
		$("#zoomertv").css({ 'display' : 'none' });
		$("#zoomercaption").css({ 'display' : 'none' });
		modalClose();
		
		var img = ge("zoomer");

		var offset = $(this.zoomedimgid).offset();
		var width = $(this.zoomedimgid).width();
		var height = $(this.zoomedimgid).height();

		$("#zoomer").animate({ width: width + "px", height: height + "px",
							   top: offset.top + "px", left: offset.left + "px"}, 150, "swing", this.completeCloseZoom);
		this.gallery = null;

	};

	this.completeCloseZoom = function()
	{
		var zoomer = ge("zoomercl").Zoomer;
	
		if(typeof(zoomer.gallerycb) == 'function')
		{
			zoomer.gallerycb(zoomer.cbtv, zoomer.cbimgno);
		}

		ge("zoomer").style.display = "none";
	};
	
	this.setGalleryCallback = function(n)
	{
		this.gallerycb = n;
	}
}

function zoomerCloseZoom()
{
	ge("zoomercl").Zoomer.closeZoom();
}

function el_fnFixPng(img)
{
	if(InternetExploderFive || InternetExploderSix)
	{
		var src = img.src;
		img.style.width = img.width + "px";
		img.style.height = img.height + "px";
		img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
		img.src = '/etc/x.gif';
	}
}

function limitChars(textid, limit, infodiv)
{
	var text = $('#' + textid).val(); 
	var textlength = text.length;
	if(textlength > limit)
	{
		$('#' + infodiv).html('0 characters remaining');
		$('#'+textid).val(text.substr(0,limit));
		return false;
	}
	else
	{
		$('#' + infodiv).html((limit - textlength) +' characters remaining');
		return true;
	}
}
