

	var stopTheClock = true;

	var interval = "";

	var showingID = null;

	var timerStarted = false;

	var numTopLevelNavItems=0;

	

	function tTimer(index) {

	// Borrowed from Hameed's genius

	// Modified to specify an index -JGD4

		stopTheClock = false;

		hideAllSubs();

		

		// Style-specific changes by JGD4

//		document.getElementById("navarr"+index).src = "img/nav1_arrow.gif";

		document.getElementById("navarr"+index).src = nav1_arrow_url;

		document.getElementById("menu"+index).style.background = "none";

		document.getElementById("menu"+index).style.color = "#FFF";

		

		stopTheClock = true;

	}

	

	function startInterval(index) {

	// Borrowed from Hameed's genius

	// Modified to specify an index -JGD4

		interval = window.setInterval("tTimer("+index+")",1000);

	} 

	

	function stopInterval() {

	// Borrowed from Hameed's genius

		if ( interval != "" )

		{

			window.clearInterval (interval);

			interval="";

		}

	}

	

	function getX(obj) {

	// Borrowed from Hameed's genius

		return( obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft+getX(obj.offsetParent) );

	}

	

	function getY(obj) {

	// Borrowed from Hameed's genius

		return( obj.offsetParent==null ? obj.offsetTop : obj.offsetTop+getY(obj.offsetParent) );

	}

	

	function getHeight(obj){

		var result=0;

		if (obj.offsetHeight) {

			result = obj.offsetHeight;

		} else if (obj.clip && obj.clip.height) {

			result = obj.clip.height;

		} else if (obj.style && obj.style.pixelHeight) {

			result = obj.style.pixelHeight;

		}

		//alert(result+", "+ getY(obj));

		return parseInt(result, 10);

	}

	

	function hideAllSubs() {

	// Cycles through the existing submenu indexes, hiding each one until we run out. -JGD4

		for (var i=0; i<numTopLevelNavItems; i++)

		{

			if (document.getElementById("submenu"+i) != null && typeof(document.getElementById("submenu"+i)) != "undefined") {

				//alert("Hiding submenu"+i+".");

				document.getElementById("submenu"+i).style.visibility = "hidden";

			}

		}

	}

	

	function processH(index){

	// Called when the main navigation link is rolled over

	//   --John G Durden IV

		var xpos, ypos;

		

		/*****************/

		if (stopTheClock) stopInterval();

		if(showingID != null && document.getElementById("submenu"+showingID) != null && typeof(document.getElementById("submenu"+showingID)) != "undefined") {

			//document.getElementById("navarr"+showingID).src = "img/nav1_arrow.gif";

			document.getElementById("navarr"+showingID).src = nav1_arrow_url;

			document.getElementById("menu"+showingID).style.background = "none";

			document.getElementById("menu"+showingID).style.color = "#FFF";

		}

		showingID=index;



		// Hide all open submenus

		hideAllSubs();

			

		/*****************/

		

		// Do the following ONLY if a submenu exists for this node...

		if (document.getElementById("submenu"+index) != null && typeof(document.getElementById("submenu"+index)) != "undefined") 

		{

			// Change button display 

			//document.getElementById("navarr"+index).src = "images/nav1_arrow_ovr.gif";

			document.getElementById("navarr"+index).src = nav1_arrow_ovr_url;

			document.getElementById("menu"+index).style.background = "#B6B48D url("+ nav1_bg_ovr_url + ") repeat-x bottom left";

			document.getElementById("menu"+index).style.color = "#323218";

			

			// Make this submenu visible

			document.getElementById("submenu"+index).style.visibility = "visible";

			

			// Get x-position of left block

			xpos = getX(document.getElementById("hd"+index));

			ypos = getY(document.getElementById("hd"+index)) + getHeight(document.getElementById("hd"+index));

			document.getElementById("submenu"+index).style.left = xpos;

			document.getElementById("submenu"+index).style.top = ypos;

		} // if submenu

	}

	

	function processL(index){

	// Called when the main navigation link is rolled off  

	//   --John G Durden IV

		if (document.getElementById("submenu"+index) != null && typeof(document.getElementById("submenu"+index)) != "undefined") 

		{

			startInterval(index);

		}

		//document.getElementById("navarr"+index).src = "images/nav1_arrow.gif";

		//document.getElementById("submenu"+index).style.visibility = "hidden";

		

	}

/*************************************************************************************************/
/*  Process line breaks on the RSS feed                                                          */
/*************************************************************************************************/

function RSSLineBreak() {
	var elements = document.getElementsByTagName("li");
	//alert(elements.length);
	var regExp = /\/\s\-\-\s/gi;
	var newStr = "<br>";
	
	for (var i=0; i<elements.length; i++) {
		if (elements.item(i).className == "syndication-list-item"){
			elements.item(i).innerHTML = elements.item(i).innerHTML.replace(regExp,newStr);
		}
	}
}

/*************************************************************************************************/
// ****************************************************************************
// Common Portlet JS

function stripIDFromFormname(formname) {return formname.slice(0,-5);}
//var DFLT_PARAM = ",left=0,top=0,resizable=yes,status,scrollbars=yes,toolbar=yes,menubar=yes";

// Trim(string) : Returns a copy of a string without leading or trailing spaces
// PURPOSE: Remove trailing and leading blanks from our string
function Trim(str){
   return str.replace(/^[ \t\r\n]+/,"").replace(/[ \t\r\n]+$/,"");
}

