// detects the section which the page lives in and displays the block of links for that section
// when you add a section or link, you must add in the following an additional case.

// At present the .length test is performed on sectionLinkA array. This is because it is the LONGEST array, 
// not because it is the FIRST array. So if you introduce a longer array, you must change the line:
// for(var i=0; i<sectionLinkA.length; i++) to read for(var i=0; i<sectionLinkMyNewArray.length; i++)
// SEE ACCOMPANYING DOCUMENTATION
var url_A = new Array ("welcome");
var url_B = new Array ("about");
var url_C = new Array ("faq");
var url_D = new Array ("access","ac_online","ac_dis");
var url_E = new Array ("exam");
var url_F = new Array ("dis","dis_learn","dis_blind","dis_deaf","dis_adhd","dis_aut","dis_med","dis_ment","dis_brain","dis_mobil");
var url_G = new Array ("counsel");
var url_H = new Array ("classroom");
var url_I = new Array ("tech");
var url_J = new Array ("books");
var url_K = new Array ("faculty");
var url_L = new Array ("learn","learn_read","learn_write","learn_math","learn_test","learn_mem","learn_time","learn_note","learn_study");
var url_M = new Array ("finance");
var url_N = new Array ("teach","teach_high","teach_in");
var url_O = new Array ("other");
var url_P = new Array ("FutureStudents");
var url_Q = new Array ("archives");
var url_R = new Array ("Forms");
var url_S = new Array ("contact");

var text_A = new Array ("Home");
var text_B = new Array ("About Us");
var text_C = new Array ("FAQs");
var text_D = new Array ("Accessing Services","Apply Online","Document your Disability");
var text_E = new Array ("Exam Accommodations");
var text_F = new Array ("Disability Categories","Learning Disability","Blind / Low Vision","Deaf / Hard of Hearing","Attention Deficit","Autism / Autism Spectrum","Medical Disability","Mental Health","Mild Acquired Brain Injury","Mobility Impairments");
var text_G = new Array ("Counselling");
var text_H = new Array ("Classroom Interpreting");
var text_I = new Array ("Assistive Technology");
var text_J = new Array ("Alternative Textbooks");
var text_K = new Array ("Faculty Information");
var text_L = new Array ("Learning Strategies","Reading","Writing","Mathematics","Test Taking","Memory","Time Management","Note Taking","Study Skills");
var text_M = new Array ("Financial Assistance");
var text_N = new Array ("Teacher/Guidance Info","High School Transition","Teacher In-Services");
var text_O = new Array ("Other Services & Links");
var text_P = new Array ("Future Students");
var text_Q = new Array ("Archives");
var text_R = new Array ("Downloadable Forms");
var text_S = new Array ("Contact Us");

// gets the full path for use later 
var thisPage=String((document.location.href));

// takes the above variable and strips out the extraneous path components and 
// makes a name for the page, eg 'www.smu.ca/academic/welcome.html' becomes just 'welcome'
var loc= String((thisPage));
loc=loc.split("/");
loc=loc[loc.length-1].split(".");
loc=loc[loc.length-2];

// A URL not displaying an HTML file, eg 'www.smu.ca/academic/' returns a 'null' value to this script.
// This forces a 'null' value to assume the value of 'welcome' to display the root menu.
if (loc == null) loc = "welcome";

if(typeof(loc)=="undefined"){ 

loc="welcome"; 

}

// SETS THE BASE URL
// █████████████ CHANGE THIS!!! ██████████████████████
var baseURL = ('http://www.smu.ca/administration/atlcentre/');
// █████████████ CHANGE THIS!!! ██████████████████████

// (uncomment the line below for testing and troubleshooting)
// document.write (loc)

