/*******************************************************************
 * Copyright: Sander Internetoplossingen                           *
 * By: Roel van Nuland                                             *
 *******************************************************************
 * Description: Creates list of thumbs that can switch to a bigone *
 * Version: v0.1                                                   *
 *******************************************************************/

function CreatePhotolist()
{
	var currentidx = 0;

	var photolistcontainer = document.getElementById( photosdivname );
	if (photolistcontainer)
	{
		// Create div
		var divthumbslist = document.createElement( 'div' );
		divthumbslist.id = 'thumbslist';

		// Create thumb divs
		for ( var idx in thumbslist )
		{
			divthumbs[idx] = document.createElement( 'div' );
			if (idx == currentidx)
			{
				divthumbs[idx].className = 'thumbactive';
			}
			else
			{
				divthumbs[idx].className = 'thumb';
			}

			// Create image inside thumb divs
			divimg = document.createElement( 'img' );
			divimg.src = imagepath+thumbslist[idx];

			// Add image to thumb div
			divthumbs[idx].appendChild( divimg );

			// Add mouseover event to thumb div
			divthumbs[idx].onmouseover = new Function("onThumbImageOver('"+idx+"')");

			// Add thumb div to thumblist div
			divthumbslist.appendChild( divthumbs[idx] );
		}

		// Create float div
		var floatit = document.createElement( 'br' );
		floatit.className = 'clear';

		// Create bigimg div
		var divbigimg = document.createElement( 'div' );
		divbigimg.id = 'bigimage';

		// Create image inside thumb divs
		imgbigimgage = document.createElement( 'img' );
		imgbigimgage.src = imagepath+photoslist[currentidx];

		// Add img to divbigimg
		divbigimg.appendChild( imgbigimgage );

		// Add divs to container
		photolistcontainer.appendChild( divbigimg );
		photolistcontainer.appendChild( floatit );
		photolistcontainer.appendChild( divthumbslist );

		// Done!
	}
	else
	{
		alert( 'Could not find photolist container! ('+photosdivname+')' );
	}
}

function onThumbImageOver( idxImage )
{
	// Create thumb divs
	for ( var idx in thumbslist )
	{
		if ( idx == idxImage )
		{
			divthumbs[idx].className = 'thumbactive';
		}
		else
		{
			divthumbs[idx].className = 'thumb';
		}
	}

	if (imgbigimgage)
	{
		imgbigimgage.src = imagepath+photoslist[idxImage];
	}
}

