﻿
var popup;
var lasthit=null;
var currenthit=null;
var Summaryhit=null;
var documentnumber = 0;
var documentnumbertotal = null;
var anchors = new Array();

function getTop(node) {
	var result=node.offsetTop;
	while (node.offsetParent) {
		node=node.offsetParent;
		result+=node.offsetTop;
	}
	return result;
}

function getLeft(node) {
	var result=node.offsetLeft;
	while (node.offsetParent) {
		node=node.offsetParent;
		result+=node.offsetLeft;
	}
	return result;
}

function showpopup(a,text) {
    var element = a;
    
    // Loop upward to find out which div this abbreviation is in.
    while(element.parentNode.id != 'secondarycontent' && element.parentNode.id != 'content')
    {
        element = element.parentNode;
    }

	if (!popup) popup=document.getElementById("popup");
	popup.innerHTML=text;
	popup.style.display="block";
	
	var left=getLeft(a);
	if (left+popup.offsetWidth > getWindowWidth()-10) {
		left=getWindowWidth()-popup.offsetWidth-10;
	}
	
	var top=getTop(a)+20-getScrollTop(element.parentNode.id);
	if (top+popup.offsetHeight > getWindowHeight() - 45) {
		top=getTop(a)-popup.offsetHeight-getScrollTop(element.parentNode.id)-35;
	}
	
	popup.style.left=left+"px";
	popup.style.top=top+"px";

}

function hidepopup(a) {
	popup.style.display="none";
}

function togglereference() {
	var reference=document.getElementById("reference");
	var referencepm=document.getElementById("referencepm");
	if (reference.style.display=="none") {
		reference.style.display="block";
		referencepm.src="/images/grnarrwsmminus.gif";
	} else {
		reference.style.display="none";
		referencepm.src="/images/grnarrwsmplus.gif";
	}
	
	currentWindowHeight=0;
}

function gotosection(jumplink) {
	jumplink=jumplink.toLowerCase();
	
	var w=window.opener?window.opener:window;
	
	if (w.location.search.toLowerCase().indexOf(jumplink.match(/^([^\.]+\.){3}/)[0])>=0 && w.location.href.toLowerCase().indexOf("summary.aspx")>=0) {
		w.opensection("contents",jumplink);
		w.location.hash=jumplink;
	} else {
		w.location="/summary.aspx?jumplink="+escape(jumplink)+"#"+jumplink;
	}
	
	if (w!=window) w.blur();
	w.focus();
}

function gotoScope(jumplink)
{
    document.getElementById("spanSeparatorNav").style.display = "none";
    
    var URL = "scopeajax.aspx?jumplink=" + escape(jumplink);
    
    var httpRequest = createHttpRequest();

    if (!httpRequest) 
    {
        document.getElementById('secondarycontent').innerHTML = "Error: Unable to create an XMLHTTP instance";
    }
    
    httpRequest.open('GET', URL, false);
    httpRequest.send('');
     
    document.getElementById('secondarycontent').innerHTML = httpRequest.responseText;
     chktitle="0";
    updateContentSeparatorTitle();
        
    document.getElementById('secondarycontent').style.display = "block";
    document.getElementById('contentseparator').style.display = "block";
    
    // reset this variable so adjustScroll() runs
	currentWindowHeight = 0;
}

function goToStatuteFromPopup()
{
    
	goToStatute(window.event.srcElement.getAttribute("state"),window.event.srcElement.getAttribute("cite"),0,window.event);
	document.getElementById("statutePopup").style.display="none";
	
}

//function goToStatute(state, cite, newdocumentnumber, event) 
//{
//    
//    document.getElementById("spanSeparatorNav").style.display = "inline";

