//textile_effects.js

function ElementDimensions(elem)
{
	this.width = elem.offsetWidth;
	this.height = elem.offsetHeight;
	var tmp = elem;
	this.left = this.top = 0;
	while(tmp.offsetParent)
	{
		this.left += tmp.offsetLeft;
		this.top += tmp.offsetTop;
		tmp = tmp.offsetParent;
	}
}

var grid_alpha_div = null;

function hovertext(elem, id, name, lgpic, caption, clr)
{
	if(grid_alpha_div == null)
		grid_alpha_div = document.getElementById('grid_alpha_div');
	
	grid_alpha_div.appendChild(document.createTextNode(id));
	grid_alpha_div.appendChild(document.createElement('br'));
	var n = document.createElement('span');
	n.className = 'swatchname';
	n.appendChild(document.createTextNode(name));
	grid_alpha_div.appendChild(n);
	var ED = new ElementDimensions(elem);
	
	grid_alpha_div.style.left = ED.left + 'px';
	grid_alpha_div.style.top = ED.top + 'px';
	grid_alpha_div.style.height = ED.height + 'px';
	grid_alpha_div.style.width = ED.width + 'px';
	grid_alpha_div.style.display = 'block';
	
	grid_alpha_div.onmouseout = unhovertext;
	grid_alpha_div.onclick = new Function("document.getElementById('LargePic').src='" + lgpic + "';show_caption('" + caption + "','" + clr + "');");
}
function unhovertext()
{
	grid_alpha_div.style.display = 'none';
	while(grid_alpha_div.hasChildNodes())
	{
		grid_alpha_div.removeChild(grid_alpha_div.firstChild);
	}
}

function show_caption(caption, clr)
{
	var elem = document.getElementById('PicCaption');
	while(elem.hasChildNodes())
		elem.removeChild(elem.firstChild);
	elem.appendChild(document.createTextNode(caption));
	elem.style.display = 'block';
	elem.style.color = clr;
}
