	var stallVariable = 0;
	var c=0;
	var t;
	
	function setDept(targ,selObj,restore){ 
	  eval(targ+".location='Default.aspx?sort=department&range="+selObj.options[selObj.selectedIndex].value+"'");
	  if (restore) selObj.selectedIndex=0;
	}
	function setType(targ,selObj,restore){ 
	  eval(targ+".location='Default.aspx?sort=type&range="+selObj.options[selObj.selectedIndex].value+"'");
	  if (restore) selObj.selectedIndex=0;
	}
	function pubReveal(uniqueID) {
	var el = document.getElementById('pubReveal'+uniqueID);
	var elArrow = document.getElementById('pubArrow'+uniqueID);
	var elParent = document.getElementById('pub'+uniqueID);
	if (stallVariable == 0) {
		if (el.style.display == 'none' || el.style.display == '') {
			el.style.display='none';
			ajaxpage('/toah/content/mma_pubs/pub'+uniqueID+'.html', 'pubReveal'+uniqueID);
			elArrow.src = '/toah/art/close.png';
			$('#pubReveal'+uniqueID).slideDown("fast");
			elParent.className='stayHighlightPub';
			document.getElementById("thematicSlideIndex"+uniqueID).style.display = "block";
			pubHighlighter();
		} else {
			$('#pubReveal'+uniqueID).slideUp("fast");
			elArrow.src = '/toah/art/open.png';
			elParent.className='publicationContent';
			document.getElementById("thematicSlideIndex"+uniqueID).style.display = "none";
		}
	}
	}
function unStallSwap() {
	stallVariable = 0;
}

function stallSwap() {
	stallVariable = 1;
	clearTimeout(t);
	t=setTimeout("unStallSwap()",1000);
}
function swapCategory(theID) {
	if (stallVariable == 0) {
		var el = document.getElementById(theID);
		var elArrow = document.getElementById(theID+'Arrow');
			if (el.style.display == 'none' || el.style.display == '') {
				$('#'+theID).slideDown("fast");
				elArrow.src = '/toah/art/thematic_arrow_down.gif';
			} else {
				$('#'+theID).slideUp("fast");
				elArrow.src = '/toah/art/thematic_arrow_right.gif';
			}
	}
	//alert(el.style.display);
}
function highlightIndex(theNum,whichOne) {
	var el = document.getElementById('pub'+theNum);
	if (el.className != 'stayHighlightPub') {
		el.className='indexHighlightPub';
	}
}

