//--==Site Configuration==--
var sRoot = url_root + "/"; //site root folder
var sMRName = "Media Room"; //site name
var bIsMultiMR = true; //specify whether or not this site contains multiple sub-sites (Media Rooms)
var aMR = new Array("","climate-action"); //array listing Media Room root folders
	
	
//--==Gather Current Page Information==--
//Find current year folder
var sUrl = document.URL;
sYear = sUrl.substr(sUrl.lastIndexOf("2"),4);
if (isNaN(sYear)==true)
	sYear = null;

//Find current Media Room folder - determines whether or not this site contains multiple Media Rooms
switch (bIsMultiMR) {
	case false :
		var sMRFolder = ""; //Media Room site subfolder does not exist
		break;	
	case true :
		//get current Media Room folder
		if (getCurrentMR()=="")
			var sMRFolder = "";
		else
			var sMRFolder = getCurrentMR() + "/";
}

function getCurrentMR() {
	var i = new Number();
	
	//check current url to determine current Media Room
	/*
	for(i in aMR) {
		if (document.URL.indexOf(aMR[i]+"/")>-1) {
			return aMR[i];
			break;
		}
	}
	*/
	//temporary adjustment to account for a different structure, as Penner's Media Room is not in a subfolder of the main site
	if (document.URL.indexOf(aMR[1]+"/")>-1) {
		//alert(document.URL.indexOf(aMR[1]+"/"));
		return aMR[1];
	} else {
		return "";
	}
}



//--==Insert Titles and Archive/Breadcrumb Links Into Current Page==--
function insertMRLink() {
	document.write("<li><a href='" + sRoot + sMRFolder + "' title='" + sMRName + "'>"+sMRName+"</a></li>");
}

//alert(sRoot+"\n"+sMRFolder+"\n"+sSection);
function insertBreadcrumb() {
	if (document.URL.indexOf("archive.html")>-1) {
		document.write("<li><a href='" + sRoot + sMRFolder + sSection + "/'>"+sHome+"</a></li>");
		document.write("<li>"+sArchive+"</li>");
	} else {
		document.write("<li><a href='" + sRoot + sMRFolder + sSection + "/'>"+sHome+"</a></li>");
	}
}
												
function insertSectionTitle() {
	if (document.URL.indexOf("archive.html")>-1)
		document.write(sArchive);
	else {
		if (sYear==null)
			document.write(sHome);
		else
			document.write(sHome + " &ndash; " + sYear);																
	}
}

function insertTopicLinkDivider() {
	if (bArchiveExists==true && bTopArchiveLink==true)
		document.write("<hr />");
}

function insertTopArchiveLink() {
	if (bArchiveExists==true && bTopArchiveLink==true) {
		document.write("<div class='topicLink'><ul>");
		if (document.URL.indexOf("archive.html")>-1)
			document.write("<li><a href='" + sRoot + sMRFolder + sSection + "/'>"+sHome+"</a></li>");
		else
			document.write("<li><a href='" + sRoot + sMRFolder + sSection + "/archive.html'>"+sArchive+"</a></li>");
		document.write("</ul></div>");
	}
}

function insertBottomArchiveLink() {
	if (bArchiveExists==true && isFinite(sUrl.substring(sUrl.length-5,sUrl.length-1))==true) {
		if (document.URL.indexOf("archive.html")>-1)
			document.write("[<a href='" + sRoot + sMRFolder + sSection + "/'>"+sHome+"</a>]");
		else
			document.write("[<a href='" + sRoot + sMRFolder + sSection + "/archive.html'>"+sArchive+"</a>]");
	}
}






//--==Misc Functions==--


function highlightText(x,y) { //2006 PAB standard style for hyperlinks
	var oElement=document.getElementById(x)
	switch (y) {
		case 'on':
			oElement.style.color='#0066CC';
			oElement.style.textDecoration='none';
			break;
		case 'off':
			oElement.style.color='#0000FF';
			oElement.style.textDecoration='underline';					
			break;
	}			  
}
