﻿//http://www.codeproject.com/KB/ajax/AjaxWebServices.aspx
 
  var req;
  var response;
  var bGoodGov=0;
  var bWhatTheGov=0;
  var sWhtGovUrl;
  var sOtherUrl;
  
  
  
  function loadResults(url) 
  {
      // document.getElementById('ContentBox').innerHTML="<span class='hotel' style='width:100%;height:100%'><center  style='width:100%;margin-top:50px;'> Loading. Please wait... <br /><img src='/Themes/default/images/loading.gif' align='middle'></center></span>";
      document.body.style.cursor = "wait";
      if (window.XMLHttpRequest) // branch for native XMLHttpRequest object
      {
          req = new XMLHttpRequest();
          req.onreadystatechange = processReqChange;
          req.open("GET", url, true);
          req.send(null);
      
      }
      else if (window.ActiveXObject) // branch for IE/Windows ActiveX version 
      {
          isIE = true;
          req = new ActiveXObject("Microsoft.XMLHTTP");
          if (req) 
          {
              req.onreadystatechange = processReqChange;
              req.open("GET", url, true);
              req.send();
          }
      }
  }
 
  function processReqChange() 
  {
      if (req.readyState == 4) 
      {
          if (req.status == 200) 
          {
              document.getElementById('ContentBox').innerHTML = req.responseText;
              document.body.style.cursor = "";
          } 
          else 
          {
              //No response
          }
      }
  }
  
  function LoadResultAgencyIssue(GoodGovUrl,WhatTheGovUrl,OthersUrl)
  {
    LoadResultsGoodGov(GoodGovUrl);
    sWhtGovUrl=WhatTheGovUrl;
    sOtherUrl=OthersUrl;
  }
    
  function LoadResultsGoodGov(url) 
  {
        //document.getElementById('ContentBoxGoodGov').innerHTML="<span class='hotel' style='width:100%;height:100%'><center  style='width:100%;margin-top:50px;'> Loading. Please wait... <br /><img src='/Themes/default/images/loading.gif' align='middle'></center></span>";
      document.body.style.cursor = "wait";
      if (window.XMLHttpRequest) // branch for native XMLHttpRequest object
      {
          req = new XMLHttpRequest();
          req.onreadystatechange = ProcessReqChangeGoodGov;
          req.open("GET", url, true);
          req.send(null);
      
      }
      else if (window.ActiveXObject) // branch for IE/Windows ActiveX version 
      {
          isIE = true;
          req = new ActiveXObject("Microsoft.XMLHTTP");
          if (req) 
          {
              req.onreadystatechange = ProcessReqChangeGoodGov;
              req.open("GET", url, true);
              req.send();
          }
      }
  }

  function ProcessReqChangeGoodGov() 
  {
      if (req.readyState == 4) 
      {
          if (req.status == 200) 
          {
                document.getElementById('ContentBoxGoodGov').innerHTML=req.responseText;
                if(bGoodGov==0)
                {
                    LoadResultsWhatTheGov(sWhtGovUrl);
                    bGoodGov=1;
                }
          } 
          else 
          {
              //No response
          }
      }
  }
    
  function LoadResultsWhatTheGov(url) 
  {
      // document.getElementById('ContentBoxWhatTheGov').innerHTML="<span class='hotel' style='width:100%;height:100%'><center  style='width:100%;margin-top:50px;'> Loading. Please wait... <br /><img src='/Themes/default/images/loading.gif' align='middle'></center></span>";
      document.body.style.cursor = "wait";
      if (window.XMLHttpRequest) // branch for native XMLHttpRequest object
      {
          req = new XMLHttpRequest();
          req.onreadystatechange = ProcessReqChangeTheGov;
          req.open("GET", url, true);
          req.send(null);
      
      }
      else if (window.ActiveXObject) // branch for IE/Windows ActiveX version 
      {
          isIE = true;
          req = new ActiveXObject("Microsoft.XMLHTTP");
          if (req) 
          {
              req.onreadystatechange = ProcessReqChangeTheGov;
              req.open("GET", url, true);
              req.send();
          }
      }
  }

   function ProcessReqChangeTheGov() 
  {
      if (req.readyState == 4) 
      {
          //document.getElementById('<%=hdnListOrder.ClientID%>').value="2";
          //varlorder.value = "2";
          //AgencyIssueFlag="2";
          if (req.status == 200) 
          {
                document.getElementById('ContentBoxWhatTheGov').innerHTML=req.responseText;
                if(bWhatTheGov==0)
                {
                    LoadResultsOther(sOtherUrl);
                    bWhatTheGov=1;    
                }
          } 
          else 
          {
              //No response
          }
      }
  }
  
  
  
  
  
  function LoadResultsOther(url) 
  {
      //document.getElementById('ContentBoxOther').innerHTML="<span class='hotel' style='width:100%;height:100%'><center  style='width:100%;margin-top:50px;'> Loading. Please wait... <br /><img src='/Themes/default/images/loading.gif' align='middle'></center></span>";
      document.body.style.cursor = "wait";
      if (window.XMLHttpRequest) // branch for native XMLHttpRequest object
      {
          req = new XMLHttpRequest();
          req.onreadystatechange = ProcessReqChangeOther;
          req.open("GET", url, true);
          req.send(null);
      
      }
      else if (window.ActiveXObject) // branch for IE/Windows ActiveX version 
      {
          isIE = true;
          req = new ActiveXObject("Microsoft.XMLHTTP");
          if (req) 
          {
              req.onreadystatechange = ProcessReqChangeOther;
              req.open("GET", url, true);
              req.send();
          }
      }
  }

   function ProcessReqChangeOther() 
  {
      if (req.readyState == 4) 
      {
          if (req.status == 200) 
          {
              document.getElementById('ContentBoxOther').innerHTML = req.responseText;
              document.body.style.cursor = "";
          } 
          else 
          {
              //No response
          }
      }
  }
  

   
