if (document.addEventListener) 
{
    document.addEventListener("DOMContentLoaded", init, null);
}

// fallback
window.onload = init;
function init()
{
	//make sure we only get here once
	if (arguments.callee.done)
	{
		return;
	}
	arguments.callee.done = true;

	load_art_photos();
}

function load_art_photos()
{
	_container = document.getElementById('foto');
	
	if(_container)
	{
		_fotos = document.getElementById('overzicht_fotos');
		
		if(_fotos)
		{
			_links = _fotos.getElementsByTagName('a');
			
			for(i=0;i<_links.length;i++)
			{
				//_links[i].onclick=function()
				//{
					//change(_links[i]);
				//}
				
				if(_links[i].className != 'noajax')
				{
					_links[i].setAttribute('href','javascript:view("'+_links[i]+'/bekijken")');
				}
				//_links[i].setAttribute('href','javascript:void(0)');
			}
		}
	}
}

function view(_link)
{
	new Ajax.Updater('foto', _link, {
		method: 'get',
		insertion: Insertion.after
	});
}

function move(content_id)
{	
	_container = document.getElementById('overzicht_kunstwerken');
	
	if(_container)
	{
		_lis = _container.getElementsByTagName('li');
		
		for(i=0;i<_lis.length;i++)
		{
			//alert(_lis[i].id);
			_content_id = _lis[i].getElementsByTagName('a');
			//alert(_content_id[0].id);
			new Ajax.Request('/ajax/kunstwerk_positie',
			{
				method:'post',
				parameters: {position: i, content_id: _content_id[0].id},
				onSuccess: function(transport){
					var response = transport.responseText || "no response text";
					//alert("Success! \n\n" + response);
				},
				onFailure: function(){ alert('er ging iets mis...') }
			});
		}
	}	
	//alert('De foto is verplaatst');
}