//    documentnumber = newdocumentnumber;
//    
//    var element = (window.event!=undefined)? window.event.srcElement: event.target;
//    
//    // Loop upward to find out which div this statute link is in.
//    while(element && element.parentNode && element.parentNode.id != 'secondarycontent' && element.parentNode.id != 'content')
//    {
//        element = element.parentNode;
//    }
//    
//	if((element && element.parentNode && element.parentNode.id == 'secondarycontent') || window.location.href.match(/statute\.aspx/)) // if statute link is in bottom pane summary on search results page
//	{
//	    var w = window.opener ? window.opener : window;
//	
//	    w.location = "statute.aspx?state=" + encodeURIComponent(state) + "&cite=" + encodeURIComponent(cite);
//	    if (w != window) w.blur();
//	    w.focus();
//	}
//	else
//	{
//	    var i = 0, searchtext = "";
//	    var querystring = unescape(location.search).split("&");
//	    
//	    while(querystring[i] && searchtext == "")
//	    {
//	        if(querystring[i].search("searchtext") == 0 || querystring[i].search("searchtext") == 1)
//	        {
//	            searchtext = querystring[i].split("=")[1];
//	        }
//	        i++;
//	    }

//	    var URL = "statuteajax.aspx?state=" + escape(state) + "&cite=" + escape(cite) + "&searchtext=" + escape(searchtext) + "&direction=";
//        var httpRequest = createHttpRequest();

//        if (!httpRequest) 
//        {
//            document.getElementById('secondarycontent').innerHTML = "Error: Unable to create an XMLHTTP instance";
//        }
//        
//        httpRequest.open('GET', URL, false);
//        httpRequest.send('');
//         
//        document.getElementById('secondarycontent').innerHTML = httpRequest.responseText;
//        document.getElementById('secondarycontent').style.display = "block";
//	    document.getElementById('contentseparator').style.display = "block";
//        
//        if(document.getElementById("strHits").value > 0)
//        {
//            goToHitNumber(1);
//            document.getElementById("spanHitNavR").style.display = "inline";
//            document.getElementById("spanHitNavL").style.display = "inline";
//            document.getElementById("imgSplitRR").style.display = "inline";
//            document.getElementById("imgSplitLL").style.display = "inline";
//            document.getElementById("spantagPrint").style.display = "inline";

//        }
//        else
//        {
//	        //document.getElementById("spanHitNavR").style.display = "inline";
//            //document.getElementById("spanHitNavL").style.display = "inline";
//            document.getElementById("imgSplitRR").alt="Previous Statute";
//            document.getElementById("imgSplitLL").alt="Next Statute";
//        }
//        
//        updateContentSeparatorTitle();
//	    window.location.hash = "hit1";
//	    
//	    
//	    // reset this variable so adjustScroll() runs
//	    currentWindowHeight = 0;
//	    
//	    // reset this array so it isn't populated on a statute
//        anchors = [];
//        
//        // populate statutes list
//        //		var statutePopup=document.getElementById("statutePopup");
//        //		if (statutePopup) {
//        //			statutePopupLookup=new Array();
//        //			statutePopup.innerHTML="";
//        //			httpRequest = createHttpRequest();
//        //		
//        //			var URL = "statutelistajax.aspx?state=" + state;	
//        //			
//        //			httpRequest.open('GET', URL, false);
//        //			httpRequest.send('');
//        //			
//        //			var blocks=httpRequest.responseText.split("|");
//        //			for (var i=0; i<blocks.length-1; i+=2) {
//        //				var cite=blocks[i];
//        //				var title=blocks[i+1];
//        //				
//        //				var link=document.createElement("a");
//        //				link.innerHTML=cite + " " + title;
//        //				link.href="#";
//        //				link.setAttribute("state",blocks[blocks.length-1]);
//        //				link.setAttribute("cite",HTMLDecode(cite));
//        //				
//        //				link.onclick=goToStatuteFromPopup;
//        //				
//        //				statutePopup.appendChild(link);
//        //				
//        //				statutePopupLookup.push(new Array(cite,link));
//        //			}		
//        //		}
//    }
//    return false;
//}



