function add_load_event(f)
{ 
	var old = window.onload; 
	if ( typeof window.onload != 'function' )
	{ 
		window.onload = f; 
	}
	else
	{ 
		window.onload = function()
		{ 
			if (old)
			{ 
				old(); 
			}
			f(); 
		}
	}
}

function preload(urls)
{
	var img = new Array();
	for ( var i=0; i<urls.length; i++ )
	{
		img[img.length] = new Image();
		img[img.length - 1].src = urls[i];
	}
}

function toggle_box()
{
	var toggler_open = document.getElementById('toggler_open');
	var toggler_close = document.getElementById('toggler_close');
	
	var photo_box = document.getElementById('photo_box');
	//if (photo_box.style.display == 'none' || photo_box.style.display == '' || photo_box.style.display == false)
	if (photo_box.style.display == 'none')
	{
		photo_box.style.display = 'block';
		toggler_open.style.display = 'none';
		toggler_close.style.display = 'inline';
	}
	else
	{
		photo_box.style.display = 'none';
		toggler_close.style.display = 'none';
		toggler_open.style.display = 'inline';
	}	
}

function prev_photo()
{
	var artist_photo = document.getElementById('photo_placeholder');
	if (current_photo > 1)
	{
		current_photo--;
	}
	else
	{
		current_photo = max_photo;
	}
	set_photo_title();
	artist_photo.src = photos[current_photo-1];
	artist_photo.width = sizes[current_photo-1];
}

function next_photo()
{
	var artist_photo = document.getElementById('photo_placeholder');
	if (current_photo < max_photo)
	{
		current_photo++;		
	}
	else
	{
		current_photo = 1;
	}
	set_photo_title()
	artist_photo.src = photos[current_photo-1];
	artist_photo.width = sizes[current_photo-1];
}

function set_photo_title()
{
  var photo_title = document.getElementById('title_placeholder');
  photo_title.innerHTML = titles[current_photo - 1];
}
