function getContent(mt,taxonomy_id,lang,site,element)
{
	
	
	var b = document.getElementById('body');
	var toRefresh = new Array();
	
	//Refresh all if language has changed
	if (b.getAttribute("language_id") != lang)
	{
		if (mt) b.setAttribute("mt",mt);
		if (taxonomy_id) b.setAttribute("taxonomy_id",taxonomy_id);
		if (lang) b.setAttribute("language_id",lang);
		toRefresh.push("topnav");
		toRefresh.push("lhsnav");
		toRefresh.push("content");
	}
	//Refresh lhsnav and content if main topic changed
	else if (b.getAttribute("mt") != mt)
	{
		if (mt) b.setAttribute("mt",mt);
		if (taxonomy_id) b.setAttribute("taxonomy_id",taxonomy_id);
		toRefresh.push("lhsnav");
		toRefresh.push("content");
	}
	//Refresh content if subtopic changed
	else if (b.getAttribute("taxonomy_id") == -1 || b.getAttribute("taxonomy_id") != taxonomy_id)
	{
		if (taxonomy_id) b.setAttribute("taxonomy_id",taxonomy_id);
		toRefresh.push("content");
	}
	//Return because nothing changed
	else
	{
		//Return false stops the loading of a new url
		return false;
	}
	
	//Remove all toselect id's. Multiple toselect's happen when user clicks another menuitem before content is fully loaded
	while (document.getElementById("toselect") != null)
	{
		document.getElementById("toselect").id = "";
	}

	if(element) 
	{
		element.parentNode.id = 'toselect';
	}
	else
	{
		//Try to find proper element
		var allLinks = document.getElementsByTagName("a");
		for (i = 0; i < allLinks.length; i++)
		{
			if(allLinks[i].getAttribute("href").indexOf('index_SIS.jsp?mt='+mt+'&taxonomy_id='+taxonomy_id+'&lang='+lang+'&site='+site) != -1)
			{
				element = allLinks[i];
				element.parentNode.id = 'toselect';
			}
		}
	}
	
	$("#tabs").tabs();
	/*
	 * Request altered content through /getContent.jsp, by setting the location of the history frame
	 * Frame position "0" is hardcoded, because IE doesn't support index based on name. 
	 * Location.href is used, because "element.src = url" doesn';t trigger history in Safari
	 */
	var url = 'getContent_SIS.jsp?mt=' + b.getAttribute("mt") + '&taxonomy_id=' + b.getAttribute("taxonomy_id") + '&lang=' + b.getAttribute("language_id") + '&site=' + b.getAttribute("site_id") + '&retrieve=' + toRefresh.join("|") + '&title=' + b.getAttribute("baseTitle");
	if (element) url += '&subTitle=' + element.innerHTML;
	
	frames[0].location.href = url;
	
	//Return false stops the loading of a new url
	
	//timedMsg();//flashing text
	
	
	
	//resizeFrame(document.getElementById('frame_content'));
	
	return false;
	
}

