function ajaxFunction(eid,proc,ename)
  {  
  var xmlHttp;
  try
    {    // Firefox, Opera 8.0+, Safari    
		xmlHttp=new XMLHttpRequest();    }
  catch (e)
    {    // Internet Explorer    
    try
      {      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      }
    catch (e)
      {      try
        {        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        }
      catch (e)
        {        alert("Your browser does not support AJAX!");        return false;        }      }    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
		if (proc==1)// GetDetails
			{
			    document.getElementById(ename).innerHTML = xmlHttp.responseText;
			    document.getElementById(ename).style.visibility = 'visible'
			    document.getElementById(ename).style.zIndex = '1000'
			    //alert(xmlHttp.responseText)
			}
		 
		if (proc==2)// GetUnits
		
			{
			//alert(xmlHttp.responseText)
				 document.getElementById(ename).innerHTML=xmlHttp.responseText;
				 document.getElementById(ename).style.visibility='visible'
				 document.getElementById(ename).style.zIndex='1000'
				  //alert(xmlHttp.responseText)
			}
		if (proc==3)// GetTenantMain
			{
			 //document.getElementById(ename).visibility='visible'
			alert(ename)
				 document.getElementById(ename).innerHTML=xmlHttp.responseText;
				 // alert(xmlHttp.responseText)
			}
		if (proc==4)// AddEditUnits
			{
				 document.getElementById(ename).innerHTML=xmlHttp.responseText;
				 document.getElementById(ename).style.display='inline'
				//alert(xmlHttp.responseText)
			}
		if (proc==5)// AddEditUnits
			{
				 document.getElementById(ename).innerHTML=xmlHttp.responseText;
				 document.getElementById(ename).style.display='inline'
				//alert(xmlHttp.responseText)
			}
		if (proc==6)// AddNotice
			{
				 document.getElementById(ename).innerHTML=xmlHttp.responseText;
				 document.getElementById(ename).style.display='inline'
				//alert(xmlHttp.responseText)
			}
		if (proc==7)// Eviction is unchecked
			{
				 //document.getElementById(ename).innerHTML=xmlHttp.responseText;
				 //document.getElementById(ename).style.display='inline'
				//alert(xmlHttp.responseText)
			}
		if (proc==8)// Checkout Details
			{
				 document.getElementById(ename).innerHTML=xmlHttp.responseText;
				 document.getElementById(ename).style.display='inline'
				 //document.getElementById(ename).style.zIndex='1000'
				//alert(xmlHttp.responseText)
			}
		if (proc==9)// GetEditUnits
		
			{
			//alert(xmlHttp.responseText)
				 document.getElementById(ename).innerHTML=xmlHttp.responseText;
				 document.getElementById(ename).style.visibility='visible'
				 document.getElementById(ename).style.zIndex='10000'
				  //alert(xmlHttp.responseText)
			}
		if (proc==10)// EditUnits
			{
			//alert(xmlHttp.responseText)
				 document.getElementById(ename).innerHTML=xmlHttp.responseText;
				 document.getElementById(ename).style.display='inline'
				 document.getElementById(ename).style.zIndex='2000'
				  //alert(xmlHttp.responseText)
			}
		
		if (proc==11)// Remove Tenant from Edit Untis
			{
				 // document.getElementById(ename).innerHTML=xmlHttp.responseText;
				 // document.getElementById(ename).style.display='inline'
				 //HideDivAddEditUnit('x')
				  alert(xmlHttp.responseText)
			}
		if (proc==99)// Add Eviction Notice
			{
				 document.getElementById(ename).innerHTML=xmlHttp.responseText;
				 document.getElementById(ename).style.display='inline'
				//alert(xmlHttp.responseText)
			}
		if (proc==101)// Add new rent notice
			{
				 //  document.getElementById('addbr').innerHTML=xmlHttp.responseText;
				 // document.getElementById('addbr').style.display='inline'
				 HideDivAddEditUnit('x')
				  alert(xmlHttp.responseText)
			}
		if (proc==102)// open back rent
			{    var br
				 br=xmlHttp.responseText.split("~")
				 
				 document.form1.BackRent.value=br[1]
				 document.getElementById(ename).innerHTML=br[0]//xmlHttp.responseText;
				 document.getElementById(ename).style.display='inline'
				 
			}	
		if (proc==103)// save back rent
			{
				
				 document.getElementById(ename).innerHTML=xmlHttp.responseText;
				 document.getElementById(ename).style.display='inline'
				//alert(xmlHttp.responseText)
			}
		if (proc==104)// remove back rent
			{
				document.form1.BackRent.value=xmlHttp.responseText
				// document.getElementById(ename).innerHTML=xmlHttp.responseText;
				 document.getElementById(ename).style.display='none'
				//alert(xmlHttp.responseText)
			}
		if (proc==105)// notices to check out
			{
				//document.form1.BackRent.value=xmlHttp.responseText
				  document.getElementById('checkout').innerHTML=xmlHttp.responseText;
				 //document.getElementById(ename).style.display='none'
				//alert(xmlHttp.responseText)
			}
		if (proc==106)// delete rent notice
			{
				//document.form1.BackRent.value=xmlHttp.responseText
				  document.getElementById('checkout').innerHTML=xmlHttp.responseText;
				 //document.getElementById(ename).style.display='none'
				 alert("Rent Notice Removed")
				 HideDivAddEditUnit('x')
				 ajaxFunction('',105,'')
			}
		if (proc==107)// delete rent notice check out
			{	ajaxFunction("" ,108,'')
				 alert("Rent Notice Removed")
				 var rentid
					rentid=eid.split("=")
				 RemoveTR(rentid[1])
				  
				
				 
				
			}
		if (proc==108)// Rent Notice Total Due
			{
				 
				 document.getElementById('rent_quan_amount').innerHTML=xmlHttp.responseText;
				 document.getElementById('rent_quan_amount').style.display='inline'
				   ajaxFunction("" ,109,'')
			}	
		if (proc==109)// Rent Notice quantity
			{
				 
				 document.getElementById('rent_quan').innerHTML=xmlHttp.responseText;
				 document.getElementById('rent_quan').style.display='inline'
				  ajaxFunction("" ,110,'')
			}	
		if (proc==110)// Rent Notice totals at bottom
			{
				 
				 document.getElementById('rnt_notice_totals').innerHTML=xmlHttp.responseText;
				 document.getElementById('rnt_notice_totals').style.display='inline'
				   ajaxFunction("" ,111,'') // grandtotal
			}	
		if (proc==111)// GrandTotal
			{
				 
				 document.getElementById('grandtotal').innerHTML=xmlHttp.responseText;
				 document.getElementById('grandtotal').style.display='inline'
				  
			}	
		if (proc==112)// Delete Eviction from check out
			{
				 
				 //document.getElementById('grandtotal').innerHTML=xmlHttp.responseText;
				 //document.getElementById('grandtotal').style.display='inline'
				   var evn
					evn=eid.split("=")
				 RemoveTR(evn[1])
				  ajaxFunction("" ,113,'') //change eviction totals
			}	
		if (proc==113)// change all eviction notice totals
			{
				 var etotal
				 etotal=xmlHttp.responseText.split("~")
				// alert(etotal[1])
				// alert(etotal[0])
				  document.getElementById('ev_quan_amount').innerHTML=etotal[1];
				  document.getElementById('ev_quan_amount').style.display='inline'
				  
				  document.getElementById('ev_quan').innerHTML=etotal[0];
				  document.getElementById('ev_quan').style.display='inline'
				  
				  document.getElementById('evn_notice_totals').innerHTML=etotal[1];
				  document.getElementById('evn_notice_totals').style.display='inline'
				  
				   ajaxFunction("" ,111,'') // grandtotal
			}		
		}
	 }
    if (proc==1)
	 { 
	 xmlHttp.open("GET","AjaxFunctions.aspx?proc=1" + eid,true);
	 xmlHttp.send(null);  
	 }
    if (proc==2)
	 { 
	 xmlHttp.open("GET","AjaxFunctions.asp?proc=2" + eid,true);
	 xmlHttp.send(null);  
	 }
    if (proc==3)
	 { 
	 xmlHttp.open("GET","AjaxFunctions.asp?proc=3" + eid,true);
	 xmlHttp.send(null);  
	 }
    if (proc==4)
	 { 
	 xmlHttp.open("GET","AjaxFunctions.asp?proc=4" + eid,true);
	 xmlHttp.send(null);  
	 }
    if (proc==5)
	 { 
	 xmlHttp.open("GET","AjaxFunctions.asp?proc=5" + eid,true);
	 xmlHttp.send(null);  
	 }
    if (proc==6)
	 { 
	 xmlHttp.open("GET","AjaxFunctions.asp?proc=6" + eid,true);
	 xmlHttp.send(null);  
	 }
    if (proc==7)
	 { 
	 xmlHttp.open("GET","AjaxFunctions.asp?proc=7" + eid,true);
	 xmlHttp.send(null);  
	 }
    if (proc==8)
    {
	//alert ("1") 
	 xmlHttp.open("GET","AjaxFunctions.asp?proc=8" + eid,true);
	 xmlHttp.send(null);  
	 //alert ("2") 
	 }
    if (proc==9)
	 { 
	 xmlHttp.open("GET","AjaxFunctions.asp?proc=9" + eid,true);
	 xmlHttp.send(null);  
	 }
    if (proc==10)
	 { 
	 xmlHttp.open("GET","AjaxFunctions.asp?proc=10" + eid,true);
	 xmlHttp.send(null);  
	 }
	 if (proc==11)
	 { 
	 xmlHttp.open("GET","AjaxFunctions.asp?proc=11" + eid,true);
	 xmlHttp.send(null);  
	 }
	if (proc==99)
	 { 
	 xmlHttp.open("GET","AjaxFunctions.asp?proc=99" + eid,true);
	 xmlHttp.send(null);  
	 }
	 if (proc==101)
	 { 
	 xmlHttp.open("GET","AjaxInsert.asp?proc=101" + eid,true);
	 xmlHttp.send(null);  
	 }
	  if (proc==102)
	 { 
	 xmlHttp.open("GET","AjaxInsert.asp?proc=102" + eid,true);
	 xmlHttp.send(null);  
	 }
	  if (proc==103)
	 { 
	 xmlHttp.open("GET","AjaxInsert.asp?proc=103" + eid,true);
	 xmlHttp.send(null);  
	 }
	  if (proc==104)
	 { 
	 xmlHttp.open("GET","AjaxInsert.asp?proc=104" + eid,true);
	 xmlHttp.send(null);  
	 }
	if (proc==105)
	 { 
	 xmlHttp.open("GET","AjaxInsert.asp?proc=105" + eid,true);
	 xmlHttp.send(null);  
	 }
	 if (proc==106)
	 { 
	 xmlHttp.open("GET","AjaxInsert.asp?proc=106" + eid,true);
	 xmlHttp.send(null);  
	 }
	 if (proc==107)
	 { 
	 xmlHttp.open("GET","AjaxInsert.asp?proc=107" + eid,true);
	 xmlHttp.send(null);  
	 }
	  if (proc==108)
	 { 
	 xmlHttp.open("GET","AjaxInsert.asp?proc=108" + eid,true);
	 xmlHttp.send(null);  
	 }
	  if (proc==109)
	 { 
	 xmlHttp.open("GET","AjaxInsert.asp?proc=109" + eid,true);
	 xmlHttp.send(null);  
	 }
	 if (proc==110)
	 { 
	 xmlHttp.open("GET","AjaxInsert.asp?proc=110" + eid,true);
	 xmlHttp.send(null);  
	 }
	 if (proc==111)
	 { 
	 xmlHttp.open("GET","AjaxInsert.asp?proc=111" + eid,true);
	 xmlHttp.send(null);  
	 }
	 if (proc==112)
	 { 
		xmlHttp.open("GET","AjaxInsert.asp?proc=112" + eid,true);
		xmlHttp.send(null);  
	 } 
	  if (proc==113)
	 { 
		xmlHttp.open("GET","AjaxInsert.asp?proc=113" + eid,true);
		xmlHttp.send(null);  
	 } 
}
function HideDivUnit(divname)
{
	var allDivs = document.getElementsByTagName("div");
	var len = allDivs.length;

		for(var x=0;x<len;x++){
		var singleDiv = allDivs[x];
		//do whatever you want to do with the singleDiv here
		if (singleDiv.id.substring(0, 8) == "div_Det_")
			{
			if(singleDiv.id!=divname)
			{
				 document.getElementById(singleDiv.id).style.visibility='hidden' 
				//alert(singleDiv.id + "," + divname)
			}
			}
			
		}
}
function HideDivEditUnit(divname)
{
	var allDivs = document.getElementsByTagName("div");
	var len = allDivs.length;

		for(var x=0;x<len;x++){
		var singleDiv = allDivs[x];
		//do whatever you want to do with the singleDiv here
		if(singleDiv.id.substring(0,7)=="div_det")
			{
			if(singleDiv.id!=divname)
			{
				 document.getElementById(singleDiv.id).style.visibility='hidden' 
				//alert(singleDiv.id + "," + divname)
			}
			}
			
		}
}
function HideMe(divname)
{
	  document.getElementById(divname).style.display='none'
}
function HideDivAddEditUnit(divname)
{
	var allDivs = document.getElementsByTagName("div");
	var len = allDivs.length;

		for(var x=0;x<len;x++){
		var singleDiv = allDivs[x];
		//do whatever you want to do with the singleDiv here
		if(singleDiv.id.substring(0,7)=="div_det")
			{
			if(singleDiv.id!=divname)
			{
				 document.getElementById(singleDiv.id).style.display='none' 
				//alert(singleDiv.id + "," + divname)
			}
			}
			
		}
}

function CloseDiv(divname)
{
				 document.getElementById(divname).style.visibility='hidden' 
				//alert(divname)
}
function RemoveTR(id)
{
	document.getElementById("tr_" + id).style.display='none'
}
