/*
	Forum functions
*/
function subforum(id, show)
{
	if (show)
	{
		myid = document.getElementById('s' + id + 'b');
		myid.style.display = 'block';
		s = (String(myid.getAttribute('active')) == '1') ? '-a' : '';
		document.getElementById('s' + id).innerHTML = '<span onClick="subforum('+id+',0);"><img src="theme/images/min'+s+'.gif"> <strong>Subforums inklappen</strong></span>';
		document.cookie = 'subforum'+id+'=1';
	}
	else
	{
		myid = document.getElementById('s' + id + 'b');
		myid.style.display = 'none';
		s = (String(myid.getAttribute('active')) == '1') ? '-a' : '';
		document.getElementById('s' + id).innerHTML = '<span onClick="subforum('+id+',1);"><img src="theme/images/plus'+s+'.gif"> <strong>Subforums uitklappen</strong></span>';
		document.cookie = 'subforum'+id+'=0';
	}
}

var imgsizes=new Array();
var imgsizes_ex=new Array();
var imgex=new Array();

function zoomimg(id,zm) {
	embedimg=document.getElementById('embedimg' + id);
	w=embedimg.width;
	h=embedimg.height;

	if(imgsizes.length<id)
		imgsizes[id]=[w,h];
	else {
		if(!imgsizes[id]) imgsizes[id]=[w,h];
	}

	if(zm>0) {
		embedimg.width=w*zm;
		embedimg.height=h*zm;
		expandimg(id,3);
	} else {
		embedimg.width=imgsizes[id][0];
		embedimg.height=imgsizes[id][1];
		expandimg(id,3);
	}
}

function imgcontrol(id)
{
	control=document.getElementById('imgctr' + id);
	embedimg=document.getElementById('embedimg' + id);
	imgcontain=document.getElementById('imgcontain' + id);

	w=embedimg.width;
	h=embedimg.height;

	if (!w)
		return;

	if ((w > 300 && h > 150) || w > 500)
	{
		if (w > 580)
		{
			zoomimg(id, 580/w);
		}
	}
	else
	{
		control.style.display = 'none';
		imgcontain.style.overflow = 'visible';
	}
}

function expandimg(id, flag)
{
	imgcontain=document.getElementById('imgcontain' + id);
	embedimg=document.getElementById('embedimg' + id);
	spacer=document.getElementById('spacer' + id);

	if(flag==2)	if(imgcontain.style.position=='absolute') { flag=0 } else { flag=1 };
	if(flag==3)	if(imgcontain.style.position=='absolute') { flag=1 } else { flag=0 };

	w=embedimg.width;
	h=embedimg.height;

	if(imgsizes.length<id)
		imgsizes[id]=[w,h];
	else {
		if(!imgsizes[id]) imgsizes[id]=[w,h];
	}

	if(w>0) {
		if(flag==1) {
			if(w>580 || imgsizes[id][0] > 580)
			{
				imgex[id] = 1;
				imgsizes_ex[id]=[w,h];

				if (w < imgsizes[id][0])
				{
					w=imgsizes[id][0];
					h=imgsizes[id][1];
					embedimg.width = w;
					embedimg.height = h;
				}
				midpoint=540-Math.round(w/2);
				if(midpoint<10)  midpoint=10;

/*				if(ismsie) {
					imgcontain.style.width=w+4;
				} else {
					imgcontain.style.width=w;
				}
*/
				imgcontain.style.position='absolute';
				imgcontain.style.width=w;
				imgcontain.style.left= midpoint+'px';
				imgcontain.style.overflow='visible';
				spacer.height=h+4;
			} else {
				imgcontain.style.width=580;
				imgcontain.style.position='static';
				imgcontain.style.overflow='auto';
				spacer.height=1;
			}
		} else {
			imgcontain.style.width=580;
			imgcontain.style.position='static';
			imgcontain.style.overflow='auto';
			spacer.height=1;
			if (imgex[id])
			{
				imgex[id] = 0;
				embedimg.width = imgsizes_ex[id][0];
				embedimg.height = imgsizes_ex[id][1];
			}
		}
	}
}
