function preloadNav()
{
	preloadImages('images/nav/n1_off.gif','images/nav/n1_on.gif','images/nav/n2_off.gif','images/nav/n2_on.gif','images/nav/n3_off.gif','images/nav/n3_on.gif','images/nav/n4_off.gif','images/nav/n4_on.gif','images/nav/n5_off.gif','images/nav/n5_on.gif');
}
function preloadImages() {
	var d=document; 
	if(d.images)
	{ 
		if(!d.p)
			d.p=new Array();
			
		var i,j=d.p.length,a=preloadImages.arguments;
		for(i=0; i<a.length; i++)
		{
			if (a[i].indexOf("#")!=0)
			{
				d.p[j]=new Image;
				d.p[j++].src=a[i];
			}
		}
	}
}

function roll(img,type)
{
		if (type == "on")
			img.src = img.src.replace('_off','_on');
		else if (type == "off")
			img.src = img.src.replace('_on','_off');
}

function openWindow(type,x)
{
    var newwin;
    
    switch(type)
    {
        case "LINK":
            newwin = window.open(x);
            break; 
        case "PDF":
            newwin = window.open("/pdfs/" + x + ".pdf","pdf_download","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left=150,top=150,alwaysRaised=1");
            break; 
        case "APPLY":
            newwin = window.open("/about/apply.html","application","width=617,height=470,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,left=150,top=150,alwaysRaised=1");
            break; 
    }
    
    newwin.focus();
}

function printPage()
{
    print();
}

function closePage()
{
    window.close();
}

function showText(divID,type)
{
    var iconTextObj = (document.layers)?document[divID]:document.all?document.all[divID]:document.getElementById(divID);
    
    clearIconText();
    
    if (type == "on")
        iconTextObj.style.display = "block";
    else
    {
        // show default text
        iconTextObj = (document.layers)?document["box0"]:document.all?document.all["box0"]:document.getElementById("box0");
        iconTextObj.style.display = "block";
    }
        
}

function clearIconText()
{
    var obj, boxID;
    for (var i=0; i<7; i++)
    {
        boxID = "box" + i;
        obj = (document.layers)?document[boxID]:document.all?document.all[boxID]:document.getElementById(boxID);
        if (obj != null)
            obj.style.display = "none";
    }
}

// external link functions
// gets all a tags in document and sets any class="external" to open up in a new window
function setExternalLinks() {

	// Fetch all the a elements in the document.
	var links = document.getElementsByTagName('a');

	// Loop through the a elements in reverse order
	// for speed.
	for (var i = links.length; i != 0; i--) {
		
		// Pull out the element for this iteration.
		var a = links[i-1];
		
		// If the element doesn't have an href, skip it.
		if (!a.href) continue;

		// If the element has a className that contains
		// 'external' attach the onclick handler.
		if (a.className && a.className.indexOf('external') != -1) a.onclick = PopWin;
	}
}

function PopWin(e) {

	// Accommodate IE's non-standard event handling.
	if (!e) var e = window.event;
	var a = e.target ? e.target : e.srcElement;

	// Open a new window with the link's href.
	
	// we could be using a <span> for PDF links, so let's check to see if we
	// need to use the parentNode.
	var newwin;
	if (a.nodeName=="SPAN")
	    newwin = window.open(a.parentNode.href);
	else
	    newwin = window.open(a.href);

	// The thought is that if the new window didn't
	// (popups blocked or whatever) we want to return
	// true so the link is follow normally. Not sure
	// if this works, but it doesn't seem to hinder.
	return !newwin;                               
}

// load up the function after all elements render
onload = setExternalLinks;