function show(obj){
	document.getElementById(obj).style.display='block';
}
function hide(obj){
	document.getElementById(obj).style.display='none';
}


var myimages=new Array()
		function preloadimages(){
		for (i=0;i<preloadimages.arguments.length;i++){
		myimages[i]=new Image();
		myimages[i].src=preloadimages.arguments[i];
		}
		}


		preloadimages('/~ato/img/bro_tab_o.jpg', '/~ato/img/menu_about_o.jpg', '/~ato/img/menu_join_o.jpg', '/~ato/img/menu_alumni_o.jpg', '/~ato/img/logo_o.jpg', '/~ato/img/arrow1_o.jpg', '/~ato/img/arrow2_o.jpg', '/~ato/img/arrow3_o.jpg');


var menutimeout;

function resetmenu(){

	menutimeout = setTimeout("menuworks('reset');", 1000);

}

function menuworks(tab){

	var m1 = document.getElementById('m1');
	var m2 = document.getElementById('m2');
	var m3 = document.getElementById('m3');

	var a1 = document.getElementById('a1');
	var a2 = document.getElementById('a2');
	var a3 = document.getElementById('a3');

	var mt = document.getElementById('links');

		m1.src = '/~ato/img/menu_about.jpg';
		m2.src = '/~ato/img/menu_join.jpg';
		m3.src = '/~ato/img/menu_alumni.jpg';

		a1.src = '/~ato/img/arrow1.jpg';
		a2.src = '/~ato/img/arrow2.jpg';
		a3.src = '/~ato/img/arrow3.jpg';


	if(tab == "reset"){

		Slide('menu').up();

	}
	else{
		clearTimeout(menutimeout);
	}

	if(tab == 'm1'){
		m1.src = '/~ato/img/menu_about_o.jpg';
		a1.src = '/~ato/img/arrow1_o.jpg';
		mt.innerHTML = "<a href='/~ato/brothers/'>Meet the Brothers</a><a href='/~ato/brothers/officers/'>Chapter Officers</a><a href='/~ato/about/'>About AT&Omega;</a><a href='/~ato/photos/'>Photo Album</a><a href='/~ato/contact/'>Contact Us</a>";
	}
	if(tab == 'm2'){
		m2.src = '/~ato/img/menu_join_o.jpg';
		a2.src = '/~ato/img/arrow2_o.jpg';
		mt.innerHTML = "<a href='/~ato/whyato/'>Why Should I Join?</a><a href='/~ato/rush/'>How Can I Join? / Rush Schedule</a><a href='/~ato/join/'>What's Involved in Joining?</a>";

	}
	if(tab == 'm3'){
		m3.src = '/~ato/img/menu_alumni_o.jpg';
		a3.src = '/~ato/img/arrow3_o.jpg';
		mt.innerHTML = "<a href='/~ato/alumni/events/'>Events</a><a href='/~ato/alumni/contact/'>Alumni Contact Information</a><a href ='/~ato/alumni/bugle/'>Bugle</a><a href='/~ato/alumni/houseinfo/'>House Information</a><a href='/~ato/alumni/involved/'>GET Involved</a><a href='/~ato/alumni/donate/'>Donate</a>";
	}

	if(document.getElementById('menu').style.display == "none" && tab != "reset"){
		Slide('menu').down();
	}

}

function brotab(obj){

	if(document.getElementById('bro_login').style.display == "none"){
		obj.src = '/~ato/img/bro_tab_o.jpg';
	}
	else{
		obj.src = '/~ato/img/bro_tab.jpg';
	}

}

function SimpleSwap(el,which){
  el.src=el.getAttribute(which || "origsrc");
}

function SimpleSwapSetup(){
  var x = document.getElementsByTagName("img");
  for (var i=0;i<x.length;i++){
    var oversrc = x[i].getAttribute("oversrc");
    if (!oversrc) continue;
      
    // preload image
    // comment the next two lines to disable image pre-loading
    x[i].oversrc_img = new Image();
    x[i].oversrc_img.src=oversrc;
    // set event handlers
    x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
    x[i].onmouseout = new Function("SimpleSwap(this);");
    // save original src
    x[i].setAttribute("origsrc",x[i].src);
  }
}

var PreSimpleSwapOnload =(window.onload)? window.onload : function(){};
window.onload = function(){PreSimpleSwapOnload(); SimpleSwapSetup();}