var chktitle="0";
function goToStatute(state, cite, newdocumentnumber, event) 
{

    
    document.getElementById("spanSeparatorNav").style.display = "inline";

    documentnumber = newdocumentnumber;
    
    var element = (window.event!=undefined)? window.event.srcElement: event.target;
    
    // Loop upward to find out which div this statute link is in.
  
    while(element && element.parentNode && element.parentNode.id != 'secondarycontent' && element.parentNode.id != 'content')
    {
        element = element.parentNode;
    }

//    if((element && element.parentNode && element.parentNode.id == 'secondarycontent') || window.location.href.match(/statute\.aspx/)) // if statute link is in bottom pane summary on search results page
//	{
//	    var w = window.opener ? window.opener : window;
//	    w.location = "statute.aspx?state=" + encodeURIComponent(state) + "&cite=" + encodeURIComponent(cite);
//        if (w != window) w.blur();
//	    w.focus();
//    }

    if(element && element.parentNode && element.parentNode.id == 'secondarycontent')
	{
        var i = 0, searchtext = "";
        var querystring = unescape(location.search).split("&");

        while(querystring[i] && searchtext == "")
        {
            if(querystring[i].search("searchtext") == 0 || querystring[i].search("searchtext") == 1)
            {
                searchtext = querystring[i].split("=")[1];
            }
            i++;
        }

        var URL = "statuteajax.aspx?state=" + escape(state) + "&cite=" + escape(cite) + "&searchtext=" + escape(searchtext) + "&direction=";
        var httpRequest = createHttpRequest();

        if (!httpRequest) 
        {
            document.getElementById('thirdseparator').innerHTML = "Error: Unable to create an XMLHTTP instance";
        }

        httpRequest.open('GET', URL, false);
        httpRequest.send('');
         
        document.getElementById('thirdcontent').innerHTML = httpRequest.responseText;
        document.getElementById('thirdcontent').style.display = "block";
        document.getElementById('thirdseparator').style.display = "block";
        document.getElementById('thirdcontentseparatortitle').innerHTML = cite;
document.getElementById('spanSeparatorNav').style.display = "none";
        currentWindowHeight = 0;

        // reset this array so it isn't populated on a statute
        anchors = [];

        // populate statutes list
        var statutePopup=document.getElementById("statutePopup");
        if (statutePopup) {
            statutePopupLookup=new Array();
            statutePopup.innerHTML="";
            httpRequest = createHttpRequest();

            var URL = "statutelistajax.aspx?state=" + state;	
        	
            httpRequest.open('GET', URL, false);
            httpRequest.send('');
        	
            var blocks=httpRequest.responseText.split("|");
            for (var i=0; i<blocks.length-1; i+=2) {
                var cite=blocks[i];
                var title=blocks[i+1];
        		
                var link=document.createElement("a");
                link.innerHTML=cite + " " + title;
                link.href="#";
                link.setAttribute("state",blocks[blocks.length-1]);
                link.setAttribute("cite",HTMLDecode(cite));
        		
                link.onclick=goToStatuteFromPopup;
        		
                statutePopup.appendChild(link);
        		
                statutePopupLookup.push(new Array(cite,link));
            }		
        }
        return false;
    }
    else if(window.location.href.match(/statute\.aspx/)) // if statute link is in bottom pane summary on search results page
    {
        var w = window.opener ? window.opener : window;
	    w.location = "statute.aspx?state=" + encodeURIComponent(state) + "&cite=" + encodeURIComponent(cite);
        if (w != window) w.blur();
	    w.focus();
    }
	else
	{
	    var i = 0, searchtext = "";
	    var querystring = unescape(location.search).split("&");
	    
	    while(querystring[i] && searchtext == "")
	    {
	        if(querystring[i].search("searchtext") == 0 || querystring[i].search("searchtext") == 1)
	        {
	            searchtext = querystring[i].split("=")[1];
	        }
	        i++;
	    }

	    var URL = "statuteajax.aspx?state=" + escape(state) + "&cite=" + escape(cite) + "&searchtext=" + escape(searchtext) + "&direction=";
        var httpRequest = createHttpRequest();

        if (!httpRequest) 
        {
            document.getElementById('secondarycontent').innerHTML = "Error: Unable to create an XMLHTTP instance";
        }
        
        httpRequest.open('GET', URL, false);
        httpRequest.send('');
         
        document.getElementById('secondarycontent').innerHTML = httpRequest.responseText;
        document.getElementById('secondarycontent').style.display = "block";
	    document.getElementById('contentseparator').style.display = "block";
	      chktitle="1";
	    updateContentSeparatorTitle();
	   window.location.hash = "hit1";
	   currenthit = 1;
        if(document.getElementById("strHits").value > 0)
        {
            
            goToHitNumber(1);
            document.getElementById("spanHitNavR").style.display = "inline";
            document.getElementById("spanHitNavL").style.display = "inline";
            document.getElementById("imgSplitRR").style.display = "inline";
            document.getElementById("imgSplitLL").style.display = "inline";
            document.getElementById("spantagPrint").style.display = "inline";
        }
        else
        {document.getElementById("imgSplitRR").style.display = "inline";
            document.getElementById("imgSplitLL").style.display = "inline";
	        document.getElementById("imgSplitRR").alt="Previous Statute";
            document.getElementById("imgSplitLL").alt="Next Statute";
        }
        
	    
	    // reset this variable so adjustScroll() runs
	    currentWindowHeight = 0;
	    
	    // reset this array so it isn't populated on a statute
        anchors = [];
        
        // populate statutes list
		var statutePopup=document.getElementById("statutePopup");
		if (statutePopup) {
			statutePopupLookup=new Array();
			statutePopup.innerHTML="";
			httpRequest = createHttpRequest();
		
			var URL = "statutelistajax.aspx?state=" + state;	
			
			httpRequest.open('GET', URL, false);
			httpRequest.send('');
			
			var blocks=httpRequest.responseText.split("|");
			for (var i=0; i<blocks.length-1; i+=2) {
				var cite=blocks[i];
				var title=blocks[i+1];
				
				var link=document.createElement("a");
				link.innerHTML=cite + " " + title;
				link.href="#";
				link.setAttribute("state",blocks[blocks.length-1]);
				link.setAttribute("cite",HTMLDecode(cite));
				
				link.onclick=goToStatuteFromPopup;
				
				statutePopup.appendChild(link);
				
				statutePopupLookup.push(new Array(cite,link));
			}		
		}
    }
    
      var res=document.getElementById("strsyncsummary").value;
     if(res=="true")
     {
      document.getElementById("spansyncsummary").style.display = "none";
     }
     else
     {
      document.getElementById("spansyncsummary").style.display = "block";
     }
      //end
    
    
    
    return false;
}





