// Vars needed to display the full text of a caption


/**
 * Displays the full text of a caption with a shadow border.
 * 
 * @param element e
 * @return void
 */
function displayFullText (e) {
	var fullText = $('fulltxt' + e.id.substring(e.id.indexOf('_'))).value;
	var b = null;
	var t = null;
	var borderadjust = 2;
	var cw = e.clientWidth;
	if (!window.fullTextBlurbContainer) {
		b = window.fullTextBlurbContainer = ce('div');
		b.style.border = 'solid 1px #000';
		ac(document.body,b);
		t = window.fullTextBlurb = ce('div');
		t.style.background = '#E7D6B1 repeat';
		t.style.padding = borderadjust + 'px';
//		t.style.border = 'solid 1px #000000';
		t.style.width = cw + 'px';
		
		var sd = '21px';
		
//		// TOP SHADOW
//		var top = ce('div');
//		ac(b,top);
//		top.style.height = sd;
//		top.style.width = '100%';
//		
//		var s = ce('div');
//		ac(top,s);
//		s.style.background = 'url("/images/template/fade_tl.png")';
//		s.style.width = sd;
//		s.style.height = sd;
//		
//		s = ce('div');
//		ac(top,s);
//		b.stretchx = [s];
//		s.style.height = sd;
//		s.style.background = 'url("/images/template/fade_t.png") repeat-x';
//		
//		s = ce('div');
//		ac(top,s);
//		s.style.background = 'url("/images/template/fade_tr.png")';
//		s.style.width = sd;
//		s.style.height = sd;
		
		// SIDE SHADOWS
		var mid = ce('div');
		ac(b,mid);
//		mid.style.height = sd;
//		mid.style.width = '100%';
//		
//		s = ce('div');
//		ac(mid,s);
//		s.style.background = 'url("/images/template/fade_l.png")';
//		s.style.width = sd;
//		s.style.height = '100%';
//		b.stretchy = [s];
		
		ac(mid,t);
		
//		s = ce('div');
//		ac(mid,s);
//		s.style.background = 'url("/images/template/fade_r.png")';
//		s.style.width = sd;
//		s.style.height = '100%';
//		b.stretchy.push(s);
		
//		// BOTTOM SHADOW
//		var bot = ce('div');
//		ac(b,bot);
//		b.botredraw = bot;
//		bot.style.height = sd;
//		bot.style.width = '100%';
//		
//		s = ce('div');
//		ac(bot,s);
//		s.style.background = 'url("/images/template/fade_bl.png")';
//		s.style.width = sd;
//		s.style.height = sd;
//		
//		s = ce('div');
//		ac(bot,s);
//		b.stretchx.push(s);
//		s.style.height = sd;
//		s.style.background = 'url("/images/template/fade_b.png") repeat-x';
//		
//		s = ce('div');
//		ac(bot,s);
//		s.style.background = 'url("/images/template/fade_br.png")';
//		s.style.width = sd;
//		s.style.height = sd;
		
		// Set element attributes
//		t.style.padding = '21px';
		b.style.position = 'absolute';
		b.style.zIndex = '90000';
		//b.style.background = '#E7D6B1 repeat';
//		b.style.background = '#FFFFFF repeat';
		
		if (window.userAgent == 'IE6') {
			setFloatIE6(b, 'left');
		} else {
			setFloatFF(b, 'left');
		}
	} else {
		b = window.fullTextBlurbContainer;
		t = window.fullTextBlurb;
	}
	
	// Set text and draw boxes
	b.style.opacity = '0.01';
	b.style.filter = 'alpha(opacity=1)';
	b.style.display = 'block';
	t.innerHTML = fullText;
	
	// Set position
	var h = t.clientHeight + 1;
//	b.stretchx[0].style.width = (cw + 2 * borderadjust) + 'px';
//	b.stretchx[1].style.width = (cw + 2 * borderadjust) + 'px';
//	b.stretchy[0].style.height = h + 'px';
//	b.stretchy[1].style.height = h + 'px';
	var coords = [0,0];
	getCoords(e, coords);
	b.style.left = (coords[0] - 1 -borderadjust) + 'px';
	b.style.top = (coords[1] - 1 - borderadjust) + 'px';
//	b.botredraw.style.top = (h - 21) + 'px';
	
	// Bring into view
	b.style.opacity = '1';
	b.style.filter = 'alpha(opacity=100)';
	
	// Set observer method
	setTimeout(function () { document.onmousemove = function (event) {observeFullText(event, t);}}, 0);
}

