(function() {
	function init () {
		
		if ($('hidden_cat')) {
			var cat_name = $('hidden_cat').value;
			
			if (cat_name != 'press-releases') {
				$$("li#t_foot_blog a").invoke('addClassName', 'active');
			} else {
				$$("li#t_foot_press a").invoke("addClassName", 'active');
			}
		
		}
		
		$$('div#recent_press p:last-child', 'div#recent_twitter p:last-child').invoke('addClassName', 'recent_last');
		$$('a[rel~=external]').each(external_links);
		$$('div.apply_content p:first-of-type').invoke('addClassName', 'apply_first');
		$$('div#app_form_container ul li:nth-child(even)').invoke('addClassName', 'odd');
		
		
		var ajax_links = $$('ul#ajax_nav li a');
		
		ajax_links.each(function(el, index) {
			if (index == 0) {
				new Ajax.Updater('update_ajax', el.href, {method: 'get'});
				el.addClassName('active');
			}
			el.observe('click', function(event) {
				ajax_links.invoke('removeClassName', 'active');
				this.addClassName('active');
				event.preventDefault();
				var url = this.href;
				new Ajax.Request(url, {method: 'get',
					onCreate: function() {
						$('update_ajax').update('<img class="loader" src="/wp-content/themes/launchpad/assets/images/ajax_loader.gif" width="66" height="66" alt="loading"');
					},
					onSuccess: function(transport) {
						$('update_ajax').update(transport.responseText);
					}
				});
			});
		});		
	}
		
	function external_links (el) {
		el.observe('click', function(event) {
			event.preventDefault();
			window.open(this.href);
		});
	}
			
	document.observe("dom:loaded", init);
	
})();