function gotosummary(jumplink, searchindex, newdocumentnumber, event)
{
    
    document.getElementById("spanSeparatorNav").style.display = "inline";
    
    documentnumber = newdocumentnumber;

    var searchtext = unescape(location.search).split("&")[0].split("=")[1];
    var URL = "summaryajax.aspx?jumplink=" + jumplink + "&searchtext=" + searchtext;
    
    var httpRequest = createHttpRequest();

    if (!httpRequest) 
    {
        document.getElementById('secondarycontent').innerHTML = "Error: Unable to create an XMLHTTP instance";
    }
    
    httpRequest.open('GET', URL, false);
    httpRequest.send('');
    
    document.getElementById('secondarycontent').innerHTML = httpRequest.responseText;
    document.getElementById('secondarycontent').style.display = "block";
    document.getElementById('contentseparator').style.display = "block";
    document.getElementById("spanHitNavR").style.display = "inline";
    document.getElementById("spanHitNavL").style.display = "inline";
    document.getElementById("imgSplitRR").style.display = "inline";
    document.getElementById("imgSplitLL").style.display = "inline";
    document.getElementById("spantagPrint").style.display = "inline";
         chktitle="0";
    
    if(document.getElementById('strFirstHit'))
    {
        currenthit = document.getElementById('strFirstHit').value;
    
        if(isNaN(currenthit))
        {
            currenthit = 0;
        }
        else
        {
            goToHitNumber(currenthit);
        }
        
        updateContentSeparatorTitle();
        
        window.location.hash = "hit" + currenthit;
    }
    
    // reset this variable so adjustScroll() runs
    currentWindowHeight = 0;
    
     var res=document.getElementById("strsyncsummary").value;
     if(res=="true")
     {
      document.getElementById("spansyncsummary").style.display = "none";
     }
     else
     {
      document.getElementById("spansyncsummary").style.display = "block";
     }
      //end
    
    
    
    // reset this array so it gets repopulated on this new summary
    anchors = [];
    return false;
}


