﻿// JScript File
function openCaseD(sKeyword,sGuid,rDCr)
{
    window.open("/search/caselaw/showCase.aspx?r=" + rDCr.toString() + "&k=" + sKeyword + "&g=" + sGuid,"Caselaw","width=500,height=375,toolbars=no,menubar=no,scrollbars=yes");
}
function openCase(sID)
{
    if(sID!='')
    {
        window.open("/search/caselaw?" + sID,"Caselaw");
    }
}
function showdialog(objS)
{
   if (objS.value!="0" && objS.value!="4")
   {
    if (window.confirm("To use this facility you have to logged in. Do you want to login?"))
        window.parent.window.__doPostBack(this.name,'');
    }
    else
        window.parent.window.__doPostBack(this.name,'');
}

function OpenJudge(aID)
{
    document.getElementById("sideHead").innerText = 'Judge Details';
    if(screen.width==800)
    {
        document.getElementById("framAct").src="/search/caselaw/judge.aspx?" + aID;   
        ActivateDiv800();
    }
    else    
    {    
        ActivateDiv();        
        document.getElementById("framAct").src="/search/caselaw/judge.aspx?" + aID;   
    }
}
function ExecuteHistory(sID,stype)
{
    window.parent.document.getElementById("ctl00_guestMaster_hdnShowSearch").value = '1';
    window.parent.document.getElementById("ctl00_guestMaster_hdnSHID").value = sID;
    if (stype == 'Caselaw')
    window.parent.window.__doPostBack('ctl00$guestMaster$lblvWCaselaw','');
    if (stype == 'Acts')
    window.parent.window.__doPostBack('ctl00$guestMaster$lnkvWActs','');
    if (stype == 'Rules')
    window.parent.window.__doPostBack('ctl00$guestMaster$lnkvWrules','');
    if (stype == 'N')
    window.parent.window.__doPostBack('ctl00$guestMaster$lblvWN','');
    if (stype == 'C')
    window.parent.window.__doPostBack('ctl00$guestMaster$lblvWN','')
    if (stype == 'T')
    window.parent.window.__doPostBack('ctl00$guestMaster$lblvWN','')
}
function ExecuteAndEditHistory(sID,stype)
{   
    window.parent.document.getElementById("ctl00_guestMaster_hdnSHID").value = sID;
    window.parent.document.getElementById("ctl00_guestMaster_hdnEditHistory").value = '1';
    if (stype=='Caselaw')
    {
        window.parent.window.__doPostBack('ctl00$guestMaster$lblvWCaselaw','');
    }
   if(stype=='Acts')
    {
        window.parent.window.__doPostBack('ctl00$guestMaster$lnkvWActs','');
    }
   if (stype=='Rules')
    {
        window.parent.window.__doPostBack('ctl00$guestMaster$lnkvWrules',''); 
    }
    if (stype=='N')
    {
        window.parent.window.__doPostBack('ctl00$guestMaster$lblvWN',''); 
    }
    if (stype == 'C')
    {
        window.parent.window.__doPostBack('ctl00$guestMaster$lblvWN','') 
    }
    if (stype == 'T')
    {
       window.parent.window.__doPostBack('ctl00$guestMaster$lblvWN','') 
    }
}
function OpenHistory(aID,sID,stype)
{
    if(sID>0)
    {
        document.getElementById("sideHead").innerText = 'Research History';
        if(screen.width==800)
        {
           document.getElementById("framAct").src="/search/" + stype + "/shistory.aspx?aID=" + aID ; 
           
            ActivateDiv800();
        }
        else
        {
            ActivateDiv();
           document.getElementById("framAct").src="/search/" + stype + "/shistory.aspx?aID=" + aID ;   
       }
   }
   else
        alert("Please login to view the search history");
}
function __Open_aCt(aID)
{
    document.getElementById("sideHead").innerText = 'Section Details';
    //ShowPopUp();
    if(screen.width==800)
    {
        document.getElementById("IfrmPop").src="/search/caselaw/act.aspx?" + aID;   
      ActivateDiv800();
    }
    else    
    {
       ActivateDiv();
       document.getElementById("framAct").src="/search/caselaw/act.aspx?" + aID;   
   }
}
function ShowPopUp()
{
    var sDiv = document.getElementById("divPopUp");
    var sFrame = document.getElementById("IfrmPop");
    if(tempS<200)
        sDiv.style.top = ((tempY+tempS)-290).toString() + 'px';
    else
        sDiv.style.top = ((tempY+tempS)+10).toString() + 'px';
    sDiv.style.height=263;
    sDiv.style.left=(tempX-30).toString() + 'px';
    sFrame.style.height=263;    
    sFrame.style.width='352px';
    if(!IE)
    {
        sDiv.style.display ="visible";
        sFrame.style.display ="visible";
    }
    else
    {
        sDiv.style.visibility ="visible";
        sFrame.style.visibility ="visible";
    }
}
function __Close_PopUp()
{
    document.getElementById("IfrmPop").style.width="0px";
    document.getElementById("IfrmPop").src="about:blank";
    document.getElementById("divPopUp").style.visibility="hidden";
    document.getElementById("IfrmPop").style.visibility="hidden";
}
function __Close_Me()
{   
    document.getElementById("framAct").style.width="0px";
    document.getElementById("framAct").src="about:blank";
    document.getElementById("divAct").style.visibility="hidden";
    document.getElementById("framAct").style.visibility="hidden";
}
function ActivateDiv()
{  
      var myWidth = 0, myHeight = 0;
      if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
      } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
      } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
      }      
      var objB;
      if (document.body.scrollTop) 
        objB = document.body;
      else if(document.documentElement.scrollTop)
        objB = document.documentElement;
      else
        objB = document.body;       
      if(objB.scrollTop<105)
      {
         document.getElementById("divAct").style.top = 105;
         document.getElementById("divAct").style.height=460;
         document.getElementById("framAct").style.height=460;
         var sWidth = myWidth-770;
         document.getElementById("divAct").style.left="767px";
         document.getElementById("framAct").style.width=sWidth;
         if(document.getElementById("framAct").style.height=='')
         {
            var myH = myHeight-35;
            document.getElementById("divAct").style.top=  objB.scrollTop.toString() + 'px';
            document.getElementById("divAct").style.height=myH.toString() + 'px';
            document.getElementById("framAct").style.height=myH.toString() + 'px';
            sWidth = sWidth - 20;
            document.getElementById("divAct").style.width= sWidth.toString() + 'px';
            document.getElementById("framAct").style.width= sWidth.toString() + 'px';        
            document.getElementById("framAct").style.display ="visible";
            document.getElementById("divAct").style.display ="visible";
         }
         else
         {
            document.getElementById("framAct").style.visibility ="visible";
            document.getElementById("divAct").style.visibility="visible";
         }
         if(document.getElementById("framAct").style.width=='0px')
         {
            var myH = myHeight-35;
            document.getElementById("divAct").style.top=  objB.scrollTop.toString() + 'px';
            document.getElementById("divAct").style.height=myH.toString() + 'px';
            document.getElementById("framAct").style.height=myH.toString() + 'px';
            sWidth = sWidth - 20;
            document.getElementById("divAct").style.width= sWidth.toString() + 'px';
            document.getElementById("framAct").style.width= sWidth.toString() + 'px';        
            document.getElementById("framAct").style.display ="visible";
            document.getElementById("divAct").style.display ="visible";
         }              
     }
     else if(objB.scrollTop>105)
     {
         document.getElementById("divAct").style.top = objB.scrollTop.toString() + ' px';          
         document.getElementById("divAct").style.height=460;
         document.getElementById("framAct").style.height=460;         
         var sWidth = myWidth-770;
         document.getElementById("divAct").style.left="767px";
         document.getElementById("framAct").style.width=sWidth;         
         if(document.getElementById("framAct").style.height=='')
         {
            var myH = myHeight-35;
            document.getElementById("divAct").style.top=  objB.scrollTop.toString() + 'px';
            document.getElementById("divAct").style.height=myH.toString() + 'px';
            document.getElementById("framAct").style.height=myH.toString() + 'px';
            sWidth = sWidth - 20;
            document.getElementById("divAct").style.width= sWidth.toString() + 'px';
            document.getElementById("framAct").style.width= sWidth.toString() + 'px';        
            document.getElementById("framAct").style.display ="visible";
            document.getElementById("divAct").style.display ="visible";
         }
         else
         {
            document.getElementById("framAct").style.visibility ="visible";
            document.getElementById("divAct").style.visibility="visible";
         }
         if(document.getElementById("framAct").style.width=='0px')
         {
            var myH = myHeight-35;
            document.getElementById("divAct").style.top=  objB.scrollTop.toString() + 'px';
            document.getElementById("divAct").style.height=myH.toString() + 'px';
            document.getElementById("framAct").style.height=myH.toString() + 'px';
            sWidth = sWidth - 20;
            document.getElementById("divAct").style.width= sWidth.toString() + 'px';
            document.getElementById("framAct").style.width= sWidth.toString() + 'px';        
            document.getElementById("framAct").style.display ="visible";
            document.getElementById("divAct").style.display ="visible";
         }         
     }
}
function ActivateDiv800()
{   
    document.getElementById("divAct").style.height="200px";
    document.getElementById("framAct").style.height="200px";
    document.getElementById("divAct").style.left="400px";
    document.getElementById("framAct").style.width="300px";
     var objB;
      if (document.body.scrollTop) 
        objB = document.body;
      else if(document.documentElement.scrollTop)
        objB = document.documentElement;
      else
        objB = document.body;
    document.getElementById("divAct").style.top = objB.scrollTop + 10;
    document.getElementById("divAct").style.visibility="visible";
    document.getElementById("framAct").style.visibility ="visible";
}
function __Open_Cases(aID)
{
    document.getElementById("sideHead").innerText = 'Related Caselaws';
    if(screen.width==800)
        {
        document.getElementById("framAct").src="/search/acts/Case.aspx?" + aID;
        ActivateDiv800();
        }
    else    
    {
        document.getElementById("framAct").src="/search/acts/Case.aspx?" + aID;
        ActivateDiv();
    }       
}
function __Open_CasesOnDiv(aID)
{
    window.location.href="/search/acts/Case.aspx?" + aID; 
}
function __Open_Legislation(aID,sType)
{
    if(sType == '2')
        window.open("/search/acts?" + aID,"Act");
    else if(sType=='3')
        window.open("/search/rules?" + aID,"Rule");
    else if(sType=='10')
        window.open("/search/bills?" + aID,"Bills");
}
function __Open_Section(sID)
{    
    document.getElementById('ctl00$guestMaster$BLRLinkHidden').value=sID;
    __doPostBack('ctl00$guestMaster$BLRLink','');
}