function encodeRegUrl(url) {
	// this doesn't encode following special characters: , / ? : @ & = + $ # *
	url = encodeURI(url);
	// now encode all spec chars except / ? : & = 
	url = url.replace(/\,/,"%2C").replace(/\@/,"%40").replace(/\+/,"%2B").replace(/\$/,"%24").replace(/\#/,"%23").replace(/\*/,"%2A");
	return url;
}

// Opens [parsed] content in the same portlet window
function getNewDocument_common(formName, newUrl, newExtUrl){
	var formUrl = stripIDFromFormname(formName)+"_theUrl";
	var formExtUrl = stripIDFromFormname(formName)+"_extUrl";
	eval("document."+formName+"restoreForm."+formUrl+".value = newUrl");	
	eval("document."+formName+"restoreForm."+formExtUrl+".value = newExtUrl");
	eval("document."+formName+"restoreForm.submit()");
}

// Opens [not-parsed] content in a new window outside portal
function openExternalUrlWindow_common(url, targetWindow){
	var width;
	var height;
	width = document.body.clientWidth - 100;
	height = document.body.clientHeight - 100;
	url = encodeRegUrl(url);
	window.open(url,targetWindow,"width=" + width + ", height=" + height + ", left=0, top=0, location=no, resizable=yes, scrollbars=yes, toolbar=yes, menubar=yes");
}

function encodeServletUrl(url) {
	url = encodeURIComponent(url);
	//url = encodeRegUrl(url);
	//url = url.replace(/\&/,"%26").replace(/\=/,"%3D")
	return url;
}

// Opens [parsed] content in a new window using PrintServlet
function getNewWindowDocument_common(newUrl,targetName,parms,encryptLinks,UNQ_PORTLET_ID,uniqueId,encodedNEW_WIN_SERVLET_URI) {
	var cnt;
	var str = newUrl;
	var width;
	var height;
	var encode;
	width = document.body.clientWidth - 100;
	height = document.body.clientHeight - 100;
	str = encodeServletUrl(str);
	if(encryptLinks){
		encode = "&encode=true";
	}
	window.open(encodedNEW_WIN_SERVLET_URI+str+encode+"&"+UNQ_PORTLET_ID+"="+uniqueId,
		targetName,"width=" + width + ",height=" + height + 

",left=0,top=0,resizable=1,status,scrollbars=yes,toolbar=1,menubar=1");
}

// Opens [parsed] content in a new window using PrintServlet for printing
// Content is stripped of images and links
function getPrintWindow_common(newUrl,targetName,parms,encryptLinks,UNQ_PORTLET_ID,uniqueId,encodedPRINT_SERVLET_URI) {
	var cnt;
	var str = newUrl;
	var width;
	var height;
	var encode;
	width = document.body.clientWidth - 100;
	height = document.body.clientHeight - 100;
	str = encodeServletUrl(str);
	if(encryptLinks){
		encode = "&encode=true";
	}
	window.open(encodedPRINT_SERVLET_URI+str+encode+"&"+UNQ_PORTLET_ID+"="+uniqueId,
		targetName,"width=" + width + ",height=" + height + 

",left=0,top=0,resizable=1,status,scrollbars=yes,toolbar=1,menubar=1");
}

function saveUrl_common(urlStr,extUrl,theheight,thewidth,portletWindowStr,sameWindowStr,useIFrame,urlParms, uFormname) {
	var uniqueID = stripIDFromFormname(uFormname);
	var uTheUrl = uniqueID + "_theUrl";
	var uExtUrl = uniqueID + "_extUrl";
	var uHeight = uniqueID + "_height";
	var uWidth = uniqueID + "_width";
	var uIFrame = uniqueID + "_iframe";

	if(portletWindowStr.indexOf("true") > -1) 
	{
		eval("document."+uFormname+"."+uTheUrl+".value = urlStr");
		eval("document."+uFormname+"."+uExtUrl+".value = extUrl");

		if(theheight == null) theheight = "";
		eval("document."+uFormname+"."+uHeight+".value = theheight");
		
		if(thewidth == null) thewidth = "";
		eval("document."+uFormname+"."+uWidth+".value = thewidth");
		
		eval("document."+uFormname+"."+uIFrame+".value = useIFrame");

		//restoreToNormal = sRestoreToNormal;
		eval("document."+uFormname+".submit()");
	}
	else
	{
		if(sameWindowStr.indexOf("differentWindow") > -1)
		{
			targetName = "";
			iLen = urlParms.length;
			if( iLen > 0)
			{
				
				iTarget = urlParms.indexOf("target=");
			    // we found a target=<name> in the urlparms				

	
			    if ( iTarget > -1 )
			    {
				   // 7 is the lenght of target=
			       iTarget = iTarget + 7;
		       
			       // remove everything before and including "target="
			       tmp = urlParms.substring(iTarget, iLen);
		       
			       var word=tmp.split(" ");
			       
				   targetName = word[0];
				   // clean up the name 
				   targetName = Trim(targetName);
			    }
			    
				window.open(encodeRegUrl(extUrl),targetName,urlParms);
            }				
			else {
				window.open(encodeRegUrl(extUrl),"");
			}
		} else {
			top.location = urlStr;
		}
		eval("document."+uFormname+"."+uTheUrl+".value = 'original'");
	}
}