function goToAlerts(alertId,newdocumentnumber,event)
    {
    
    documentnumber = newdocumentnumber;
    document.getElementById('secondarycontent').style.display = "block";
    document.getElementById('contentseparator').style.display = "block";
    document.getElementById("spanHitNavR").style.display = "none";
    document.getElementById("spanHitNavL").style.display = "none";
    document.getElementById("imgSplitRR").style.display = "inline";
    document.getElementById("imgSplitLL").style.display = "inline";
    document.getElementById("spantagPrint").style.display = "none";
    
    document.getElementById("contentseparatortitle").innerText = '';
    
    documentnumber = newdocumentnumber;    
    
         var i = 0, searchtext = "";
	     var querystring = unescape(location.search).split("&");
	    
	    while(querystring[i] && searchtext == "")
	    {
	        if(querystring[i].search("searchtext") == 0 || querystring[i].search("searchtext") == 1)
	        {
	            searchtext = querystring[i].split("=")[1];
	        }
	        i++;
	    }
    
    currentWindowHeight = 0;
    var httpRequest = createHttpRequest();
    if (!httpRequest) 
    {
        document.getElementById('secondarycontent').innerHTML = "Error: Unable to create an XMLHTTP instance";
    }
    httpRequest.open('GET', "searchalerts.aspx?alertId=" + alertId + "&searchtext="+searchtext, false);
    httpRequest.send('');
    var result=httpRequest.responseText;
    result=result.replace(/<[/]{0,1}(form|Form)[^><]*>/g, "");
    document.getElementById('secondarycontent').innerHTML =result ;
    chktitle="0";
    window.location.hash = "hit"
   // getAlerts();
    return false;
    }

function goToHitNumber(newhit) 
{
	if (document.getElementById("hitspan"+newhit)) {
		document.getElementById("hitspan"+newhit).className = "highlightover";
		document.getElementById("hitprev"+newhit).src = "/images/prover.gif";
		document.getElementById("hitnext"+newhit).src = "/images/nxover.gif";
	
		lasthit = newhit;
	}
}

function goToHit(which) 
{	
	if (window.location.hash.match(/hit(\d)+/))
	{
		currenthit = window.location.hash.match(/(\d*)$/)[1];
	}
	else 
	{
		var section = document.getElementById("contents_sec_" + window.location.hash.replace("#","").toLowerCase());
		if (section) 
		{
			var hitas = section.getElementsByTagName("A");
			if (hitas) 
			{
				for (var i = 0; i < hitas.length; i++) 
				{
					if (hitas[i].name.match(/hit(\d)+/)) 
					{
						currenthit = hitas[i].name.match(/(\d*)$/)[1];
						break;
					}
				}
			}
		}
	}
	
	if (currenthit=="") currenthit = 1;
	if (which=="prev") currenthit--; else currenthit++;
	
	if (document.getElementById("hit"+currenthit)) 
	{
		if (lasthit) 
		{
			document.getElementById("hitspan"+lasthit).className="highlight";
			document.getElementById("hitprev"+lasthit).src="/images/pr.gif";
			document.getElementById("hitnext"+lasthit).src="/images/nx.gif";	
		}
		
		goToHitNumber(currenthit);
		
		window.location.hash = "hit" + currenthit;
		
		var sec = document.getElementById("hit" + currenthit);
		while (sec && (!sec.id || !sec.id.match(/^contents_sec_/))) 
		{
			sec = sec.parentNode;
		}
		
		if (sec) 
		{
			var newlink = sec.id.match(/^contents_sec_([^\.]+\.){3}(.*)$/)[2];
				
			var beginning = newlink.match(/^([^\.]+\.){1,2}/);
			if (beginning) beginning = beginning[0]; else beginning = "";
			var ending = newlink.match(/^([^\.]\.){2}(.*)/);
			if (ending) ending = ending[0]; else ending = "";
			
			newlink = beginning.toUpperCase() + ending;			
		}
		
		updateContentSeparatorTitle();
	}
	else
	{
	    if (which == "prev")
	    {
	        alert("This is the first hit in the current result.");
	    }
	    else
	    {
	        alert("This is the last hit in the current result.");
	    }
	    
	}
}

