// Use this script if you have a lightbox relation in an iframe and you want the iframe parent to display the image

var LightboxSub = Class.create();

LightboxSub.prototype = {
	
	// initialize()
	// Constructor runs on completion of the DOM loading. Loops through anchor tags looking for 
	// 'LightboxSub' references and applies onclick events to appropriate links. The 2nd section of
	// the function inserts html at the bottom of the page which is used to display the shadow 
	// overlay and the image container.
	//
	initialize: function() {	
		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName('a');
		//var areas = document.getElementsByTagName('area');

		// loop through all anchor tags
		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];
			
			var relAttribute = String(anchor.getAttribute('rel'));
			
			// use the string.match() method to catch 'LightboxSub' references in the rel attribute
			if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
				anchor.onclick = function () {top.myLightbox.start(this); return false;}
			}
		}

		/*
		// loop through all area tags
		// todo: combine anchor & area tag loops
		for (var i=0; i< areas.length; i++){
			var area = areas[i];
			
			var relAttribute = String(area.getAttribute('rel'));
			
			// use the string.match() method to catch 'LightboxSub' references in the rel attribute
			if (area.getAttribute('href') && (relAttribute.toLowerCase().match('LightboxSub'))){
				area.onclick = function () {myLightboxSub.start(this); return false;}
			}
		}
		*/

		
	}
}

function initLightboxSub() { myLightboxSub = new LightboxSub(); }
Event.observe(window, 'load', initLightboxSub, false);