/*If you just want to log a message to the server:*/

function log(message) 
{
    var client = new XMLHttpRequest();
    client.open("POST", "/log");
    client.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
    client.send(message);
}

function getValues()
{
    var objChk='';var objCounter=0;
    for(i=0;i<document.forms[0].elements.length;i++)
    {   
        if(document.forms[0].elements[i].type=="checkbox")
        {
            if (document.forms[0].elements[i].id == "chk8") 
            {
                if (document.forms[0].elements[i].checked) 
                {
                    objCounter+=1;
                    objChk += document.forms[0].elements[i].value +'|';
                }
            }
        }
    }
    if(objCounter>0)
    {
        map_open(objChk );return false;
    }
    else{alert("No values to display.")}
}


/*CODE FOR POP UP ON MOUSEOVER*/

function showPopUp(id,ctl)
{

    var objdiv=document.getElementById(id+'bubble_tooltip1');
    
    if(objdiv!=null){objdiv.style.display = 'block';}
}
function hidePopUp(id)
{
    var objdiv=document.getElementById(id+'bubble_tooltip1');
    if(objdiv!=null){objdiv.style.display = 'none';}
}
function setborder(id,status)
{
    for(i=0;i<document.forms[0].elements.length;i++)
    {   
        if(document.forms[0].elements[i].type=="checkbox")
        {
            if (document.forms[0].elements[i].id == "chk8") 
            {
                if (document.forms[0].elements[i].checked) 
                {
                    var objid = document.forms[0].elements[i].name
                    var objdiv = document.getElementById(objid+'border');
                    if(objdiv!=null){objdiv.className = 'black';}
                }
                else
                {
                    var objid = document.forms[0].elements[i].name
                    var objdiv = document.getElementById(objid+'border');
                    if(objdiv!=null){objdiv.className = 'listing_inner_new';}
                }
            }
        }
    }
}