function goToDocument(direction)
{

    if(document.getElementById('ctl00_ContentPlaceHolder_hdnCount')!=null)
        {
        documentnumbertotal = parseInt(document.getElementById('ctl00_ContentPlaceHolder_hdnCount').value);
        }
        
    if(documentnumbertotal)
    {
        goToSearchResult(direction);
    }
    else // navigate statutes on summary page
    {
        var URL = "statuteajax.aspx?state=" + escape(document.getElementById("strCurrentState").value) + "&cite=" + escape(document.getElementById("strLong").value) + "&searchtext=qwerty&direction=" + direction;
        
        var httpRequest = createHttpRequest();

        if (!httpRequest) 
        {
            document.getElementById('secondarycontent').innerHTML = "Error: Unable to create an XMLHTTP instance";
        }
        
        httpRequest.open('GET', URL, false);
        httpRequest.send('');
         
        document.getElementById('secondarycontent').innerHTML = httpRequest.responseText;
        document.getElementById('secondarycontent').scrollTop = 0;
        
        updateContentSeparatorTitle();
    }
    
    var res=document.getElementById("strsyncsummary").value;
     if(res=="true")
     {
      document.getElementById("spansyncsummary").style.display = "none";
     }
     else
     {
      document.getElementById("spansyncsummary").style.display = "block";
     }
}

function goToSearchResult(direction)
{
    
    var newdocumentnumber;
        
    if(direction == 'prev')
    {
        newdocumentnumber = documentnumber - 1;
    }
    else
    {
        newdocumentnumber = documentnumber + 1;
    }
    
    if(newdocumentnumber < 1)
    {
        alert("This is the first result.");
    }
    else if (newdocumentnumber > documentnumbertotal)
    {
        alert("This is the last result.");
    }
    else
    {
            
        var link = document.getElementById("trDoc" + newdocumentnumber).getElementsByTagName("A")[0];
        
        if(link)
        {
            currenthit = 1;
            if(link.dispatchEvent)
            {
            
            if(link.href.indexOf('.pdf')!= -1)
                {
                     window.open(link.href);
                     return false;
                }
                else
                {
                    var evt = document.createEvent("MouseEvents");
                    evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
                    link.dispatchEvent(evt);
                }    
            }
            else if(link.fireEvent)
            {
               if(link.href.indexOf('.pdf')!= -1)
                {
                     window.open(link.href);
                     return false;
                }
                else
                {
                    link.fireEvent("onclick"); 
                    return false;
                }    
                
            }
        }
    }
}

function updateContentSeparatorTitle()
{
    if(document.getElementById("strLong"))
    {
        document.getElementById('contentseparatortitle').innerHTML = document.getElementById("strLong").value;
    }
    else
    {
        document.getElementById('contentseparatortitle').innerHTML = "Scope";
    }
    
    if(document.getElementById("strHits").value > 0)
    {
        document.getElementById('contentseparatortitle').innerHTML += " | Hit ";
        
        if(lasthit == null)
        {
            document.getElementById('contentseparatortitle').innerHTML += "1";
        }
        else
        {
            document.getElementById('contentseparatortitle').innerHTML += lasthit;
        }
        
        document.getElementById('contentseparatortitle').innerHTML += " of " + document.getElementById("strHits").value + " in " + documentnumber;
    }
    
    updateSplitBarSummary()
}

