/*
EDITABLE SECTION AT TOP
Change array contents to add or remove links in main nav bar in appropriate section
*/

//Contents for current teams section menu
var about=new Array()
about[0]='<a href="2009/coanda/intro.html">Team Coanda</a>'
about[1]='<a href="2009/solarSomethings/intro.html">Solar Somethings</a>'
about[2]='<a href="2009/moMonetMoProblems/intro.html">Mo Monet, Mo Problems</a>'
about[3]='<a href="2009/storm/intro.html">Team Storm</a>'
about[4]='<a href="2009/angstrom/intro.html">Angstrom Inc.</a>'
about[5]='<a href="2009/croupiers/intro.html">The Croupiers</a>'
about[6]='<a href="2009/seeSawers/intro.html">The SeeSawers</a>'
about[7]='<a href="2009/bambooBikers/intro.html">The Bamboo Bikers</a>'
about[8]='<a href="2009/worldClassDesign/intro.html">World Class Design Team</a>'
about[9]='<a href="2009/parkies/intro.html">The Parkies Team</a>'
about[10]='<a href="2009/windTurbine/intro.html">The Wind Turbine Team</a>'
about[11]='<a href="photos.shtml">Photos</a>'
about[12]='<a href="addInfo.shtml">Additional Information</a>'


//Contents for past teams menu
var schedResults=new Array()
schedResults[0]='<a href="2007.shtml">2007</a>'
schedResults[1]='<a href="2008.shtml">2008</a>'


/*Contents for schedule Menu
var outreach=new Array()
outreach[0]='<a href="#/">deadlines</a>'
outreach[1]='<a href="#">no one</a>'
outreach[2]='<a href="#">will make  </a>'
*/
		
//Contents for Links Menu
var linksMenu=new Array()
linksMenu[0]='<a href="http://www.sdp-si.com/">Stock Drive</a>'
linksMenu[1]='<a href="http://www.mcmaster.com">McMaster</a>'
linksMenu[2]='<a href="http://me.columbia.edu">ME Dept.</a>'

		
	
var menuwidth='120px'		//default menu width
var menubgcolor='#666633'	//menu bgcolor
var disappeardelay=250		//menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes"	//hide menu when user clicks within menu?



//!------		Do not edit beyond here		-----
////SLIDING DIVS/////
// our global vars
var heightnow;
var targetheight;
var block;
var slideinterval;
var divheights = new Array();

// the delay between the slide in/out, and a little inertia
var inertiabase = 1;
var inertiainc = 1;
var slideintervalinc = 20;
var inertiabaseoriginal = inertiabase;

window.onload = function()
{
	// detect whether the user has ie or not, how we get the height is different 
	var useragent = navigator.userAgent.toLowerCase();
	var ie = ((useragent.indexOf('msie') != -1) && (useragent.indexOf('opera') == -1) && (useragent.indexOf('webtv') == -1));
	var divs = getElementsByClassName(document, "div", "slideblock");

	for(var i=0; i<divs.length; i++)
	{
		// get the original height
		var baseheight = (ie) ? divs[i].offsetHeight + "px" : document.defaultView.getComputedStyle(divs[i], null).getPropertyValue('height', null);

		// explicitly display it (optional, you could use cookies to toggle whether to display it or not)
		divs[i].style.display = "none";

		// "save" our div height, because once it's display is set to none we can't get the original height again
		var d = new div();
		d.el = divs[i];
		d.ht = baseheight.substring(0, baseheight.indexOf("p"));

		// store our saved versoin
		divheights[i] = d;		
	}
}

// this is one of our divs, it just has a DOM reference to the element and the original height
function div(_el, _ht)
{
	this.el = _el;
	this.ht = _ht;
}

function toggle(t)
{
	// reset our inertia base and interval
	inertiabase = inertiabaseoriginal;
	clearInterval(slideinterval);

	// get our block
	block = t.parentNode.nextSibling;

	// for mozilla, it doesn't like whitespace between elements
	if(block.className == undefined)
		block = t.parentNode.nextSibling.nextSibling;

	if(block.style.display == "none")
	{
		// link text
		//t.innerHTML = "Hide";

		block.style.display = "block";
		block.style.height = "1px";

		// our goal and current height
		targetheight = divheight(block);
		heightnow = 1;

		// our interval
		slideinterval = setInterval(slideout, slideintervalinc);
	}
	else
	{
		// linkstext
		//t.innerHTML = "Show";

		// our goal and current height
		targetheight = 1;
		heightnow = divheight(block);

		// our interval
		slideinterval = setInterval(slidein, slideintervalinc);
	}
}

// this is our slidein function the interval uses, it keeps subtracting
// from the height till it's 1px then it hides it
function slidein()
{
	if(heightnow > targetheight)
	{
		// reduce the height by intertiabase * inertiainc
		heightnow -= inertiabase;

		// increase the intertiabase by the amount to keep it changing
		inertiabase += inertiainc;

		// it's possible to exceed the height we want so we use a ternary - (condition) ? when true : when false;
		block.style.height = (heightnow > 1) ? heightnow + "px" : targetheight + "px";
	}
	else
	{
		// finished, so hide the div properly and kill the interval
		clearInterval(slideinterval);
		block.style.display = "none";
	}
}

// this is the function our slideout interval uses, it keeps adding
// to the height till it's fully displayed
function slideout()
{
	if(heightnow < targetheight)
	{
		// increases the height by the inertia stuff
		heightnow += inertiabase;

		// increase the inertia stuff
		inertiabase += inertiainc;

		// it's possible to exceed the height we want so we use a ternary - (condition) ? when true : when false;
		block.style.height = (heightnow < targetheight) ? heightnow + "px" : targetheight + "px";
		
	}
	else
	{
		// finished, so make sure the height is what it's meant to be (inertia can make it off a little)
		// then kill the interval
		clearInterval(slideinterval);
		block.style.height = targetheight + "px";
	}
}

// returns the height of the div from our array of such things
function divheight(d)
{
	for(var i=0; i<divheights.length; i++)
	{
		if(divheights[i].el == d)
		{
			return divheights[i].ht;
		}
	}
}

/*
	the getElementsByClassName function I pilfered from this guy.  It's
	a useful function that'll return any/all tags with a specific css class.

		Written by Jonathan Snook, http://www.snook.ca/jonathan
		Add-ons by Robert Nyman, http://www.robertnyman.com
*/
function getElementsByClassName(oElm, strTagName, strClassName)
{
	// first it gets all of the specified tags
    var arrElements = (strTagName == "*" && document.all) ? document.all : oElm.getElementsByTagName(strTagName);
    
	// then it sets up an array that'll hold the results
	var arrReturnElements = new Array();

	// some regex stuff you don't need to worry about
    strClassName = strClassName.replace(/\-/g, "\\-");

    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;

	// now it iterates through the elements it grabbed above
    for(var i=0; i<arrElements.length; i++)
	{
        oElement = arrElements[i];

		// if the class matches what we're looking for it ads to the results array
        if(oRegExp.test(oElement.className))
		{
            arrReturnElements.push(oElement);
        }   
    }

	// then it kicks the results back to us
    return (arrReturnElements)
}


////DROP DOWN MENU////


var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
	if (ie4||ns6)
		dropmenuobj.style.left=dropmenuobj.style.top="-500px"
	if (menuwidth!=""){
		dropmenuobj.widthobj=dropmenuobj.style
		dropmenuobj.widthobj.width=menuwidth
}

if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
	obj.visibility=visible
else if (e.type=="click")
	obj.visibility=hidden
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
	dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
	if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
		edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu
// JavaScript Document

/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/