function ShowHideLayer(boxID) {
	/* Obtain reference for the selected boxID layer and its button */
	var box = document.getElementById("submenu"+boxID);
	/* find the submenu with currently open page */
	var curloc = 0;
	if (loc==url_D[1] || loc==url_D[2]){
		curloc = 10;
	}
	else if (loc==url_F[1] || loc==url_F[2] || loc==url_F[3] || loc==url_F[4] || loc==url_F[5] || loc==url_F[6] || loc==url_F[7] || loc==url_F[8] || loc==url_F[9]){
		curloc = 20;
	}
	else if (loc==url_L[1] || loc==url_L[2] || loc==url_L[3] || loc==url_L[4] || loc==url_L[5] || loc==url_L[6] || loc==url_L[7] || loc==url_L[8]){
		curloc = 30;
	}
	else if (loc==url_N[1] || loc==url_N[2]){
		curloc = 40;
	}
	/* If the selected box is currently invisible, show it */
	if(box.style.display == "none" || box.style.display=="") {
		box.style.display = "block";
	}
	else {
		box.style.display = "none";
	}

/* and hide other open submenus, leaving the one with the current page open 
 (s must loop through the existing submenus - submenu40,submenu60,...) */

//	for(var s=10; s<130; s+=10)
//	{
//		if((s != boxID) && (s != curloc))
//		{
//			var otherbox = document.getElementById("submenu"+s);
//			otherbox.style.display = "none";
//		}
//	}
}

var menubegin = ('<ul class="menu"><li class="menu"><a class="menu')
var menumid1 = ('" href="')
var menumid2 = ('.html">')
var aul = ('</a></li></ul>')

var lia = ('<li class="menu2"><a href="')
var suboff = ('.html" class="menu2">')
var subon = ('.html" class="menu2thispage">')
var ali = ('</a> &#8226;</li>')

// this function takes the value of loc 
// and compares it to all the contents of the arrays until it finds a match.