function updateTopBarSummary()
{
    var title = document.getElementById(summarytitle);
    var filter = "";
    if(title.innerHTML.search("Filter:") > -1)
    {
        filter = title.innerHTML.substr(title.innerHTML.indexOf("Filter:"),title.innerHTML.length - 1);
        title.innerHTML = title.innerHTML.substr(0,title.innerHTML.indexOf("Filter:"));
    }
    var titleparts = title.innerHTML.split(":");
    var section = getSummarySection("content");
    var sectionparts = section.split(".");
    
    section = "";
    
    for(var i = 3; i < sectionparts.length; i++)
    {
        if (i==3||i==4) {
			section += sectionparts[i].toUpperCase() + ".";
		} else {
			section += sectionparts[i] + ".";
		}
    }
    
    section = section.substr(0, section.length - 1);
    
    title.innerHTML = titleparts[0] + ": " + section + " " + filter;
}

function updateSplitBarSummary()
{
         if(chktitle=="1")
        {return;
        }
    var title = document.getElementById("contentseparatortitle");
    var titlestring=title.innerHTML;
 //   titlestring=titlestring.replace(/ | Filter: .*/,"");
    var titleparts = titlestring.split("|");
    var titlesubparts = titleparts[0].split(":");
    var section = getSummarySection("secondarycontent");
    
    var sectionparts = section.split(".");
    
    section = "";
    
    for(var i = 3; i < sectionparts.length; i++)
    {
		if (i==3||i==4) {
			section += sectionparts[i].toUpperCase() + ".";
		} else {
			section += sectionparts[i] + ".";
		}
    }
    
    section = section.substr(0, section.length - 1);
    
    if(section != "")
    {
        title.innerHTML = titlesubparts[0] + ": " + section;
        
        if(titleparts[1])
        {
            title.innerHTML = title.innerHTML + "|" + titleparts[1];
        } 
    }
    
    if (document.getElementById("strFilter") && document.getElementById("strFilter").value!="") {
		title.innerHTML=title.innerHTML + " | " + document.getElementById("strFilter").value;
    }
}

function getSummarySection(pane)
{
    var anchorstemp = new Array();
    var anchorindex;
    
    // only get anchors on first run
    if(anchors.length == 0)
    {
        anchorstemp = document.getElementById(pane).getElementsByTagName("a");
        
        // only keep anchors that have names and are visible
        for(var i = 0; i < anchorstemp.length; i++)
        {
            if(anchorstemp[i].name && !anchorstemp[i].name.match(/hit(\d)+/) && anchorVisible(anchorstemp[i]))
            {
                anchors.push(anchorstemp[i]);
                anchors[anchors.length - 1].position = crumbGetY(anchors[anchors.length - 1]);
            }
        }
    }
    
    anchorindex = getBinaryAnchorIndex(pane);
    
    if (anchorindex)  
        return anchors[anchorindex].name;
    else
        return "";
}

function getBinaryAnchorIndex(pane)
{
    var top = -1,
        bottom = anchors.length,
        mid;
    var anchory;
    var contenttopy = getScrollTop(pane);
    var contentbottomy = contenttopy + document.getElementById(pane).offsetHeight;
    while(bottom - top > 1)
    {
        mid = (top + bottom) >>> 1;
        
        anchory = anchors[mid].position + 5;
        
        if(anchory > contentbottomy)
            bottom = mid;
        else if(anchory < contenttopy)
            top = mid;
        else
        {
            while((anchory < contentbottomy) && (anchory > contenttopy))
            {
                mid--;
                if(mid > -1)
                {
                    anchory = anchors[mid].position + 5;
                }
                else
                {
                    anchory = -10;
                }
            }
            
            return mid + 1;
        }
    }

    if(mid > -1)
        return mid;
    else
        return false;
}

// returns element position in pixels
function crumbGetY(node) {
	var y=node.offsetTop;
	var parent=node.offsetParent;
	
	if(parent)
	{
	    while ((parent.id != "content") && (parent.id != "secondarycontent"))
	    {
		    if (!parent.attributes["offsetTopCached"]) {
			    parent.setAttribute("offsetTopCached",parent.offsetTop);
		    }
		    y+=parseInt(parent.attributes["offsetTopCached"].value,10);
    		
		    if (parent.currentStyle && parent.currentStyle.borderTopWidth && !isNaN(parseInt(parent.currentStyle.borderTopWidth))) {
			    y+=parseInt(parent.currentStyle.borderTopWidth);
		    }
    		
		    parent=parent.offsetParent;
	    }
	}
	else
	{
	    var i = 0;
	}
	return y;
}

