/*
Base Code: (C) www.dhtmlgoodies.com, September 2005
Modified Code: Daniel Dixon (AU Office of Information Technology)
Last Modified: April 19, 2005
*/		
var initHeight = 0;
var slidedown_direction = 1;
var slidedownContentBox = false;
var slidedownContent = false;
var slidedownControl = false;
var slidedownActive = false;
var contentHeight = false;
var slidedownSpeed = 40; 	// Higher value = faster script
var slidedownTimer = 1;	// Lower value = faster script
// reposition the quicklinks when the window is resized
window.onresize = quicklinks_positionContainer; 
if(typeof override == 'undefined' || (override.toLowerCase() != "quicklinks" &&  override.toLowerCase() != "both")) {
	document.write('<div id="quicklinks_container" onmouseover="quicklinks_clearHideTimer(); return false;" onmouseout="quicklinks_setHideTimer(); return false;">')
	document.write('<ul id="quicklinks_content">')
	document.write('<li><a href="http://www.ag.auburn.edu/aaes/">Alabama Agricultural Experiment Station</a></li>')
	document.write('<li><a href="http://www.aces.edu/">Alabama Cooperative Extension System</a></li>')
	document.write('<li><a href="http://www.alumni.auburn.edu/aoc/index.html">Auburn Online Community</a></li>')
	document.write('<li><a href="http://www.aum.edu">Auburn University Montgomery</a></li>')
	document.write('<li><a href="http://www.auburn.edu/bookstore/">Bookstore</a></li>')
	document.write('<li><a href="http://www.ocm.auburn.edu">Communications &amp; Marketing Resources</a></li>')
	document.write('<li><a href="http://www.ocm.auburn.edu/crisisassistance.html">Crisis/Incident Assistance</a></li>')
	document.write('<li><a href="http://www.auburn.edu/diversity">Diversity and Multicultural Affairs</a></li>')
	document.write('<li><a href="http://www.auburn.edu/emergency">Emergency Preparedness</a></li>')
	document.write('<li><a href="http://www.auburn.edu/student_info/student_affairs/finaid/index.html">Financial Aid</a></li>')
	document.write('<li><a href="http://www.auhcc.com/">Hotel and Conference Center</a></li>')
	document.write('<li><a href="http://jcsm.auburn.edu/">Jule Collins Smith Museum of Fine Art</a></li>')
	document.write('<li><a href="http://www.auburn.edu/au_medical/index.html">Medical Clinic</a></li>')
	document.write('<li><a href="http://ocm.auburn.edu/photographicservices">Photographic Services</a></li>')
	document.write('<li><a href="http://www.auburn.edu/scholarship">Scholarships</a></li>')
	document.write('<li><a href="http://www.vetmed.auburn.edu/index.pl/raptor">Southeastern Raptor Center</a></li>')
	document.write('<li><a href="http://www.auburn.edu/disability/">Students w/ Disabilities</a></li>')
	document.write('<li><a href="http://www.auburn.edu/theatre/">Theatre</a></li>')
	document.write('</ul></div>');
}
function quicklinks_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 quicklinks_showHide()
{	
	// it only set to "undefined" once, even after using clearTimeOut()
	if (typeof preventslide == "undefined" || preventslide == 0) {
		quicklinks_setPreventSlideTimer();
		// if the menu is up, move it down
		if(initHeight==0)
			slidedown_direction=slidedownSpeed;
		else // else, move it up
			slidedown_direction = slidedownSpeed*-1;
		// if the slidedownContentBox isn't set
		if(!slidedownContentBox){
			slidedownContentBox = document.getElementById('quicklinks_container');
			slidedownControl = document.getElementById('quicklinks');
			quicklinks_positionContainer();
			slidedownContent = document.getElementById('quicklinks_content');
			contentHeight = document.getElementById('quicklinks_content').offsetHeight+0; // grab the height
		} else {
			// reset the quicklinks position on every link
			quicklinks_positionContainer();
		}
		// make the content box visible
		slidedownContentBox.style.visibility='visible';
		// tell the timer that we're moving
		slidedownActive = true;
		// start the motion
		quicklinks_showHide_start();
	}
}
function quicklinks_showHide_start()
{
	// clear if the slidedown is waiting to hide
	quicklinks_clearHideTimer();
	// if we reached the height desired, stop the timer event
	if(!slidedownActive)return;
	// increase the height of the content box (could incorporate easing?)
	initHeight = initHeight/1 + slidedown_direction;
	// if moving up and reached a height less than zero
	if(initHeight <= 0){
		slidedownActive = false; // cancel the timer callback to this function	
		slidedownContentBox.style.visibility='hidden'; // hide the content box
		initHeight = 0; // make sure the height is 0
	}
	// if moving down and reached a height greater than the content
	if(initHeight>contentHeight){
		slidedownActive = false; // cancel the timer callback to this function		
	}
	// set the height
	slidedownContentBox.style.height = initHeight + 'px';
	// make the box grow
	slidedownContent.style.top = initHeight - contentHeight + 'px';
	// call this function again on a timer
	setTimeout('quicklinks_showHide_start()',slidedownTimer); // Choose a lower value than 10 to make the script move faster
}

function quicklinks_positionContainer() {
	slidedownContentBox.x=quicklinks_getPosOffset(slidedownControl, "left")-0; // minus 150 to move it inside
	slidedownContentBox.y=quicklinks_getPosOffset(slidedownControl, "top")+20; // push 20 so it doesn't cover link
	slidedownContentBox.style.left=slidedownContentBox.x+"px"
	slidedownContentBox.style.top=slidedownContentBox.y+"px"	
}
function quicklinks_setHideTimer() {
	//slidedownContentBox = document.getElementById('quicklinks_container');
	// clear any other timers first
	if (typeof delayhide != "undefined")
		clearTimeout(delayhide)
	// then set this one
	delayhide=setTimeout("quicklinks_showHide()",100)
}

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

function quicklinks_setPreventSlideTimer() {
	//slidedownContentBox = document.getElementById('quicklinks_container');
	preventslide=setTimeout("quicklinks_clearPreventSlideTimer()",100)
}

function quicklinks_clearPreventSlideTimer() {
	if (typeof preventslide != "undefined") {
		clearTimeout(preventslide)
		preventslide = 0;
	}
}

