function onVideoContainerClicked(e) {
	var el = e.findElement('a');
	
	el.removeClassName('iv').addClassName('ivplay');
	el.stopObserving('click', onVideoContainerClicked);
	//var so = new SWFObject("assets/video.swf", "video_player", "320", "240", "9", "#fff");
	var so = new SWFObject("assets/video.swf", "video_player", "390", "293", "9", "#fff");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.addParam("allowFullScreen", "true");
	so.addParam("skinAutoHide", "true");
	so.addVariable("pubcode", 'http://www.nd.edu/~pray/video/' + el.readAttribute('rel'));
	so.write(el.readAttribute('id'));
	e.stop();
}

if (document.observe) {
	document.observe('dom:loaded', function() {
	  if($('mailerform')) {
	      data = $('mailerform').getElements().collect(function(i){ if(i.name.match(/^data/)) return i.name.replace(/data\[/, '').replace(/\]/, ''); }).compact().uniq();
	      h = document.createElement("input");
	      h.name = 'ordered_input_names';
	      h.type = 'hidden';
	      h.value = data;
	      //$('mailerform').appendChild(h);
	
	      $('mailerform').observe('submit', function() {
	          $('submit').value = 'submitting...';
	          $('submit').disable();
	      })
	  }
	
		if($$('ul.tab_set a').size() > 0) { new TabSet($$('ul.tab_set a'), {stopEvent:true}); }
		if($('read_liv')) {
			Event.observe('read_liv', 'click', function(event) {
				tabs = $$('ul.tab_set a');
				areas = 
				tabs.each(function(e){
					area = e.readAttribute('href').split('#')[1];
					$(area).hide();
					//$(area).setStyle({position:'absolute'});
					e.up().removeClassName('active');
				});
				//$('liv').setStyle({position:'relative'});
				$('tab_liv').up().addClassName('active');
				$('liv').show();
			});
		}
		
		// for video placeholders
		//$$('a.iv').each(function(el) {el.observe('click', onVideoContainerClicked);});
		if($('video')) loadVideo();
	});
}

function loadVideo() {
	var so = new SWFObject("/assets/11457/video2.swf", "video_player", "390", "293", "9", "#fff");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.addParam("allowFullScreen", "true");
	so.addParam("skinAutoHide", "true");
	so.addParam('play','true');
	so.addParam('loop','true');
	so.addVariable("pubcode", 'http://www.nd.edu/~pray/video/'+$("video").innerHTML);
	so.write('video');
}

/**
 * Unobtrusive TabSet
 * Author: John Nunemaker
 * Website: Addicted To New (http://addictedtonew.com)
 * 
 * - Checks url to see if it should activate based on hash (ie: http://somedomain.com/#team)
 * - Ff no hash in url or hash in url is for a different tab set, it activates the first tab
 *   in the set
 * - Tabs can be bookmarked because of the url checking
 * - Sets a class of 'active' on the active tab (li), can be changed with activeClass option
 *
 * Usage:
 * <ul id="some_id">
 *   <li><a href="#about">About</a></li>
 *   <li><a href="#team">Team</a></li>
 *   <li><a href="#contact">Contact</a></li>
 * </ul>
 *
 * <div id="about">Some text...</div>
 * <div id="team">Some text...</div>
 * <div id="contact">Some text...</div>
 *
 * <script type="text/javascript">
 *   new TabSet('some_id');
 *   // new TabSet('some_id', {activeClass: 'current'}); // would change the active class to current
 * 	 // new TabSet('some_id', {stopEvent:true}); // stops the click event when tab link is clicked
 * </script>
 */
var TabSet = Class.create({ 
	/* element is the id of the tab set ul */ 
	initialize: function(element, options) {
		this.options = $H({ activeClass: 'active', stopEvent: false }).merge(options); 
		//this.element = $(element);
		//this.tabs 	 = this.element.select('a');
		this.tabs 	 = element;
		this.areas 	 = $A([]);
		this.tabs.each(function(tab) {
			var area = this.areaForTab(tab);
			if (area) { this.areas.push(area); /*area.setStyle({position:'absolute'});*/ }
		}.bind(this));
		this.areas.invoke('hide');
		//this.areas.each(function(e){e.setStyle({position:'absolute'})});
		this.addObservers();
		this.setInitialTab(); 
	},

	addObservers: function() { 
		this.tabs.each(function(tab) { tab.observe('click', this.onClick.bindAsEventListener(this)); }.bind(this)); 
	},

	setInitialTab: function() {
		var initialTab = this.tabs.first();
		if (window.location.hash) {
			this.tabs.detect(function(tab) {
				if (this.parseHash(tab.href) == this.parseHash(window.location.hash)) {
					initialTab = tab;
				}
			}.bind(this));
		} 
		this.showTab(initialTab); 
	},

	showTab: function(tab) { 
		var tab = $(tab); 
		this.areas.invoke('hide');
		//this.areas.each(function(e){e.setStyle({position:'absolute'})});
		this.setActiveListElement(tab);
		this.areaForTab(tab).setStyle({position:'relative'});
		this.areaForTab(tab).show();
	},

	setActiveListElement: function(tab) {
		this.removeActiveClass();
		$(tab).up().addClassName(this.options.get('activeClass'));
	},

	removeActiveClass: function() {
		this.tabs.each(function(tab) {
			tab.up().removeClassName(this.options.get('activeClass')); 
		}.bind(this));
	},

	isTab: function(el) { 
		return (this.tabs.include($(el))) ? true : false; 
	},

	isArea: function(el) { 
		return (this.areas.include($(el))) ? true : false;
	},

	onClick: function(event) { 
		if (this.options.get('stopEvent')) { event.stop(); } 
		var el = Event.findElement(event, 'a'); 
		this.showTab(el); 
	},
	
	areaForTab: function(tab) {
		var tab     = $(tab);
	  var area_id = tab.readAttribute('href').split('#')[1];
	  return $(area_id);
	},
	
	parseHash: function(href) {
		var str = href.split('#').last();
	  return str;
	}
});