$(function()
{
//check if the text in div with id CategoryInfo0 contains a "<";
//This signifies there we are in the community groups page.
//If the "<" exists, take the string on the right side and copy it
//to the <h2> element, and turn the text on the left side into a
//hyperlink to the previous page (perhaps access the browser's back button?).
//If the "<" does not exist, only copy the text of the div with id CategoryInfo0
//into the h1 element; that is the header of the community groups subcategories table.
crumb = $("#CategoryInfo0").text();


if (crumb.match(">") != null)
{
	//take the text on the left side of the ">" and store it in a new variable
	crumb_left = crumb.substring(0,crumb.indexOf('>')-1);

	index_of_gt = crumb.indexOf('>');
	//take the text on the right side of the ">" and store it in a new variable
	//We need to differentiate between IE and other browsers
	//If IE:
	//take the text on the right side of the ">" and store it in a new variable
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		crumb_right_ext = crumb.substring(index_of_gt + 1);
		crumb_right = crumb_right_ext.substring(0,crumb_right_ext.indexOf(crumb_left));
		is_ie = true;
		
	} 
	else
	{
		//if not IE:
		crumb_right = crumb.substring(index_of_gt + 1, crumb.length);
	}
	
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
	{
	//Update the h1 title text
	$("h1").html("<b>" + crumb_right_ext + "</b>");
	//Update the breadcrumb
	$("#CategoryInfo0").html("<a href='#' onclick='history.go(-1);return false;'>" + crumb_left + "</a> &gt; " + crumb_right_ext);
	}
	else
	{
	//Update the h1 title text
	
	$("h1").html("<b>" + crumb_right + "</b>");
	//Update the breadcrumb
	$("#CategoryInfo0").html("<a href='#' onclick='history.back();return false;'>" + crumb_left + "</a> &gt; " + crumb_right);

	}
}
else
{
	//Update the h1 title text
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
	{
  		$("h1").html("<b>" + crumb + "</b>");
	}
	else 
	{
		//$("h1").html("<b>" + crumb.substring(0, crumb.indexOf('i = i + 1')) + "</b>");
		$("h1").html("<b>" + crumb + "</b>");


	}
}
}
);