function updatePage(data)
{    
	var x;

	if (x = data.getElementById('topnav'))
	{
		d = document.getElementById('topnav');
		d.innerHTML = x.innerHTML;
	}

	if (x = data.getElementById('lhsnav'))
	{
	d = document.getElementById('lhsnav_inner');
		d.style.display = "block";//TJ: added this to redisplay the lhsnav 
		d.innerHTML = regressiveExpandCollapse(x).innerHTML;
		addcollapseExpand();
        
		/*TJ: Added this code*/
		d = document.getElementById('lhsnav_frame_content');
		d.style.left = '180px';
		d.style.top = '0px';
		d.style.width = '700px';
		/*end of code*/
	}

	var type = data.getElementById('type').firstChild.data;
	if (type == "pubtext")
	{
		d = document.getElementById('content');
		d.innerHTML = data.getElementById('content').innerHTML;
		d.style.display="block";

		d = document.getElementById('lhsnav_frame_content');
		d.style.display = "none";

		d = document.getElementById('frame_content');
		d.src = "blank.html";
	}
	else if (type == "url")
	{
		
		d = document.getElementById('frame_content');
		d.src = data.getElementById('url').firstChild.data;

		d = document.getElementById('content');
		d.innerHTML = "";
		d.style.display="none";
		
		d = document.getElementById('lhsnav_frame_content');
		d.style.display = "block";
		
			/**TJ's check left lhsnav html**/
		//	alert(data.getElementById('lhsnav').innerHTML);
			
				if(!data.getElementById('lhsnav').innerHTML){
				d = document.getElementById('lhsnav_inner');
				d.style.display = "none";
				
				d = document.getElementById('lhsnav_frame_content');
				d.style.left = '10px';
				d.style.top = '0px';
				d.style.width = '98%';
				}
			/**End Of TJ's changes**/
		
	}
	else
	{
		d = document.getElementById('lhsnav_frame_content');
		d.style.display = "none";

		d = document.getElementById('frame_content');
		d.src = "blank.html";

		d = document.getElementById('content');
		d.innerHTML = "";
		d.style.display = "block";
	}
	
	/* Malformed content can cause the RHS tag to look empty
	 */
	x = data.getElementById('rhs');
	if (x && x.innerHTML)
	{
		/*d = document.getElementById('rhscustom');
		d.style.display = "block";
		d.innerHTML = x.innerHTML;*/
		
		d = document.getElementById('rhsdefault');
		d.style.display = "none";
	}
	else 
	{
		/*d = document.getElementById('rhscustom');
		d.style.display = "none";
		d.innerHTML = "";*/
	
		d = document.getElementById('rhsdefault');
		d.style.display = "block";
	}
	
	//Highlight selected MenuStructure
	var element = document.getElementById("toselect");
	if (element)
	{
		var allDivs = document.getElementsByTagName("div");
		for (i = 0; i < allDivs.length; i++)
		{
			if (allDivs[i].id == "selected")
			{
				allDivs[i].id = null;
			}
		}
		if (data.getElementById('lhsnav')) //Main topic has changed
		{
			var allLis = document.getElementsByTagName("li");
			for (i = 0; i < allLis.length; i++)
			{
				if (allLis[i].id == "selected")
				{
					allLis[i].id = null;
				}
			}
		}
		element.id = 'selected';
		while(element != null && element.id != 'lhsnav_inner')
		{
			if (element.id == 'submenublock')
			{
				element.parentNode.firstChild.id = 'selected';
				break;
			}
			element = element.parentNode;
		}
	}
	
	$("#tabs").tabs();
	document.title = data.title;
	document.documentElement.scrollTop = 0;
	
}

function expandCollapseMenu(menu)
{
	var sibling = realNextSibling(menu.parentNode)
	if (menu.nodeName == "A" && sibling && sibling.id == "submenublock")
	{
		if (sibling.style.display == "none")
		{
			sibling.style.display = "";
		}
		else
		{
			sibling.style.display = "none";
			regressiveExpandCollapse(sibling);
		}
	}
}

function regressiveExpandCollapse(element, type)
{
	if (!type) type = 'none';
	allSubMenus = element.getElementsByTagName("div");
	for (i = 0; i < allSubMenus.length; i++)
	{
		if (allSubMenus[i].getAttribute("id") == "submenublock")
		{
			allSubMenus[i].style.display = type;
		}
	}
	return element;
}

function realNextSibling(element)
{
	while (element.nextSibling && element.nextSibling.nodeName == '#text')
	{	
		element = element.nextSibling;
	}
	return element.nextSibling;
}

function onLoad()
{
	//Collapse the lhsnav on first display (better to show a first page without lhsnav)
	
	regressiveExpandCollapse(document.getElementById('lhsnav_inner'));
	

	/* possible solution for bookmarking (Safari only allows updating the hash through a real link)
	allLinks = document.getElementsByTagName("a");
	var url = ""
	for (i = 0; i < allLinks.length; i++)
	{
		url = allLinks[i].getAttribute("href");
		allLinks[i].setAttribute("href", url.replace('index.jsp?','#'));
	}
	*/
	//addcollapseExpand();
// initLightbox();
}

function addcollapseExpand()
{
	/*
	 * dynamically add expand/collapse buttons to the lhsnav. If JavaScript is disabled, the lhsnav will be expanded by default and cannot be collapsed, so buttons won't be added then.
	 */
	var element = document.getElementById('lhsnav_inner');
	var colexp  = document.createElement('div');
	colexp.id = "expandcollapse";
	//colexp.setAttribute("class","lhsnavwidth");
	var tmp = "<a href='' class='expand' onclick='regressiveExpandCollapse(document.getElementById(\"lhsnav\"),\"block\"); return false;'></a>\n";
	tmp += "<a href='' class='collapse' onclick='regressiveExpandCollapse(document.getElementById(\"lhsnav\"),\"none\"); return false;'></a>";
	colexp.innerHTML = tmp;
	element.insertBefore(colexp,element.firstChild);
}

//resize iframes to loose the scroll bar 
function resizeFrame(f) {
  f.style.height = f.contentWindow.document.body.scrollHeight + "px";
}

//////flashing text



function AnimText()

{
	/*var text = document.getElementById("flash");
	if(text.style.color=='red')
	{
		text.style.color='#003300';
		
	}
	
	else{text.style.color='red';}
	
	
	//timedMsg();*/
	
}


function timedMsg()
{
var t=setTimeout("AnimText()",500);

}