function slide_toggle(obj){

	if(document.getElementById(obj).style.display == "none"){
		Slide(obj).down();
	}
	else{
		Slide(obj).up();
	}

}


var slideInUse = new Array();

function Slide(objId, options) {
	this.obj = document.getElementById(objId);
	this.duration = 1;
	this.height = parseInt(this.obj.style.height);

	if(typeof options != 'undefined') { this.options = options; } else { this.options = {}; }
	if(this.options.duration) { this.duration = this.options.duration; }
		
	this.up = function() {
		this.curHeight = this.height;
		this.newHeight = '1';
		if(slideInUse[objId] != true) {
			var finishTime = this.slide();
			window.setTimeout("Slide('"+objId+"').finishup("+this.height+");",finishTime);
		}
	}
	
	this.down = function() {
		this.newHeight = this.height;
		this.curHeight = '1';
		if(slideInUse[objId] != true) {
			this.obj.style.height = '1px';
			this.obj.style.display = 'block';
			this.slide();
		}
	}
	
	this.slide = function() {
		slideInUse[objId] = true;
		var frames = 30 * duration; // Running at 30 fps

		var tIncrement = (duration*1000) / frames;
		tIncrement = Math.round(tIncrement);
		var sIncrement = (this.curHeight-this.newHeight) / frames;

		var frameSizes = new Array();
		for(var i=0; i < frames; i++) {
			if(i < frames/2) {
				frameSizes[i] = (sIncrement * (i/frames))*4;
			} else {
				frameSizes[i] = (sIncrement * (1-(i/frames)))*4;
			}
		}
		
		for(var i=0; i < frames; i++) {
			this.curHeight = this.curHeight - frameSizes[i];
			window.setTimeout("document.getElementById('"+objId+"').style.height='"+Math.round(this.curHeight)+"px';",tIncrement * i);
		}
		
		window.setTimeout("delete(slideInUse['"+objId+"']);",tIncrement * i);
		
		if(this.options.onComplete) {
			window.setTimeout(this.options.onComplete, tIncrement * (i-2));
		}
		
		return tIncrement * i;
	}
	
	this.finishup = function(height) {
		this.obj.style.display = 'none';
		this.obj.style.height = height + 'px';
	}
	
	return this;
}

function writeFlash(scrFPath,scrW,scrH,scrID,scrLp) {
	if (window.ActiveXObject) {
		with(document) {
			write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
			write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"');
			write(' width="'+scrW+'" height="'+scrH+'" id="'+scrID+'">');
			write('<param name="movie" value="'+scrFPath+'" \/>');
			write('<param name="loop" value="'+scrLp+'" \/>');
			write('<param name="menu" value="false" \/>');
			write('<param name=quality value="high" \/>');
			write('<\/object>');
		}
	} else {
		if (typeof XMLHttpRequest == "object") {
			with(document) {
				write('<object id="'+scrID+'" data="'+scrFPath+'"');
				write(' type="application/x-shockwave-flash"');
				write(' width="'+scrW+'" height="'+scrH+'">');
				write('<param name="movie" value="'+scrFPath+'" \/>');
				write('<param name="quality" value="high" \/>');
				write('<param name="loop" value="'+scrLp+'" \/>');
				write('<param name="menu" value="false" \/>');
				write('<p>You need Flash for this.');
				write(' Get the latest version from');
				write(' <a href="http://www.macromedia.com/downloads">here<\/a>.');
				write('<\/p>');
				write('<\/object>');
			}
		} else {
			with(document) {
				writeln('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" WIDTH="'+scrW+'" HEIGHT="'+scrH+'" id="'+scrID+'">');
				writeln('<PARAM NAME="movie" VALUE="'+scrFPath+'" \/>');
				writeln('<PARAM NAME="quality" VALUE="high" \/>');
				writeln('<PARAM NAME="loop" VALUE="'+scrLp+'" \/>');
				writeln('<EMBED src="'+scrFPath+'" quality="high" loop="'+scrLp+'" WIDTH="'+scrW+'" HEIGHT="'+scrH+'" NAME="'+scrID+'" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
				writeln('</EMBED>');
				write('</OBJECT>');
			}
		}
	}
}

function toggle(what){

	if (document.getElementById(what).style.visibility != 'visible'){
		document.getElementById(what).style.display = 'block';
		document.getElementById(what).style.visibility = 'visible';
	}
	else{
		document.getElementById(what).style.display = 'none';
		document.getElementById(what).style.visibility = 'hidden';
	}

}