
function cycleFeature() {
	img_captions = new Array();

// captions: (link-url,image-path,title,text-block)
//	img_captions[n] = Array('#','http://history.nd.edu/images/affiliated/some.jpg','','');	

	img_captions[0] = Array('http://theology.nd.edu/journals-and-centers/#creo','http://theology.nd.edu/images/creo.gif','Center for Research on Educational Opportunity (CREO)');
	img_captions[1] = Array('http://theology.nd.edu/journals-and-centers/#csr','http://theology.nd.edu/images/csr.gif','Center for the Study of Religion');
	img_captions[2] = Array('http://theology.nd.edu/journals-and-centers/#cssm','http://theology.nd.edu/images/cssm.gif','Center for the Study of Social Movements and Social Change');
	img_captions[3] = Array('http://theology.nd.edu/journals-and-centers/#erasmus','http://theology.nd.edu/images/erasmus.gif','Erasmus Institute');
	img_captions[4] = Array('http://theology.nd.edu/journals-and-centers/#higgins','http://theology.nd.edu/images/hlrc.gif','Higgins Labor Research Center');
	img_captions[5] = Array('http://theology.nd.edu/journals-and-centers/#kellogg','http://theology.nd.edu/images/kellogg.gif','Kellogg Institute for International Studies');
	img_captions[6] = Array('http://theology.nd.edu/journals-and-centers/#kroc','http://theology.nd.edu/images/kroc.gif','Joan B. Kroc Institute for International Peace Studies');
	img_captions[7] = Array('http://theology.nd.edu/journals-and-centers/#ils','http://theology.nd.edu/images/latino.gif','The Institute for Latino Studies');
	img_captions[8] = Array('http://theology.nd.edu/journals-and-centers/#sociological_voices','http://theology.nd.edu/images/socvoices.gif','Sociological Voices');

// DO NOT CHANGE ANYTHING BELOW
var num = img_captions.length;
	img_number  = Math.floor(Math.random()*(num));
	img_output = 
		'<a href="' + img_captions[img_number][0] + '"><img src="' + img_captions[img_number][1] + '" alt="' + img_captions[img_number][2] + '" border="0" /></a><p><a href="' + img_captions[img_number][0] + '">' + img_captions[img_number][2] + '</a></p><ul id="features-links"><li><a href="' + img_captions[img_number][0] + '">Read More</a></li><li><a href="http://theology.nd.edu/journals-and-centers/">View All</a></li>';

	document.write(img_output);

}



function currentNav() {
	strCurrPage = getCurrentPath();
	navdiv = document.getElementById("nav-global")
	if (!navdiv){return false;}
	navli = navdiv.getElementsByTagName("li")
	
	if ((typeof(strCurrPage[0])=="undefined")||strCurrPage[0].length<2){
		currPage = new Array();
		currPage[0] = strCurrPage;
	}
	else
	{
	 	currPage = strCurrPage;	
	}

	for (var i = 0; i < currPage.length; i++) {
		for (var j = 0; j < navli.length; j++) {
			strTestPath = getPath(navli[j].firstChild.href);
			if ((typeof(strTestPath[0])=="undefined")||strTestPath[0].length<2){
				testPath = new Array();
				testPath[0] = strTestPath;
			}
			else
			{
				testPath = strTestPath;	
			}

			for (var k = 0; k < testPath.length; k++) {
				if (cleanLastSlash(currPage[i]) == cleanLastSlash(testPath[k])) {
					// alert(currPage[i] + ' == ' + testPath[k]);
					navli[j].className = 'nav-current';
				}
				else
				{
					// alert(currPage[i] + ' != ' + testPath[k]);
				}
			}
		}
	}
}


function getPath(someurl){
 d = document;
 csite = d.domain;
 sp = someurl.indexOf(csite) + csite.length;
 cpath = someurl.substring(sp);
 if (cpath.search(/index/)!=-1){
  re = "(.*?)\/index.shtml";
  myRe = new RegExp(re);
  cpath = cpath.match(myRe);
 }
return cpath;
}

function cleanLastSlash(someurl){
 lastchar = someurl.length-1;
  if (someurl!="") {
	if (someurl.charAt(lastchar)=="/"){someurl = someurl.substring(0,(someurl.length-1))}
  }
return someurl;

}

function getCurrentPath(){
 d = document;
 cpage = d.URL;
 csite = d.domain;
 sp = cpage.indexOf(csite) + csite.length;
 cpath = cpage.substring(sp);
 if (cpath.search(/index/)!=-1){
  re = "(.*?)\/index.shtml";
  myRe = new RegExp(re);
  cpath = cpath.match(myRe);
 }
return cpath;
}

window.onload = init;

function init(){
	currentNav();
}