function displayFullText_good (e) {
	var fullText = $('fulltxt' + e.id.substring(e.id.indexOf('_'))).value;
	var b = null;
	var t = null;
	var borderadjust = 2;
	var cw = e.clientWidth;
	if (!window.fullTextBlurbContainer) {
		b = window.fullTextBlurbContainer = ce('div');
		ac(document.body,b);
		t = window.fullTextBlurb = ce('div');
		t.style.background = '#E7D6B1 repeat';
		t.style.padding = borderadjust + 'px';
//		t.style.border = 'solid 1px #000000';
		t.style.width = cw + 'px';
		
		var sd = '21px';
		
		// TOP SHADOW
		var top = ce('div');
		ac(b,top);
		top.style.height = sd;
		top.style.width = '100%';
		
		var s = ce('div');
		ac(top,s);
		s.style.background = 'url("/images/template/fade_tl.png")';
		s.style.width = sd;
		s.style.height = sd;
		
		s = ce('div');
		ac(top,s);
		b.stretchx = [s];
		s.style.height = sd;
		s.style.background = 'url("/images/template/fade_t.png") repeat-x';
		
		s = ce('div');
		ac(top,s);
		s.style.background = 'url("/images/template/fade_tr.png")';
		s.style.width = sd;
		s.style.height = sd;
		
		// SIDE SHADOWS
		var mid = ce('div');
		ac(b,mid);
		mid.style.height = sd;
		mid.style.width = '100%';
		
		s = ce('div');
		ac(mid,s);
		s.style.background = 'url("/images/template/fade_l.png")';
		s.style.width = sd;
		s.style.height = '100%';
		b.stretchy = [s];
		
		ac(mid,t);
		
		s = ce('div');
		ac(mid,s);
		s.style.background = 'url("/images/template/fade_r.png")';
		s.style.width = sd;
		s.style.height = '100%';
		b.stretchy.push(s);
		
		// BOTTOM SHADOW
		var bot = ce('div');
		ac(b,bot);
		b.botredraw = bot;
		bot.style.height = sd;
		bot.style.width = '100%';
		
		s = ce('div');
		ac(bot,s);
		s.style.background = 'url("/images/template/fade_bl.png")';
		s.style.width = sd;
		s.style.height = sd;
		
		s = ce('div');
		ac(bot,s);
		b.stretchx.push(s);
		s.style.height = sd;
		s.style.background = 'url("/images/template/fade_b.png") repeat-x';
		
		s = ce('div');
		ac(bot,s);
		s.style.background = 'url("/images/template/fade_br.png")';
		s.style.width = sd;
		s.style.height = sd;
		
		// Set element attributes
//		t.style.padding = '21px';
		b.style.position = 'absolute';
		b.style.zIndex = '90000';
		//b.style.background = '#E7D6B1 repeat';
//		b.style.background = '#FFFFFF repeat';
		
		if (window.userAgent == 'IE6') {
			setFloatIE6(b, 'left');
		} else {
			setFloatFF(b, 'left');
		}
	} else {
		b = window.fullTextBlurbContainer;
		t = window.fullTextBlurb;
	}
	
	// Set text and draw boxes
	b.style.opacity = '0.01';
	b.style.filter = 'alpha(opacity=1)';
	b.style.display = 'block';
	t.innerHTML = fullText;
	
	// Set position
	var h = t.clientHeight + 1;
	b.stretchx[0].style.width = (cw + 2 * borderadjust) + 'px';
	b.stretchx[1].style.width = (cw + 2 * borderadjust) + 'px';
	b.stretchy[0].style.height = h + 'px';
	b.stretchy[1].style.height = h + 'px';
	var coords = [0,0];
	getCoords(e, coords);
	b.style.left = (coords[0] - 21 - borderadjust) + 'px';
	b.style.top = (coords[1] - 21 - borderadjust) + 'px';
	b.botredraw.style.top = (h - 21) + 'px';
	
	// Bring into view
	b.style.opacity = '1';
	b.style.filter = 'alpha(opacity=100)';
	
	// Set observer method
	setTimeout(function () { document.onmousemove = function (event) {observeFullText(event, t);}}, 0);
}

