
$(document).ready(function () {
//	alert("ready");
	checkICMEsrc();
	testSection = getSection();
	if(testSection) {	hiliteHeader(testSection); }
	if($(".tax-Chapters #content-inner ul li.first a") &&
		$(".tax-Chapters #content-top ul li a")
		) {
		
		testSideNav = getSubPage();
		hiliteSubNav(testSideNav);
	
	} // end if .tax-Chapters
	
});

function getSection() {
//	alert("getSection");
	var testSection = '';
	var bodyClass = $("body").attr("class");
	if(bodyClass.indexOf('tax-') > 0) {
		bodyClass = bodyClass.substr( 
			(bodyClass.indexOf('tax-')+4),
			bodyClass.length
			);
		splitClass = bodyClass.split(' ');
		splitClass = splitClass[0].split('-');
		var splitClassLen = splitClass.length;
		for( var i=0; i<splitClassLen; i++) {
			testSection += splitClass[i] + " ";
		}
	return ( jQuery.trim(testSection) );
	} // if
	else if (bodyClass.indexOf('page-content-chapter') > 0) {
		return ( jQuery.trim("Chapters") );
	} //else if
	return false;
}

function getSubPage() {
	var testSideNav = '';
	var testSideNav = jQuery.trim($(".tax-Chapters #sidebar-left ul.menu li.first a").text());	
	
	//alert('testSideNav: ' +testSideNav);	
	return ( jQuery.trim(testSideNav) );
}

function hiliteSubNav(testSideNav) {
	//alert('testSideNav: ' +testSideNav);
		$(".tax-Chapters #content-top ul li a").each(function() {
			testTopNav =  jQuery.trim($(this).text());
		//	alert(testTopNav + "--" +testSideNav);
			
			if(testTopNav == testSideNav){
				$(this).addClass("active");
			}	
	});

}
count = 0;
function hiliteHeader(testSection) {
	$("#header-blocks .menu li a").each(function() {
			testNav = jQuery.trim($(this).text());	
				count++;
			if(testSection.indexOf("Take Action") > -1 && count == 1) { 
				testSection = testSection + "!"; 
			}
	
		//	alert(testSection + " -- " +testNav);
			if(testSection == testNav){
				$(this).addClass("active");
			}	
	});
}
//alert( "ua-js" );

function checkICMEsrc() {
	$("img").each( 
		function() {
		//	var parentTag = $(this).parent();
			if (  
				( $(this).attr("src") == null ) &&
				( $(this).parent().attr("class") =="field-item")
			)	{
				$(".field-type-imceimage").remove();
			} //if
		} //function
	); //img.each
} //function
