////////////////////////////////////////////////////////////////////////////////////////////
// JavaScript Document to display footer because, Server Side Includes on eprimevest is not turned on. 
//Reason for relative path creation = absolute/root path not available/provided  
//www.ePrimeVest.com //
//Smart footer menu//
// November 2008 //
// In linksArray add the website name and in the linksName the link name in the same order//
////////////////////////////////////////////////////////////////////////////////////////////

var linksArray = new Array("index.html", "SiteMap.htm", "about.htm", "UserGuide/pages/ug_1.htm", "security_privacy.htm", "contact_info.htm", "invest.htm", "asset.htm", "invest_basics.htm", "cash.htm", "benefits.htm", "https://eprimevest.automatedfinancial.com/self_enrollment.html") 

var linksName = new Array("e*P<span id='smalltext'>RIME</span>V<span id='smalltext'>EST</span> Home Page", "Site Map", "About e*P<span id='smalltext'>RIME</span>V<span id='smalltext'>EST</span>", "e*P<span id='smalltext'>RIME</span>V<span id='smalltext'>EST</span> User Guide", "Security Information", "Contact Us", "Investment Options", "Asset Management", "Investing Basics", "Cash Management", "Benefits of e*P<span id='smalltext'>RIME</span>V<span id='smalltext'>EST</span>", "Activate an Account")

/////////////////////////////////////////////////////////////////////////////////////////////

// Do not change anything below //
var hrefStart = ('<a class="footerlinks" href="')
var hrefEnd = ('">')
var str = ('../')
var hrefCompl= ("</a> | ")
var superLinksArray = new Array(linksArray, linksName)//create mulitdimensional array
var s=new RegExp("/"); //search for slash in string see line 42 test() method in for loop
var string = window.location.pathname.substring(1) //subtract 1 character ("/") from the pathname string to search for more if exist (e.g. /index.html -> dex.html)
var slash = string.split("/") //transfer path string into an array

if (slash.length > 0){ //if no slash was found  = 0 length of array
var num = slash.length - 1 // num contains number of sub directories
function strMulti(str, num) {
var acc = [];
for (var i = 0; (1 << i) <= num; i++) {
	if ((1 << i) & num)
		acc.push(str);
		str += str;
		}
	return acc.join("");
	}
var str = strMulti(str,num) // Returns string (see join) containing x(../) depending on amount of sub directories -> use variable (str) 
}

document.write("<hr><p align='center' class='footerlinktext'>")
for (var i = 0; i < linksArray.length; i++){
		if (s.test(string)) { // test method to search in path string if slash exists "true -> if slash(/) is in string"
			var href = superLinksArray[0][i]
			if (href.indexOf("http") >= 0){ // search for links not in document root
				var str = ('')
			}
			document.write(hrefStart + str + href + hrefEnd + superLinksArray[1][i] + end(hrefCompl, i))
		}else{
		document.write(hrefStart + superLinksArray[0][i] + hrefEnd + superLinksArray[1][i] + end(hrefCompl, i))
		}
}
document.write("</p><br />")

function end(hrefCompl, i){ //policy: first row should contain 6 links, next line beginning remove | also at the end of links
if (i < 5 || i > 5 && i < (linksArray.length - 1)){
	var hrefCompl= ("</a> | ")
	}
else if (i = 5){
	var hrefCompl= ("</a><br />")
	}
else if (i = (linksArray.length - 1)){
	var hrefCompl= ("</a>")
	}
	return hrefCompl
}
/// END /////////////////