function anchorVisible(node) 
{
    while (node.parentNode)
    {
        if((node.parentNode.className) && (node.parentNode.className.search("contentsHidden") > -1))
        {
            return false;
        }
        
        node = node.parentNode;
    }
    
    return true;
}

function getAlertDetails(changeEventId, displayTitle)
{
    document.getElementById("spanSeparatorNav").style.display = "none";
    
    var URL = "alertDetailAjax.aspx?changeEventId=" + changeEventId;
    
    var httpRequest = createHttpRequest();

    if (!httpRequest) 
    {
        document.getElementById('secondarycontent').innerHTML = "Error: Unable to create an XMLHTTP instance";
    }
    
    httpRequest.open('GET', URL, false);
    httpRequest.send('');
     document.getElementById("spansyncsummary").style.display = "none";
    document.getElementById('contentseparatortitle').innerHTML = displayTitle;
    document.getElementById('secondarycontent').innerHTML = httpRequest.responseText;
chktitle="0";
    document.getElementById("spantagPrint").style.display = "none";
    document.getElementById('secondarycontent').style.display = "block";
    document.getElementById('contentseparator').style.display = "block";
    document.getElementById("spanHitNavR").style.display = "none";
    document.getElementById("spanHitNavL").style.display = "none";
    
    /*if(document.getElementById('strFirstHit'))
    {
        currenthit = document.getElementById('strFirstHit').value;
    
        if(isNaN(currenthit))
        {
            currenthit = 0;
        }
        else
        {
            goToHitNumber(currenthit);
        }
        
        updateContentSeparatorTitle();
        
        window.location.hash = "hit" + currenthit;
    }*/
    
    // reset this variable so adjustScroll() runs
    currentWindowHeight = 0;
    
    // reset this array so it gets repopulated on this new summary
    anchors = [];
    
    return false;
}

function gotoAlertsummary(jumplink,title)
{
    var lsRegExp = /\+/g;
    jumplink  = unescape(String(jumplink).replace(lsRegExp, " ")); 
    title  = unescape(String(title).replace(lsRegExp, " ")); 
    
    var URL = "summaryajax.aspx?jumplink=" + jumplink.split('#')[0]
    var httpRequest = createHttpRequest();

    if (!httpRequest) 
    {
        document.getElementById('secondarycontent').innerHTML = "Error: Unable to create an XMLHTTP instance";
    }
    
    httpRequest.open('GET', URL, false);
    httpRequest.send('');
     chktitle="0";
    document.getElementById('secondarycontent').innerHTML = httpRequest.responseText;
    document.getElementById('secondarycontent').style.display = "block";
    document.getElementById('contentseparator').style.display = "block";
    document.getElementById("spanHitNavR").style.display = "none";
    document.getElementById("spanHitNavL").style.display = "none";
    document.getElementById("imgSplitRR").style.display = "none";
    document.getElementById("imgSplitLL").style.display = "none";
    document.getElementById("spantagPrint").style.display = "inline";
         document.getElementById('secondarycontent').scrollTop=0;
     anchors = [];
    window.location.hash = jumplink.split('#')[1];
     
    window.focus();
        
    currenthit = jumplink.split('#')[1].replace(/\+/g,"");    
   
    window.location.hash ="#" + jumplink.split('#')[1].replace(/\+/g,"");
 
    Summaryhit = true
    document.getElementById('contentseparatortitle').innerHTML = title 
    updateSplitBarSummary() 
            
    // reset this variable so adjustScroll() runs
    currentWindowHeight = 0;
    
    // reset this array so it gets repopulated on this new summary
    anchors = [];
//rakesh change for maximize and minimise and sync. summary
     // document.getElementById('secondarycontent').scrollTop=0;
      var res=document.getElementById("strsyncsummary").value;
     if(res=="true")
     {
      document.getElementById("spansyncsummary").style.display = "none";
     }
     else
     {
      document.getElementById("spansyncsummary").style.display = "block";
     }
      //end
      

    return false;
}



