 document.observe("dom:loaded", function() {
	switch(document.body.id) {
		case 'prospectiveStudentsLeadership': leadershipPracticums(); break;
		case 'prospectiveStudentsAcademic': prospectiveStudentsAcademic(); break;
		case 'home': home(); break;
		case 'prospectiveStudentsHousing': prospectiveStudentsHousing(); break;
		case 'prospectiveStudentsOverview': prospectiveStudents(); break;
		case 'prospectiveStudentsEvents': prospectiveStudentsEvents(); break;
		case 'currentStudents': currentStudents(); break;
		case 'about': leadershipPracticums(); break;
	}
});

function leadershipPracticums() {
	$$('div.details').invoke('hide'); // HIDE ALL DETAILS
	$$('h3.moreInfo').each(function(s,index) { // ATTACH EVENT TO EACH 'MORE INFO' BUTTONS
		s.style.cursor = 'pointer';
		s.observe('click', function() {
			var sibling = this.next(0);
			Effect.toggle(sibling,'slide',{duration:.5});
		});
		
	});
}

function prospectiveStudentsAcademic() {
	if ($('courseWrap')) {
		$('courseWrap').getElementsBySelector('a').each(function(s){
			s.observe('click',function(e) {
				Event.stop(e);
				var tag = this;
				new Ajax.Request('/index.php?academics/index/' + tag.id.split('_')[1], {
				    onSuccess: function(transport){
						$('classInfo').update(transport.responseText);
						$('classInfo').innerHTML;
						$$('ul.courseList li.current').each(function(s) { s.removeClassName('current'); });
						tag.up(0).addClassName('current');
						},
				    onFailure: function(){ 
						}
				});
			
			});
		});
		$('semesterList').getElementsBySelector('a').each(function(s){
			s.observe('click',function(e) {
				manageTabs(this);
				Event.stop(e);
			});
		});
		manageTabs();
	}
}

function manageTabs(show) {
	if(show) {
		$(show).up(0).siblings().each(function(s) { $(s.className).hide() });
		$('currentTab').id = '';
		$($(show).up(0).className).show();
		$(show).id = 'currentTab';
	}else{
		$('currentTab').up(0).siblings().each(function(s) { $(s.className).hide() });
	}
}

// Wait before replacing main_flash
// function write_main_flash() {
//	var main_flash = new SWFObject("flash/homepage/main_flash.swf", "main_flash", "995", "350", "6", "#F2F3F3");
//	main_flash.write("main_flash");
// }
// function home() {
//	var left = new SWFObject("flash/homepage/left.swf", "left", "292", "230", "6", "#F2F3F3");
//	var middle = new SWFObject("flash/homepage/middle.swf", "middle", "292", "230", "6", "#F2F3F3");
//	var right = new SWFObject("flash/homepage/right.swf", "right", "292", "230", "6", "#F2F3F3");
//	var main_flash = new SWFObject("flash/homepage/main_flash.swf", "main_flash", "995", "350", "6", "#F2F3F3");
//	left.write("left");
//	middle.write("middle");
//	right.write("right");
//	main_flash.write("main_flash");
//	setTimeout('write_main_flash()',4000);
// }

// Original Code
function home() {
	var left = new SWFObject("flash/homepage/left.swf", "left", "292", "230", "6", "#F2F3F3");
	var middle = new SWFObject("flash/homepage/middle.swf", "middle", "292", "230", "6", "#F2F3F3");
	var right = new SWFObject("flash/homepage/right.swf", "right", "292", "230", "6", "#F2F3F3");
	var main_flash = new SWFObject("flash/homepage/main_flash.swf", "main_flash", "995", "350", "6", "#F2F3F3");
	left.write("left");
	middle.write("middle");
	right.write("right");
	main_flash.write("main_flash");
}

//function about() {
//	var john = new SWFObject("videos/aboutus/pastorjohnabout.swf", "first", "705", "284", "9", "#FFF");
//	var jon = new SWFObject("videos/aboutus/johnspenceabout.swf", "second", "705", "368", "9", "#FFF");
//	john.write("johnLindell");
//	jon.write("jonSpence");
//}

function prospectiveStudentsHousing() {
	var map = new SWFObject("flash/housing_info/web/swf/main.swf", "map", "699", "304", "6", "#FFF");
	map.write("map");
}

function prospectiveStudents() {
	var video = new SWFObject("videos/prosstudents/jeremyalderez.swf", "_video", "462", "300", "9", "#F2F3F3");
	video.write("video");
}

function prospectiveStudentsEvents() {
	var video = new SWFObject("videos/prosstudents/seancallery.swf", "_video", "462", "350", "9", "#F2F3F3");
	video.write("video");
}

function currentStudents() {
	$('forums').observe('click',function(e) {
		window.open('/forum','_forum','width=900,height=600');
		Event.stop(e);
	});
}
