/* Nav Functions
********************************************/

var lastDropdownId="";

function setupNav() {
	var i=0, j=0, total=0, elem;
	
	while(elem=document.getElementsByTagName('A')[i++]) {  //Find all <a> tags
		if(elem.rel.match("dropdown")) {				   //Where rel="dropdown"
			elem.onmouseover=elem.onfocus=showNav;		   //Set onMouseOver
			
			if(elem.className=="here") {
				$("#"+elem.rel).show();
				lastDropdownId=elem.rel;
				}
			}
		}
	}

function showNav() {
	if(this.rel!=lastDropdownId) {
		$("#"+lastDropdownId).hide();
		
		$("#"+this.rel).fadeIn(250);
		lastDropdownId=this.rel;
		}
	}


/* Popup Functions
********************************************/

function setupPopup() {
	var i=0, j=0, elem, anchors=document.getElementsByTagName('a');
	
	while(elem=anchors[i++]) {
		if(elem.rel.match("popup")) {
			if(elem.rel.match("cal")) {
				elem.onclick=revealPopupCal;
				//elem.onmouseover=elem.onblur=hidePopupCal;
				}
			else {
				elem.onmouseover=elem.onfocus=elem.onclick=revealPopup;
				elem.onmouseout=elem.onblur=hidePopup;
				}
			
			j++;
			}
		}
	//alert(j++);
	}
	
var lastPopupId="";	
	
function revealPopup() {
	var target=this.rel;

	if(lastPopupId && lastPopupId!=target) {
		$("#"+lastPopupId).fadeOut(125);
		}


	$("#"+target).show(500);
	
	lastPopupId=target;
	}
	
	
function revealPopupCal() {
	var target=this.rel;

	if(lastPopupId && lastPopupId!=target) {
		$("#"+lastPopupId).fadeOut(125);
		}

	$("#"+target).slideDown(250);
	
	lastPopupId=target;
	}

function hidePopup() {
	hide(this.rel);
	}

function hide(target) {
	$("#"+target).fadeOut(125);
	}
	
	
/* Directory Functions 
****************************************/
var lastDirectory="";

function setupDirectory() {
	$("#directory>div").hide();
	}

function showDirectory(target) {
	if(target==lastDirectory)
		return;
	if(lastDirectory) {
		$("#"+lastDirectory).fadeOut(250, function() {$("#"+target).fadeIn(500);});
		}
	else {
		$("#"+target).slideDown(500)
		}
	
	
	lastDirectory=target;	
	}