/* Archive Scenes */
var Tabs = Class.create();
Tabs.prototype = {
	initialize: function(container, active) {
		this.container = $(container);
		this.togglers  = this.container.select('.scenesToggle a');
		this.tabs      = this.container.select('.scenes_content');
		this.active    = active || 0;
		this.setup();
	},
	setup: function() {
		this.tabs[this.active].addClassName('active');
		this.togglers[this.active].addClassName('active');
		this.togglers.each(function(el, i) {
			el.onclick = function() {
				if (i != this.active) {
					el.addClassName('active');
					this.togglers[this.active].removeClassName('active');
					
					if(this.tabs.length == this.togglers.length){
						this.tabs[this.active].removeClassName('active');
						this.tabs[i].addClassName('active');
					}
				}
				this.active = i;
				return false;
			}.bind(this);
		}.bind(this));
	}
}

document.observe('dom:loaded', function(){
	if($('archiveScenes'))
		new Tabs('archiveScenes', 0);
});
/* End Archive Scenes */

/* Archive Screens */
var Tabs2 = Class.create();
Tabs2.prototype = {
	initialize: function(container, active) {
		this.container = $(container);
		this.togglers  = this.container.select('.screensToggle a');
		this.tabs      = this.container.select('.screens_content');
		this.active    = active || 0;
		this.setup();
	},
	setup: function() {
		this.tabs[this.active].addClassName('active');
		this.togglers[this.active].addClassName('active');
		this.togglers.each(function(el, i) {
			el.onclick = function() {
				if (i != this.active) {
					el.addClassName('active');
					this.togglers[this.active].removeClassName('active');
					
					if(this.tabs.length == this.togglers.length){
						this.tabs[this.active].removeClassName('active');
						this.tabs[i].addClassName('active');
					}
				}
				this.active = i;
				return false;
			}.bind(this);
		}.bind(this));
	}
}

document.observe('dom:loaded', function(){
	if($('archiveScreens'))
		new Tabs2('archiveScreens', 0);
});
/* End Archive Screens */

/* External Links */
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") == "external")
			anchor.target = "_blank";
	}
}

document.observe("dom:loaded", function(){
	externalLinks();
});