function unhighlightIndex(theNum,whichOne) {
	var el = document.getElementById('pub'+theNum);
	if (el.className != 'stayHighlightPub') {
		el.className='publicationContent';
	}
}
function unhighlightIndex2(theNum,whichOne) {
	var el = document.getElementById('pub'+theNum);
	if (el.className != 'stayHighlightPub') {
		el.className='publicationContent2';
	}
}
function showInfo(uniqueID) {
    window.location='#'+uniqueID;
    pubReveal(uniqueID);
}

	function pageload(hash) {
		if(hash) {
				var el = document.getElementById('pubReveal'+hash);
				var elArrow = document.getElementById('pubArrow'+hash);
				var elParent = document.getElementById('pub'+hash);
				if (stallVariable == 0) {
					if (el.style.display == 'none' || el.style.display == '') {
						el.style.display='none';
						ajaxpage('/toah/content/mma_pubs/pub'+hash+'.html', 'pubReveal'+hash);
						elArrow.src = '/toah/art/close.png';
						$('#pubReveal'+hash).slideDown("fast");
						elParent.className='stayHighlightPub';
					}
				}
		} else {
			$("#load").empty();
		}
	}
	
	$(document).ready(function(){
		$.historyInit(pageload);
		
		// set onlick event for buttons
		/*$("a[@rel='history']").click(function(){
			// 
			var hash = this.href;
			hash = hash.replace(/^.*#/, '');
			// moves to a new page. 
			// pageload is called at once. 
			$.historyLoad(hash);
			return false;
		});*/

	  var container = $('<div id="essayPopupContainer">'
	      + '<table width="" border="0" cellspacing="0" cellpadding="0" align="center" class="essayPopupPopup">'
	      + '<tr>'
	      + '   <td class="corner topLeft"></td>'
	      + '   <td class="top"></td>'
	      + '   <td class="corner topRight"></td>'
	      + '</tr>'
	      + '<tr>'
	      + '   <td class="left">&nbsp;</td>'
	      + '   <td class="whiteBG"><div id="essayPopupContent"></div></td>'
	      + '   <td class="right">&nbsp;</td>'
	      + '</tr>'
	      + '<tr>'
	      + '   <td class="corner bottomLeft">&nbsp;</td>'
	      + '   <td class="bottom">&nbsp;</td>'
	      + '   <td class="corner bottomRight"></td>'
	      + '</tr>'
	      + '</table>'
	      + '</div>');
	
	  $('body').append(container);
	  
	  
	  $(".showPDF").live("click", function(){
    	$(this).parent().children(".pdfList").toggle();
	  })
	  
	});
		function showTooltipOBJ() {
			var objAccNo;
			var re = new RegExp('.*ho_(.*)\.htm','ig');
			objAccNo = $(this).attr("href");
			objAccNo = objAccNo.replace(re,"$1")

			var offset = $(this).offset();
			if (hideTimer)
				clearTimeout(hideTimer);
				ajaxpage('/toah/content/ho/preview/ho_'+objAccNo+'.htm', 'essayPopupContent');
				var tipHeight = jQuery('#essayPopupContainer').height();
				var winHeight = jQuery(window).height();
				var scrollTop = $(window).scrollTop();
	
				var totalDivHeight = tipHeight + 180;
				var orientDiv = offset.top-scrollTop;
				
				$("#essayPopupContainer").css('left',offset.left);
				$("#essayPopupContent").css('width',250);
	
				if (orientDiv > (winHeight/2)) {
					$("#essayPopupContainer").css('top',offset.top-totalDivHeight-30);
				} else {
					$("#essayPopupContainer").css('top',offset.top+20);
				}
	
				/*if ((offset.top-scrollTop) > tipHeight) { $("#essayPopupContainer").css('top',(offset.top-tipHeight)-20); } else { $("#essayPopupContainer").css('top',offset.top+20); }*/
				
				//alert('window is ' + winHeight + 'px tall and div is ' + tipHeight + 'px and is ' + offset.top + 'px from the top, but you are scrolled down to ' + scrollTop + 'px');
				//container.css('display', 'block');
				
				$("div.adSpace").remove();
				$("div.readMore").remove();
				container.fadeIn(100);
		}
		function hideTooltipOBJ() {
			if (hideTimer)
			  clearTimeout(hideTimer);
			hideTimer = setTimeout(function()
			{
			  //container.css('display', 'none');
				container.fadeOut(100);
			}, hideDelay);
		}
		function showTooltipTE() {
			
			var objAccNo;
			var re = new RegExp('.*hd_(.*)\.htm','ig');
			objAccNo = $(this).attr("href");
			objAccNo = objAccNo.replace(re,"$1")
	
			var offset = $(this).offset();
			if (hideTimer)
				clearTimeout(hideTimer);
				ajaxpage('/toah/content/te_ads/hd_'+objAccNo+'.html', 'essayPopupContent');
				var winHeight = jQuery(window).height();
				var scrollTop = $(window).scrollTop();
				var tipHeight = jQuery('#essayPopupContainer').height();
				
				var totalDivHeight = tipHeight + 230;
				var orientDiv = offset.top-scrollTop;
				
				$("#essayPopupContainer").css('left',offset.left);
				$("#essayPopupContent").css('width',295);
				
				//alert("orient = " + orientDiv + " and height/2 = " + winHeight/2);
				
				if (orientDiv > (winHeight/2)) {
					$("#essayPopupContainer").css('top',offset.top-totalDivHeight-30);
				} else {
					$("#essayPopupContainer").css('top',offset.top+20);
				}
				
				/*if ((offset.top-scrollTop) > tipHeight) { $("#essayPopupContainer").css('top',(offset.top-tipHeight)-20); } else { $("#essayPopupContainer").css('top',offset.top+20); }*/
				
				//alert('window is ' + winHeight + 'px tall and div is ' + tipHeight + 'px and is ' + offset.top + 'px from the top, but you are scrolled down to ' + scrollTop + 'px');
				//container.css('display', 'block');
				container.fadeIn(100);
		}
		function hideTooltipTE() {
			if (hideTimer)
			  clearTimeout(hideTimer);
			hideTimer = setTimeout(function()
			{
			  //container.css('display', 'none');
				container.fadeOut(100);
			}, hideDelay);
		}

	var pubHighlighter = function() {
	  var hideDelay = 10;  
	  var currentID;
	  var hideTimer = null;
		$(".toahTipObj").hoverIntent(showTooltipOBJ,hideTooltipOBJ);
		$(".toahTipTE").hoverIntent(showTooltipTE,hideTooltipTE);
	}