var albumcount = 0;
var albums = '';
albums = new Array;
window.onload = bodyload;

function bodyload(){
	new_windows();
	albumload();
	albumanchors();
}

function albumload(){
	if(albumcount > 0){
		for(i=1;document.getElementById('thumb_container_' + i);i++){
			trg = document.getElementById('thumb_container_' + i);
			trg.innerHTML = albums[i];
		}
	}
}

function albumanchors(){
	var album = document.getElementById('singlealbum');
	if(!album) { return false; }
	var img_anchors = album.getElementsByTagName('a');
	var l = img_anchors.length;
	for(var i = 0; i < l ; i++){
		var thisanchor = img_anchors[i];
		thisanchor.onclick = function(){ open_image(this);return false;};
	}
}
function open_image(img_anchor){
	img = img_anchor.getElementsByTagName('img');
	thisimg = img[0];
	img_target = document.getElementById('bigimage');
	new_src = thisimg.src.replace(/_h[0-9]+_w[0-9]+_f\.jpg$/,'_h285_w450_a.jpg');
	img_target.src = new_src;
	document.getElementById('bigimage_desc').innerHTML = thisimg.alt;
	return false;
}

function new_windows(){
	var bl_anchors = document.getElementsByTagName('a');
	if(!bl_anchors) return false;
	var l = bl_anchors.length;
	var re = /\bnewwindow\b/;
	for(var i = 0; i < l; i++){
		var thisanchor = bl_anchors[i];
		if(thisanchor.className.match(re)){
			thisanchor.onclick = function(){opennew(this.href);return false;}
		}
	}
}
function opennew(uri){
	newwindow = window.open(uri,'_blank');
	if(!newwindow){return true;}
	if (window.focus) {newwindow.focus()}
	return false;
}