function sectionDetect()
{
for(var i=0; i<20; i++)
{

/* and hide other open submenus, leaving the one with the current page open 
 (s must loop through the existing submenus - submenu40,submenu60,...) */

//	for(var s=10; s<130; s+=10)
//	{
//		if((s != boxID) && (s != curloc))
//		{
//			var otherbox = document.getElementById("submenu"+s);
//			otherbox.style.display = "none";
//		}
//	}
//}

// this function takes the value of loc 
// and compares it to all the contents of the arrays until it finds a match.


// A
document.write( menubegin ); switch (loc) { case url_A[i]: document.write('thispage'); break } document.write( menumid1 + url_A[0] + menumid2 + text_A[0] + aul );

// B
document.write( menubegin ); switch (loc) { case url_B[i]: document.write('thispage'); break } document.write( menumid1 + url_B[0] + menumid2 + text_B[0] + aul );

// C
document.write( menubegin ); switch (loc) { case url_C[i]: document.write('thispage'); break } document.write( menumid1 + url_C[0] + menumid2 + text_C[0] + aul );

// D
document.write('<ul class="menu"><li class="menu"><div><a href="' + baseURL + url_D[0] + '.html" class="menu'); switch (loc) { case url_D[i]: document.write('thispage'); break } document.write('">' +text_D[0]+ '</a></div></li>');
if(loc==url_D[0] || loc==url_D[1] || loc==url_D[2]){ document.write('<div><ul class="menu2">'); } else { document.write('<div style="display: none;"><ul class="menu2">'); }
if(loc==url_D[1]){ document.write( lia + baseURL + url_D[1] + subon + text_D[1] + ali ); } else { document.write( lia + baseURL + url_D[1] + suboff + text_D[1] + ali ); }
if(loc==url_D[2]){ document.write( lia + baseURL + url_D[2] + subon + text_D[2] + ali ); } else { document.write( lia + baseURL + url_D[2] + suboff + text_D[2] + ali ); }
switch (loc) { case url_D[i]: document.write('</ul>'); break }
document.write('</div></ul>');

// E
document.write( menubegin ); switch (loc) { case url_E[i]: document.write('thispage'); break } document.write( menumid1 + url_E[0] + menumid2 + text_E[0] + aul );

// F
document.write('<ul class="menu"><li class="menu"><div><a href="' + baseURL + url_F[0] + '.html" class="menu'); switch (loc) { case url_F[i]: document.write('thispage'); break } document.write('">' +text_F[0]+ '</a></div></li>');
if(loc==url_F[0] || loc==url_F[1] || loc==url_F[2] || loc==url_F[3] || loc==url_F[4] || loc==url_F[5] || loc==url_F[6] || loc==url_F[7] || loc==url_F[8] || loc==url_F[9]){ document.write('<div><ul class="menu2">'); } else { document.write('<div style="display: none;"><ul class="menu2">'); }
if(loc==url_F[1]){ document.write( lia + baseURL + url_F[1] + subon + text_F[1] + ali ); } else { document.write( lia + baseURL + url_F[1] + suboff + text_F[1] + ali ); }
if(loc==url_F[2]){ document.write( lia + baseURL + url_F[2] + subon + text_F[2] + ali ); } else { document.write( lia + baseURL + url_F[2] + suboff + text_F[2] + ali ); }
if(loc==url_F[3]){ document.write( lia + baseURL + url_F[3] + subon + text_F[3] + ali ); } else { document.write( lia + baseURL + url_F[3] + suboff + text_F[3] + ali ); }
if(loc==url_F[4]){ document.write( lia + baseURL + url_F[4] + subon + text_F[4] + ali ); } else { document.write( lia + baseURL + url_F[4] + suboff + text_F[4] + ali ); }
if(loc==url_F[5]){ document.write( lia + baseURL + url_F[5] + subon + text_F[5] + ali ); } else { document.write( lia + baseURL + url_F[5] + suboff + text_F[5] + ali ); }
if(loc==url_F[6]){ document.write( lia + baseURL + url_F[6] + subon + text_F[6] + ali ); } else { document.write( lia + baseURL + url_F[6] + suboff + text_F[6] + ali ); }
if(loc==url_F[7]){ document.write( lia + baseURL + url_F[7] + subon + text_F[7] + ali ); } else { document.write( lia + baseURL + url_F[7] + suboff + text_F[7] + ali ); }
if(loc==url_F[8]){ document.write( lia + baseURL + url_F[8] + subon + text_F[8] + ali ); } else { document.write( lia + baseURL + url_F[8] + suboff + text_F[8] + ali ); }
if(loc==url_F[9]){ document.write( lia + baseURL + url_F[9] + subon + text_F[9] + ali ); } else { document.write( lia + baseURL + url_F[9] + suboff + text_F[9] + ali ); }
switch (loc) { case url_F[i]: document.write('</ul>'); break }
document.write('</div></ul>');

// G
document.write( menubegin ); switch (loc) { case url_G[i]: document.write('thispage'); break } document.write( menumid1 + url_G[0] + menumid2 + text_G[0] + aul );

// H
document.write( menubegin ); switch (loc) { case url_H[i]: document.write('thispage'); break } document.write( menumid1 + url_H[0] + menumid2 + text_H[0] + aul );

// I
document.write( menubegin ); switch (loc) { case url_I[i]: document.write('thispage'); break } document.write( menumid1 + url_I[0] + menumid2 + text_I[0] + aul );

// J
document.write( menubegin ); switch (loc) { case url_J[i]: document.write('thispage'); break } document.write( menumid1 + url_J[0] + menumid2 + text_J[0] + aul );

// K
document.write( menubegin ); switch (loc) { case url_K[i]: document.write('thispage'); break } document.write( menumid1 + url_K[0] + menumid2 + text_K[0] + aul );

// L
document.write('<ul class="menu"><li class="menu"><div><a href="' + baseURL + url_L[0] + '.html" class="menu'); switch (loc) { case url_L[i]: document.write('thispage'); break } document.write('">' +text_L[0]+ '</a></div></li>');
if(loc==url_L[0] || loc==url_L[1] || loc==url_L[2] || loc==url_L[3] || loc==url_L[4] || loc==url_L[5] || loc==url_L[6] || loc==url_L[7] || loc==url_L[8]){ document.write('<div><ul class="menu2">'); } else { document.write('<div style="display: none;"><ul class="menu2">'); }
if(loc==url_L[1]){ document.write( lia + baseURL + url_L[1] + subon + text_L[1] + ali ); } else { document.write( lia + baseURL + url_L[1] + suboff + text_L[1] + ali ); }
if(loc==url_L[2]){ document.write( lia + baseURL + url_L[2] + subon + text_L[2] + ali ); } else { document.write( lia + baseURL + url_L[2] + suboff + text_L[2] + ali ); }
if(loc==url_L[3]){ document.write( lia + baseURL + url_L[3] + subon + text_L[3] + ali ); } else { document.write( lia + baseURL + url_L[3] + suboff + text_L[3] + ali ); }
if(loc==url_L[4]){ document.write( lia + baseURL + url_L[4] + subon + text_L[4] + ali ); } else { document.write( lia + baseURL + url_L[4] + suboff + text_L[4] + ali ); }
if(loc==url_L[5]){ document.write( lia + baseURL + url_L[5] + subon + text_L[5] + ali ); } else { document.write( lia + baseURL + url_L[5] + suboff + text_L[5] + ali ); }
if(loc==url_L[6]){ document.write( lia + baseURL + url_L[6] + subon + text_L[6] + ali ); } else { document.write( lia + baseURL + url_L[6] + suboff + text_L[6] + ali ); }
if(loc==url_L[7]){ document.write( lia + baseURL + url_L[7] + subon + text_L[7] + ali ); } else { document.write( lia + baseURL + url_L[7] + suboff + text_L[7] + ali ); }
if(loc==url_L[8]){ document.write( lia + baseURL + url_L[8] + subon + text_L[8] + ali ); } else { document.write( lia + baseURL + url_L[8] + suboff + text_L[8] + ali ); }
switch (loc) { case url_L[i]: document.write('</ul>'); break }
document.write('</div></ul>');

// M
document.write( menubegin ); switch (loc) { case url_M[i]: document.write('thispage'); break } document.write( menumid1 + url_M[0] + menumid2 + text_M[0] + aul );

// N
document.write('<ul class="menu"><li class="menu"><div><a href="' + baseURL + url_N[0] + '.html" class="menu'); switch (loc) { case url_N[i]: document.write('thispage'); break } document.write('">' +text_N[0]+ '</a></div></li>');
if(loc==url_N[0] || loc==url_N[1] || loc==url_N[2]){ document.write('<div><ul class="menu2">'); } else { document.write('<div style="display: none;"><ul class="menu2">'); }
if(loc==url_N[1]){ document.write( lia + baseURL + url_N[1] + subon + text_N[1] + ali ); } else { document.write( lia + baseURL + url_N[1] + suboff + text_N[1] + ali ); }
if(loc==url_N[2]){ document.write( lia + baseURL + url_N[2] + subon + text_N[2] + ali ); } else { document.write( lia + baseURL + url_N[2] + suboff + text_N[2] + ali ); }
switch (loc) { case url_N[i]: document.write('</ul>'); break }
document.write('</div></ul>');

// O
document.write( menubegin ); switch (loc) { case url_O[i]: document.write('thispage'); break } document.write( menumid1 + url_O[0] + menumid2 + text_O[0] + aul );

// P
document.write( menubegin ); switch (loc) { case url_P[i]: document.write('thispage'); break } document.write( menumid1 + url_P[0] + menumid2 + text_P[0] + aul );

// Q
document.write( menubegin ); switch (loc) { case url_Q[i]: document.write('thispage'); break } document.write( menumid1 + url_Q[0] + menumid2 + text_Q[0] + aul );

// R
document.write( menubegin ); switch (loc) { case url_R[i]: document.write('thispage'); break } document.write( menumid1 + url_R[0] + menumid2 + text_R[0] + aul );

// S
document.write( menubegin ); switch (loc) { case url_S[i]: document.write('thispage'); break } document.write( menumid1 + url_S[0] + menumid2 + text_S[0] + aul );

break
}
}

sectionDetect (); 
// Delete the line below if the site doesn't need a related links table.
// If it needs a related links table then complete the table below
document.write('<p>&nbsp;</p><ul class="menu"><li class="menu"><b>Related Links</b></li></ul>')
document.write('<ul class="menu"><li class="menu"><a href="http://www.liberatedlearning.com/" target="_blank" class="menu">Liberated Learning</a></li></ul>')
document.write('<ul class="menu"><li class="menu"><a href="http://www.smu.ca/prospectivestudents/canadian-parents.html" class="menu">Parents & Families</a></li></ul>')

