var xmlHttp

function closeAuthor()
{
 document.getElementById("authorbox").innerHTML=null;
}

function addBill(userid,bill,bill_id)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }

var url="billtrack/addbill.php"
url=url+"?bill="+bill 
url=url+"&bill_id="+bill_id
url=url+"&userid="+userid
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChangedAddBill
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChangedAddBill() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("billdash").innerHTML=xmlHttp.responseText;
 } 
}

function newAddBill(userid,bill,refer)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }

   
var url="http://www.aroundthecapitol.com/billtrack/addbillamended.php"
url=url+"?bill="+bill
url=url+"&userid="+userid
url=url+"&sid="+Math.random()

if (refer=="amended") {
document.getElementById("monitor-"+bill).style.display='none';
document.getElementById("monitorremove-"+bill).style.display='inline';
}

xmlHttp.onreadystatechange=stateChangedNewAddBill
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChangedNewAddBill()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
// document.getElementById("billdash").innerHTML=xmlHttp.responseText;
 }
}

function newRemoveBill(userid,bill,refer)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }

var url="http://www.aroundthecapitol.com/billtrack/removebill.php"
url=url+"?userid="+userid
url=url+"&bill="+bill
url=url+"&sid="+Math.random()
url=encodeURI(url)

if (refer=="amended") {
document.getElementById("monitorremove-"+bill).style.display="none";
document.getElementById("monitor-"+bill).style.display="inline";
} 

// xmlHttp.onreadystatechange=stateChangedRemoveBill
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
}
 



function updateBills(userid)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }

var bill = document.getElementById('updatebills').value;

var url="http://www.aroundthecapitol.com/billtrack/updatebills.php"
url=url+"?bill="+bill
url=url+"&userid="+userid
url=url+"&sid="+Math.random()
url=encodeURI(url)
xmlHttp.onreadystatechange=stateChangedUpdateBills
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChangedUpdateBills()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 document.getElementById("updatebillsfeedback").innerHTML=xmlHttp.responseText;  
 window.location("http://www.aroundthecapitol.com/billtrack/");  
 }
}

function GetXmlHttpObject()
{
var xmlHttp = null;

if (window.XMLHttpRequest){

// If IE7, Mozilla, Safari, etc: Use native object
xmlHttp = new XMLHttpRequest(); // no var

}
else if (window.ActiveXObject){

// ...otherwise, use the ActiveX control for IE5.x and IE6
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); // no var

} else {
// no XMLHTTP... leave as null
} 
return xmlHttp;
}


function OLDGetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

function billsByAuthor(author) 
{
xmlHttp=GetXmlHttpObject1()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }

//var author = document.getElementById('author').value;

var url="http://www.aroundthecapitol.com/billtrack/author.php"
url=url+"?author="+author
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged1
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged1()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 document.getElementById("authorbox").innerHTML=xmlHttp.responseText
 }
}

function GetXmlHttpObject1()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

function addBillNote(id)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }

var billnote = document.getElementById('billnote-'+id).value;
var url="http://www.aroundthecapitol.com/billtrack/addbillnote.php"
url=url+"?billnote="+billnote
url=url+"&id="+id
url=url+"&sid="+Math.random()
url=encodeURI(url)
//document.getElementById("messagebox").innerHTML=url;

xmlHttp.onreadystatechange=stateChangedBillNote
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}


function stateChangedBillNote()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 document.getElementById("messagebox").innerHTML=xmlHttp.responseText;
 }
}

function changePosition(id)
{  
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return  
 }
 
var position = document.getElementById('position-'+id).value;
var url="http://www.aroundthecapitol.com/billtrack/changeposition.php"
url=url+"?position="+position
url=url+"&id="+id
url=url+"&sid="+Math.random()
url=encodeURI(url)
//document.getElementById("messagebox").innerHTML=url;
   
xmlHttp.onreadystatechange=stateChangedPosition
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}


function stateChangedPosition()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 document.getElementById("messagebox").innerHTML=xmlHttp.responseText;
 }
}

function emailSubscribe(userid,bill)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }

var thischeckbox='email-'+bill
var checkbox = document.getElementById(thischeckbox).checked
var url="http://www.aroundthecapitol.com/billtrack/emailsubscribe.php"
url=url+"?userid="+userid
url=url+"&bill="+bill
if (checkbox!='true') {
 url=url+"&action=unsubscribe"
}
url=url+"&sid="+Math.random()
url=encodeURI(url)

xmlHttp.onreadystatechange=stateChangedEmailSubscribe
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}  


function stateChangedEmailSubscribe()
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 document.getElementById("messagebox").innerHTML=xmlHttp.responseText;
 }  
}

function removeBill(userid,bill)
{
 new Effect.Opacity(document.getElementById('row-'+bill),{duration:0.5, from:1.0, to:0.7});
 var cleanbill=bill.replace("_"," ")
 var confirmHtml="Are you sure you want to remove " + cleanbill + " from your bill list?<br \>"
 confirmHtml=confirmHtml+"<span style=\"text-decoration: underline;\" onclick=\"confirmRemoveBill('" + userid + "','" + bill + "')\">Yes</span> | <span style=\"text-decoration: underline;\" onclick=\"cancelRemoveBill('" + bill + "')\">No</span>";
 document.getElementById('window-'+bill).style.zIndex="10";
 document.getElementById('window-'+bill).style.height="40";
 document.getElementById('window-'+bill).style.width="580";
 document.getElementById('window-'+bill).style.textAlign="center";
 document.getElementById('window-'+bill).style.fontWeight="bold";
 document.getElementById('window-'+bill).style.backgroundColor="#FFFF33";
 Effect.Grow(document.getElementById('window-'+bill).innerHTML=confirmHtml);
}


function cancelRemoveBill(bill) {
// document.getElementById('window-'+bill).style.display= 'none'
Effect.Squish(document.getElementById('window-'+bill));
 new Effect.Opacity(document.getElementById('row-'+bill),{ from:0.7, to:1});
 document.getElementById('monitor-'+bill).checked=true
 document.getElementById('row-'+bill).style.height="240";
}

function confirmRemoveBill(userid,bill)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }

 Effect.Squish(document.getElementById('window-'+bill))
 Effect.Fade(document.getElementById('row-'+bill))


var url="http://www.aroundthecapitol.com/billtrack/removebill.php"
url=url+"?userid="+userid
url=url+"&bill="+bill
url=url+"&sid="+Math.random()
url=encodeURI(url)

 xmlHttp.onreadystatechange=stateChangedRemoveBill
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
}


function stateChangedRemoveBill()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
// document.getElementById('row-'+bill).style.display='none';
// document.getElementById('window-'+bill).style.display='none';
 }
}


function addBillAmended(userid,bill)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }

var mb = document.getElementById('monitor-'+bill);
//alert(document.getElementById('monitor-'+bill).checked);
if (mb.checked == true) {

 var url="http://www.aroundthecapitol.com/billtrack/addbillamended.php"
 url=url+"?bill="+bill
 url=url+"&userid="+userid
 url=url+"&sid="+Math.random()
 xmlHttp.onreadystatechange=stateChangedAddBillAmended(bill)
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)

} else {
 removeBill(userid,bill);
}
}

function stateChangedAddBillAmended(bill)
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
alert(xmlHttp.responseText);
 document.getElementById('monitor-'+bill).innerHTML=xmlHttp.responseText;
 }
}

