

function Picture( id, fileRef, source, caption, datum, title )
{
	this.Id	= id;
	this.FileRef = fileRef;
	this.Source = source;
	this.Caption = caption;
	this.Datum = datum;
	this.Title = title;

	// Preload
	this.Image	= new Image();
	this.Image.src = this.Source;
}


function prevPicture( showAlt ) {
	movePicture( currentPicture - 1, showAlt );
}

function nextPicture( showAlt ) {
	movePicture( currentPicture + 1, showAlt );
}




function movePicture( cnt, showAlt )
{
	if ( document.images && cnt >= 0 && cnt < images.length )
	{
		var img = document.getElementById( 'picArticle' );
		var nextPicTop = document.getElementById( 'picNextTop' );
		var nextPicBottom = document.getElementById( 'picNextBottom' );
		var prevPicTop = document.getElementById( 'picPrevTop' );
		var prevPicBottom = document.getElementById( 'picPrevBottom' );
		var caption	= document.getElementById( 'picCaption' );
		var title	= document.getElementById( 'picTitle' );
		var datum	= document.getElementById( 'picDate' );
		var positionTop = document.getElementById( 'picPosTop' );
		var positionBottom = document.getElementById( 'picPosBottom' );
		var source = document.getElementById( 'picSource' );
		var clear	= document.getElementById( 'picClear' );
		var setalt	= !(showAlt == false);
		
		if ( img != null && ((nextPicTop != null && prevPicTop != null) || (nextPicBottom != null && prevPicBottom != null)) )
		{
			var i = images[cnt];
			
			if ( i != null )
			{
				img.src = i.FileRef;
				
				if ( setalt ) img.alt = i.Caption;
				
				var hasSource = true;
				var hasCaption = true;
				
				if ( datum != null ) {
					if (i.Datum != null && i.Datum != "") {
						datum.innerHTML = "[" + i.Datum + "]";
						datum.style.display = "block";
					}
					else
						datum.style.display = "none";
				}
				
				if ( i.Caption != null && i.Caption != "" ) {
					caption.innerHTML = i.Caption;
					caption.style.display = "block";
				}
				else {
					caption.style.display	= "none";
					hasCaption				= false;
				}
					
				if ( title != null ) {
					if ( i.Title != null && i.Title != "" ) {
						title.innerHTML = i.Title;
						title.style.display = "block";
					}
					else
						title.style.display = "none";
				}
					
				if ( i.Source != null && i.Source != "" ) {
					source.innerHTML = i.Source;
					source.style.display = "block";
				}
				else {
					source.style.display = "none";
					hasSource			= false;
				}
				
				if ( clear != null ) {	
					if ( hasSource || hasCaption )
						clear.style.display = "block";
					else
						clear.style.display = "none";
				}
				
				if (positionTop != null && nextPicTop != null && prevPicTop != null)
				{
					positionTop.innerHTML = "foto " + (cnt + 1) + " van " + images.length;
					if ( cnt == (images.length - 1) )
					{
						nextPicTop.style.display = "none";
					}
					else
					{
						nextPicTop.style.display = "block";
					}
					
					if ( cnt == 0 )
					{
						prevPicTop.style.display = "none";
					}
					else
					{
						prevPicTop.style.display = "block";
					}
				}
				if (positionBottom != null && nextPicBottom != null && prevPicBottom != null)
				{
//					alert('bottom');
					positionBottom.innerHTML = "foto " + (cnt + 1) + " van " + images.length;
				
					if ( cnt == (images.length - 1) )
					{
//						alert('Not Next=' + nextPicBottom.style.display);
						nextPicBottom.style.display = "none";
//						alert('Not Next=' + nextPicBottom.style.display);
					}
					else
					{
//						alert('Next=' + nextPicBottom.style.display);
						nextPicBottom.style.display = "block";
//						alert('Next=' + nextPicBottom.style.display);
					}
					
					if ( cnt == 0 )
					{
//						alert('Not Prev=' + prevPicBottom.style.display);
						prevPicBottom.style.display = "none";
//						alert('Not Prev=' + prevPicBottom.style.display);
					}
					else
					{
//						alert('Prev=' + prevPicBottom.style.display);
						prevPicBottom.style.display = "block";
//						alert('Prev=' + prevPicBottom.style.display);
					}
				}				
				currentPicture = cnt;
			}
		}
	}
}

var currentPicture = 0;
var images = new Array();