function displayFullText_old (e) {
	var fullText = $('fulltxt' + e.id.substring(e.id.indexOf('_'))).value;
	var b = null;
	var t = null;
	if (!window.fullTextBlurbContainer) {
		b = window.fullTextBlurbContainer = ce('div');
		t = window.fullTextBlurb = ce('div');
		t.style.display = 'table-cell';
		t.style.background = '#E7D6B1 repeat';
		t.style.border = 'solid 1px #000000';
		
		var sd = '21px';
		
		// TOP SHADOW
		var top = ce('div');
		ac(b,top);
		top.style.display = 'table-row';
		top.style.height = sd;
		top.style.width = '100%';
		
		var s = ce('div');
		ac(top,s);
		s.style.display = 'table-cell';
		s.style.background = 'url("/images/template/fade_tl.png")';
		s.style.width = sd;
		s.style.height = sd;
		
		s = ce('div');
		ac(top,s);
		s.style.display = 'table-cell';
		b.stretchx = [s];
		s.style.height = sd;
		s.style.background = 'url("/images/template/fade_t.png") repeat-x';
		
		s = ce('div');
		ac(top,s);
		s.style.display = 'table-cell';
		s.style.background = 'url("/images/template/fade_tr.png")';
		s.style.width = sd;
		s.style.height = sd;
		
		// SIDE SHADOWS
		var mid = ce('div');
		ac(b,mid);
		mid.style.display = 'table-row';
		mid.style.height = sd;
		mid.style.width = '100%';
		
		s = ce('div');
		ac(mid,s);
		s.style.display = 'table-cell';
		s.style.background = 'url("/images/template/fade_l.png")';
		s.style.width = sd;
		b.stretchy = [s];
		
		ac(mid,t);
		
		s = ce('div');
		ac(mid,s);
		s.style.display = 'table-cell';
		s.style.background = 'url("/images/template/fade_r.png")';
		s.style.width = sd;
		b.stretchy.push(s);
		
		// BOTTOM SHADOW
		var bot = ce('div');
		ac(b,bot);
		bot.style.display = 'table-row';
		bot.style.height = sd;
		bot.style.width = '100%';
		
		s = ce('div');
		ac(bot,s);
		s.style.display = 'table-cell';
		s.style.background = 'url("/images/template/fade_bl.png")';
		s.style.width = sd;
		s.style.height = sd;
		
		s = ce('div');
		ac(bot,s);
		s.style.display = 'table-cell';
		b.stretchx = [s];
		s.style.height = sd;
		s.style.background = 'url("/images/template/fade_b.png") repeat-x';
		
		s = ce('div');
		ac(bot,s);
		s.style.display = 'table-cell';
		s.style.background = 'url("/images/template/fade_br.png")';
		s.style.width = sd;
		s.style.height = sd;
		
		// Set element attributes
//		t.style.padding = '21px';
		b.style.position = 'absolute';
		b.style.zIndex = '90000';
		//b.style.background = '#E7D6B1 repeat';
//		b.style.background = '#FFFFFF repeat';
		ac(document.body,b);
	} else {
		b = window.fullTextBlurbContainer;
		t = window.fullTextBlurb;
	}
	
	// Set text and draw boxes
	b.style.opacity = '0.01';
	b.style.filter = 'alpha(opacity=1)';
	b.style.display = 'block';
	t.innerHTML = fullText;
	
	// Set position
	var cw = e.clientWidth;
	b.style.width = (cw + 42) + 'px';
	b.stretchx[0].style.width = cw + 'px';
	var coords = [0,0];
	getCoords(e, coords);
	b.style.left = (coords[0] - 21) + 'px';
	b.style.top = (coords[1] - 21) + 'px';
	
	// Bring into view
	b.style.opacity = '1';
	b.style.filter = 'alpha(opacity=100)';
}

function setFloatFF (ea, f) {
	ea.style.cssFloat = f;
	if (ea.childNodes) {
		for (var i = 0; i < ea.childNodes.length; ++i) {
			if (ea.childNodes[i].childNodes) {
				setFloatFF(ea.childNodes[i],f);
			}
		}
	}
}

function setFloatIE6 (ea, f) {
	ea.style.float = f;
	if (ea.childNodes) {
		for (var i = 0; i < ea.childNodes.length; ++i) {
			if (ea.childNodes[i].childNodes) {
				setFloatIE6(ea.childNodes[i],f);
			}
		}
	}
}

function observeFullText (event, parent) {
	event = window.event || event;
	var t = event.target || event.srcElement;
	if (!isIn(t, parent)) {
		document.onmousemove = null;
		window.fullTextBlurbContainer.style.display = 'none';
	}
}

function isIn (child, parent) {
	if (child == parent) {
		return true;
	}
	
	if (child == document.body) {
		return false;
	}
	
	return isIn(child.parentNode, parent);
}
