function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName('a');
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute('href') && anchor.getAttribute('rel') && anchor.getAttribute('rel').indexOf('external') >= 0) {
			anchor.target = 'pop_up';
		}
	}
}

Behaviour.addLoadEvent(externalLinks);

function zoomImage() {
	var elementList = document.getElementsByClassName('zoom');
	for (var i=0; i<elementList.length; i++) {
		new Insertion.Top(elementList[i], '<p class="caption zoom-help">click to enlarge</p>');
//		new Insertion.Top(elementList[i], '<div class="zoom-icon"><span class="fir">Zoom</span></div>');
	}
}

Behaviour.addLoadEvent(zoomImage);

var myrules = {
	'.zoom' : function(el) {
		el.onclick = function() {
			var inactive_text = this['inactivetext'];
			if (!inactive_text) {
				this['inactivetext'] = this.firstChild.innerHTML;
				inactive_text = this.firstChild.innerHTML;
			}
			var active_text = "click to close";
			if (Element.hasClassName(this, 'floater')) {
				Element.removeClassName(this, 'floater');
				Element.addClassName(this, 'lightbox');
				this.firstChild.innerHTML = active_text
			}
			else if (Element.hasClassName(this, 'lightbox')) {
				Element.removeClassName(this, 'lightbox');
				Element.addClassName(this, 'floater');
				this.firstChild.innerHTML = inactive_text
			}
		}
	}
};

Behaviour.register(myrules);
