//************************************************************************
//*
//*  BBL_Highlight_Admin_Links_DEMO
//*  Highlight specified links on System Admin Page
//*  JSH_HiLiAdminLinks
//*  https://myclass.kckcc.edu/*
//*
//************************************************************************


//************************************************************************
//*
//*  May need to call mainline function with a slight delay by using:
//*
//*      setTimeout
//*
//*  This may be necessary to give the page time to completely render.
//*
//************************************************************************


setTimeout(BBL_Highlight_Admin_Links_20180517, 3000);

//BBL_Highlight_Admin_Links_20180517();

//************************************************************************
//*
//*  This is the mainline function.  The mainline function should
//*  use try/catch/finally blocks so any unexpected errors will
//*  be caught and will not affect rendering of the page. 
//*
//************************************************************************

function BBL_Highlight_Admin_Links_20180517()
{

//alert("BEGIN - BBL_Highlight_Admin_Links_20180517 3000");

var error1000;


error1000 = "0";	//***** 0 indicates no errors occurred *****

try
{ // begin try

	if (Is_Admin_Page_Via_Title_20180517() == true)
	//if (Is_Admin_Page_Via_Url_20180517() == true)
	{
		//alert("***** Is System Admin Page *****");

		Highlight_Specified_Admin_Links_20180517();

	}
	else
	{
		//alert("***** Not System Admin Page *****");
	}

} // end try

catch(e)
{
	//alert("***** CATCH *****");

	error1000 = "1";	//***** indicate an error occurred *****
}

finally
{
	//alert(error1000);

}


//alert("END - BBL_Highlight_Admin_Links_20180517");

}

//************************************************************************
//*
//*  Test for the "System Admin" page by using the title of the page.
//*
//*  The innerHTML of the title of the "System Admin" page is: 
//*
//*      System Admin - Blackboard Learn
//*
//*  If the token "System Admin" is found in the page title then this
//*  function returns true.
//*
//************************************************************************

function Is_Admin_Page_Via_Title_20180517()
{

//alert("BEGIN - Is_Admin_Page_Via_Title_20180517");

var s1;
var token1000;
var rc1;

rc1 = false;

token1000 = "SYSTEM ADMIN";

s1 = document.getElementsByTagName("title")[0].innerHTML;

//alert(s1);

s1 = s1.toUpperCase();


if (s1.indexOf(token1000) >= 0)
{
	rc1 = true;
}

//alert(rc1);

//alert("END - Is_Admin_Page_Via_Title_20180517");

return rc1;

}

//************************************************************************
//*
//*  This is an alternate method of testing for the "System Admin" page.
//*
//*  This function tests the URL to determine if this is the 
//*  "System Admin" page.  For KCKCC the URL for this page is:
//*
//*  https://myclass.kckcc.edu/webapps/portal/execute/tabs/tabAction?tab_tab_group_id=_65_1
//*
//*  A portion of this URL is tested to determine if it is the
//*  "System Admin" page.  The URL for the "System Admin" page
//*  will most likely be different for your school, if so adjust
//*  this function accordingly by modifying the token to search for.
//*
//************************************************************************

function Is_Admin_Page_Via_Url_20180517()
{

//alert("BEGIN - Is_Admin_Page_Via_Url_20180517");

var token2000;
var url1;
var rc1;

rc1 = false;

token2000 = "WEBAPPS/PORTAL/EXECUTE/TABS/TABACTION?TAB_TAB_GROUP_ID=_65_1";

url1 = location.href;
url1 = url1.toUpperCase();


if (url1.indexOf(token2000) >= 0)
{
	rc1 = true;
}

//alert("END - Is_Admin_Page_Via_Url_20180517");

return rc1;

}

//************************************************************************
//*
//*  This function highlights specified links on the "System Admin" page.
//*  
//************************************************************************

function Highlight_Specified_Admin_Links_20180517()
{

//alert("BEGIN - Highlight_Specified_Admin_Links_20180517");

var obj1, obj2;
var token1000;
var token2000;
var s1;
var j;
var k;
var links_to_highlight;

links_to_highlight =
["Users",
"Courses"
//"Building Blocks",
//"Data Integration"
];

//alert(links_to_highlight.length);


obj1 = document.getElementById("content");
obj2 = obj1.getElementsByTagName("a");

//alert(obj2.length);

for(j = 0; j < obj2.length; j++)
{
	s1 = obj2[j].innerHTML;
	token1000 = s1.toUpperCase();

	for (k = 0; k < links_to_highlight.length; k++)
	{
		token2000 = links_to_highlight[k].toUpperCase();

		if (token1000.indexOf(token2000) >= 0)
		{
			//obj2[j].style.backgroundColor = "LightGreen";
			//obj2[j].style.backgroundColor = "Aqua";	
			obj2[j].style.backgroundColor = "DeepPink";
		}

	}

}

//alert("END - Highlight_Specified_Admin_Links_20180517");

}

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