﻿<!--

// These Arrays (from anylinkmenu) help with searchable... abilities, I guess.
// Yes, this is needed.

var all = { divclass: 'anylinkmenu', inlinestyle: 'width:150px; background:transparent', linktarget: '_self'}
all.items = [
	["academics", ""],
	["generalinfo", ""],
	["businessandcommunity", ""],
	["athletics", ""],
	["tuitionandfees", ""],
	["news", ""],
	["studentlinks", ""],
	["athleticsside", ""] //no comma following last entry!
]

var main = { divclass: 'anylinkmenu', inlinestyle: 'width:150px; background:transparent', linktarget: '_self'}
main.items = [
	["academics", ""],
	["generalinfo", ""],
	["businessandcommunity", ""],
	["athletics", ""],
	["tuitionandfees", ""],
	["studentlinks", ""] //no comma following last entry!
]

// Declare variables and arrays

var theePile = "";
var temp;
var tempChar;
var thex;
PileTemp = new Array;
PileOfLinks = new Array;
var c;
c = 0;

// Main function

function LinkPile(how, where, what) {

c = 0;

// This helps with choosing your own menu in the function's arguments
if(what == 'anylinkmenu')
{
	thex = 3;
}
else
{
	thex = 2;
}

// Collect the links without the anchor tag

for(x=thex; x<LinkPile.arguments.length; x++)
{
	if(what == 'anylinkmenu')
	{
											
		temp = eval('anylinkmenu' + LinkPile.arguments[x] + '.items.length');
		for(y=0; y<temp; y++)
		{
			PileOfLinks[c] = eval('anylinkmenu' + LinkPile.arguments[x] + '.items[' + y + '][0]') + '<br />';
			c++;
		}
	}
	else 
	{	
		if(what == 'Main')
		{
										// these are the main links
            for(a=0; a<main.items.length; a++)
            {
                menu = main.items[a][0];
			    for(x=0; x<eval(menu).items.length; x++)
			    {
				    if(eval(menu).items[x][1] != 'nolink' && eval(menu).items[x][1] != '#') 
				    {
                        if(FindSameLink(eval(menu).items[x][0] + '<br />') == 0)
                        {
					        PileOfLinks[c] = eval(menu).items[x][0] + '<br />';
					        c++;
                        }
				    }
			    }
            }			
		}
        else if(what == 'All')
		{								// all links - not really
            for(a=0; a<all.items.length; a++)
            {
                menu = all.items[a][0];
			    for(x=0; x<eval(menu).items.length; x++)
			    {
				    if(eval(menu).items[x][1] != 'nolink' && eval(menu).items[x][1] != '#') 
				    {
                        if(PileOfLinks[c-1] != eval(menu).items[x][0] + '<br />')
                        {
					        PileOfLinks[c] = eval(menu).items[x][0] + '<br />';
					        c++;
                        }
				    }
			    }
            }
		}
		else
		{                               // Your individual chosen menus
			temp = eval(LinkPile.arguments[x] + '.items.length');
			for(y=0; y<temp; y++)
			{
				PileOfLinks[c] = eval(LinkPile.arguments[x] + '.items[' + y + '][0]') + '<br />';
				c++;
			}
		}

	}
}


// Sort it alphabetically

PileOfLinks.sort();

	
// Keep what letter group?
	
	if(how != 'All')
	{
		for(x=0; x<PileOfLinks.length; x++)
		{
			if(x==0)
			{
				c=0;
			}
	
			temp = PileOfLinks[x];
			tempChar = temp.charAt(0);
			
			if(tempChar == how)
			{
				PileTemp[c] = PileOfLinks[x];
				c++;
			}
		}

		PileOfLinks = [];

		for(x=0; x<PileTemp.length; x++)
		{
			PileOfLinks[x] = PileTemp[x];
		}	
	}	
	
// or just pile them all up
	
	else if(how == 'All') {
		for(x=0; x<PileOfLinks.length; x++)
		{
			if(x==0)
			{
				c=0;
			}
	
			PileTemp[c] = PileOfLinks[x];
			c++;
		}

		PileOfLinks = [];

		for(x=0; x<PileTemp.length; x++)
		{
			PileOfLinks[x] = PileTemp[x];
		}	
	
	}
	

	
// begin Link-a-fication!
	
for(x=0; x<PileOfLinks.length; x++)
{
    for(a=0; a<all.items.length; a++)
    {
        menu = all.items[a][0];
	    for(y=0; y<eval(menu).items.length; y++)
	    {
		    if(PileOfLinks[x] == eval(menu).items[y][0] + '<br />')
		    {
			    PileOfLinks[x] = '<li><a href="' + eval(menu).items[y][1] + '">' + PileOfLinks[x] + '</a></li>';
		    }
	    }
    }
}

// I forgot what this does...

for(x=0; x<PileOfLinks.length; x++)
{
	if(PileOfLinks[x] != null)
	{
		theePile += PileOfLinks[x] + '\n';
	}
}

// Dump it in

if(PileTemp.length == 0)
{
	theePile = '<li>No links found starting with ' + how + '.</li>';	// No links beginning with blah blah
	
	document.getElementById(where).innerHTML = theePile;
}
else {

document.getElementById(where).innerHTML = theePile;	// The cake is served :)

}

// house cleaning-
// reset arrays

theePile = "";

PileTemp = [];
	
}

// Find if there is a same link

function FindSameLink(linkvalue)
{
    var y = 0;
    for(var x = 0; x < PileOfLinks.length; x++)
    {
        if(PileOfLinks[x] == linkvalue)
        {
            y++
        }
    }

    return y;
}


// -->