function __Open_Industry(sD)
{
    document.getElementById("sideHead").innerText = 'Find an Industry';    
    if(screen.width==800)
    {
        document.getElementById("framAct").src="/search/" + sD + "/industry.aspx?" + document.getElementById('ctl00_guestMaster_txtIndustry').value; 
        ActivateDiv800()
    }
    else    
    {
        document.getElementById("framAct").src="/search/" + sD + "/industry.aspx?" + document.getElementById('ctl00_guestMaster_txtIndustry').value; 
        ActivateDiv();
    }
}

function openCourt(sObj)
{
    document.getElementById("sideHead").innerText = 'Select Court';
    if(screen.width==800)
    {
        document.getElementById("framAct").src="/search/caselaw/courts.aspx?" + sObj;
        ActivateDiv800();
    }
    else    
    {
        document.getElementById("framAct").src="/search/caselaw/courts.aspx?" + sObj; 
        ActivateDiv();
    }    
}
function __Add_Court(sID,sCourt)
{
    var sCourts = window.parent.document.getElementById(document.getElementById("hdnReturn").value).innerHTML;    
    var sCID = window.parent.document.getElementById('ctl00_guestMaster_hdnCourt').value;
    if(sCID.indexOf(',' + sID + ' ')<0)
    {            
        window.parent.document.getElementById('ctl00_guestMaster_hdnCourt').value +=',' + sID + ' ';
        if (sCourts=='All Courts')
           sCourts = sCourt + '<sup><a href="javascript:__removeCourt(\'' + sID + '\',\'' + sCourt + '\')" class="txtRed" Title="Remove Court">x</a></sup>';
        else
            sCourts +='<br>' + sCourt + '<sup><a href="javascript:__removeCourt(\'' + sID + '\',\'' + sCourt + '\')" class="txtRed" Title="Remove Court">x</a></sup>';
        window.parent.document.getElementById(document.getElementById("hdnReturn").value).innerHTML = sCourts;
    }
}
function __removeCourt(sID,sCourt)
{
    var sCID = document.getElementById('ctl00_guestMaster_hdnCourt').value;
    var objReg = new RegExp(',' + sID + ' ','gi')
    sCID = sCID.replace(objReg,'');
    var sMCourt = document.getElementById('ctl00_guestMaster_divCourt').innerHTML;
    objReg = new RegExp(sCourt + '<[^>]*><[^>]*>[a-z]<[^>]*><[^>]*>(<[^>]*>)?','gi');    
    sMCourt = sMCourt.replace(objReg,'');
    document.getElementById('ctl00_guestMaster_divCourt').innerHTML = sMCourt;
    document.getElementById('ctl00_guestMaster_hdnCourt').value = sCID;    
    var sText = document.getElementById('ctl00_guestMaster_divCourt').innerText;
    sText = sText.replace(' ','');
    sText = sText.replace(' ','');
    if(sText=='' || sText =='undefined')
    {
        document.getElementById('ctl00_guestMaster_divCourt').innerText='All Courts';
        document.getElementById('ctl00_guestMaster_hdnCourt').value ='';    
    }
}
function __Open_Keyword(sID)
{
    document.getElementById("sideHead").innerText = 'Find a keyword';
    if(screen.width==800)        
    {
        document.getElementById("framAct").src="/search/caselaw/keyword.aspx?" + document.getElementById(sID).value; 
        ActivateDiv800()
    }
    else    
    {
        document.getElementById("framAct").src="/search/caselaw/keyword.aspx?" + document.getElementById(sID).value; 
        ActivateDiv();
     }
}
function __Open_Keyword1(sID,sTitle)
{
    document.getElementById("sideHead").innerText = sTitle;
    if(screen.width==800)        
    {
        document.getElementById("framAct").src="/search/caselaw/keyword.aspx?" + document.getElementById(sID).value; 
        ActivateDiv800()
    }
    else    
    {
        document.getElementById("framAct").src="/search/caselaw/keyword.aspx?" + document.getElementById(sID).value; 
        ActivateDiv();
     }
}
function __Open_Quick_Keyword(sID)
{
    document.getElementById("sideHead").innerText = 'Find a keyword';
    if(screen.width==800)        
    {
        document.getElementById("framAct").src="/search/Quick/keyword.aspx?" + document.getElementById(sID).value; 
        ActivateDiv800()
    }
    else    
    {
        document.getElementById("framAct").src="/search/caselaw/keyword.aspx?" + document.getElementById(sID).value; 
        ActivateDiv();
     }
}
function __Open_Keyword1(sID)
{    document.getElementById("sideHead").innerText = 'Find a keyword';
    if(screen.width==800)        
    {
        document.getElementById("framAct").src="/search/keyword.aspx?" + document.getElementById(sID).value; 
        ActivateDiv800()
    }
    else    
    {
        document.getElementById("framAct").src="/search/keyword.aspx?" + document.getElementById(sID).value; 
        ActivateDiv();
     }
}
function __addIndustry(sIndustry)
{
    window.parent.document.getElementById('ctl00_guestMaster_txtIndustry').value=sIndustry;
    window.parent.document.getElementById("framAct").style.width="0px";
    window.parent.document.getElementById("framAct").src="about:blank";
    window.parent.document.getElementById("divAct").style.visibility="hidden";
    window.parent.document.getElementById("framAct").style.visibility="hidden";
}
function __addKeyword(sKeyword)
{
    if(window.parent.document.getElementById('ctl00_guestMaster_txtKeywords'))
        window.parent.document.getElementById('ctl00_guestMaster_txtKeywords').value=sKeyword;
    if(window.parent.document.getElementById('ctl00_guestMaster_txtTitle'))
        window.parent.document.getElementById('ctl00_guestMaster_txtTitle').value=sKeyword;
    if(window.parent.document.getElementById('ctl00_guestMaster_txtKeywords1'))
        window.parent.document.getElementById('ctl00_guestMaster_txtKeywords1').value=sKeyword;
    window.parent.document.getElementById("framAct").style.width="0px";
    window.parent.document.getElementById("framAct").src="about:blank";
    window.parent.document.getElementById("divAct").style.visibility="hidden"; 
    window.parent.document.getElementById("framAct").style.visibility="hidden";   
}
