// Image Node Auto-Format with Auto Image Grouping
// Steve McKenzie
// excluding modification by stille

function lightbox2_image_nodes() {

	// create an array if excluded images
	var gallery = new Array();
	// find all elements with the class galleries (should be only the <ul> from image_gallery)
	var nodes = document.getElementsByClassName("galleries");
	for (var i = 0; i < nodes.length; i++) {
		// select all the images inside those lists
		var sub = nodes[i].getElementsByTagName("img");
		for (var j=0; j < sub.length; j++) {
			// save those with the class "thumbnail" to the array
			if (Element.hasClassName(sub[j], "thumbnail")) {
				gallery.push(sub[j]);
			}
		}
	}
	
	var nodes = document.getElementsByClassName("image");
	for (var i = 0; i < nodes.length; i++) {
		if (Element.hasClassName(nodes[i], "thumbnail")) {
			// only modify those images/links not found in the gallery array
			if (gallery.indexOf(nodes[i]) == -1) {
				var parent = nodes[i].parentNode;
				parent.rel = "lightbox[node_thumbnails]";
				parent.href = nodes[i].src.replace(".thumbnail", "");
				parent.title = nodes[i].alt;
			}
		}
	}
}

if (isJsEnabled()) {
  addLoadEvent(lightbox2_image_nodes);
}