function getElementsByClass(searchClass,node,tag) 
{
	var classElements = new Array();
		if ( node == null )
	node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++)
	{
		if ( pattern.test(els[i].className) )
		{
		classElements[j] = els[i];
		j++;
		}
	}
return classElements;
}


function swapImage(preview, fullsize, box, caption)
{ 
// switch all off
var boxList = getElementsByClass('boxy', null, 'a');
for (var i=0; i<boxList.length; i++)
	{
		if (boxList[i].id == box)
		{
			var boxClass = document.getElementById(box);
			boxClass.setAttribute((document.all ? 'className' : 'class'), 'active boxy');
		}
		else
		{
			var boxString = boxList[i].id;
			var boxClass = document.getElementById(boxString);
			boxClass.setAttribute((document.all ? 'className' : 'class'), 'inactive boxy');
		}
	}
// change link to big image
var hrefTag = document.getElementById('zoom');
hrefTag.setAttribute('href', fullsize);
hrefTag.setAttribute('title', caption);
// switch preview
var imgTag = document.getElementById('prod_img');
imgTag.src = preview;

return(false);
}

function hideCurrent()
{
	var obj = document.getElementById('current');
	obj.setAttribute((document.all ? 'className' : 'class'), '');
}
function showCurrent()
{
	var obj = document.getElementById('current');
	obj.setAttribute((document.all ? 'className' : 'class'), 'active');
}

function onBlurField(elem, str)
{
	if (!elem.value)
	{
		elem.value = str;
	}
}
function onFocusField(elem, str)
{
	if (elem.value == str)
	{
		elem.value = '';
	}
}
function refreshDiv(name)
{
		changeOpac(0, name);
		opacity(name, 0, 100, 300);	
}
function opacity(id, opacStart, opacEnd, millisec) {
			
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "', 'out')",(timer * speed));
			timer++;

		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "', 'in')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id, way) {
	
	if(document.getElementById(id).style.opacity == 0.01)
	{
		if(way == 'out')
		{
			document.getElementById(id).style.display = 'none';
		}
	}
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}