
function selectall(){
table = document.getElementById('none');
inputs = table.getElementsByTagName('input');
var checkboxes = new Array();
for (i = 0; i < inputs.length; i++)
{
  if (!inputs[i].length)
  {
    if (inputs[i].type == 'checkbox')
      checkboxes[checkboxes.length] = inputs[i];
  } else
  {
    for(k = 0; k < inputs[i].length; k++)
    {
      if (inputs[i][k].type == 'checkbox')
        checkboxes[checkboxes.length] = inputs[i];
    }
  }
}

if (document.getElementById('hide_all').checked == true)
{
for (i = 0; i < checkboxes.length; i++)
{
  checkboxes[i].checked = true;
  checkboxes[i].value = 0;
}
}else{
for (i = 0; i < checkboxes.length; i++)
{
  checkboxes[i].checked = false;
  checkboxes[i].value = 1;
}
}
}

// RESET CHECKBOX
function checkbox_r(chkname)
{
if (document.getElementById(chkname).value == 1)
{
document.getElementById(chkname).value = 0;
}
else if (document.getElementById(chkname).value == 0)
{
document.getElementById(chkname).value = 1;
}

}

function updateField(nameValue){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!");
return false;
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if (xmlHttp.status==200){
//this will be called after update
doSomethingAfterUpdate(xmlHttp.responseText);
}
}
}
//this will send the data to server to be updated
xmlHttp.open("GET", 'ajax/updatesettings.php?'+ nameValue, true);
xmlHttp.send(null);
}

function submitform(nameValue){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!");
return false;
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if (xmlHttp.status==200){
//this will be called after update
doSomethingAfterUpdate3(xmlHttp.responseText);
}
}
}
//this will send the data to server to be updated
xmlHttp.open("GET", '/ajax/submitform.php?'+ nameValue, true);
xmlHttp.send(null);
}

function updatebgcolor(nameValue, editid){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!");
return false;
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if (xmlHttp.status==200){
//this will be called after update
doSomethingAfterUpdate2(xmlHttp.responseText);
}
}
}
//this will send the data to server to be updated
xmlHttp.open("GET", 'ajax/updatebgcolor.php?'+ nameValue + '&id=' + editid, true);
xmlHttp.send(null);
}


// Property Information
function updateFieldid(nameValue,getid){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!");
return false;
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if (xmlHttp.status==200){
//this will be called after update
doSomethingAfterUpdate(xmlHttp.responseText);
}
}
}
//this will send the data to server to be updated

//xmlHttp.open("GET", 'ajax/updateproperty.php?'+ nameValue + '&id=' + getid, true);
//xmlHttp.send(null);

var url = "ajax/updateproperty.php";
var params = nameValue + "&id=" + getid;

xmlHttp.open("POST", url, true);

xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

xmlHttp.send(params);
}


// AGENT
function updateFieldidagent(nameValue,getid){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!");
return false;
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if (xmlHttp.status==200){
//this will be called after update
doSomethingAfterUpdate(xmlHttp.responseText);
}
}
}
//this will send the data to server to be updated
xmlHttp.open("GET", 'ajax/updateagent.php?'+ nameValue + '&id=' + getid, true);
xmlHttp.send(null);
}

// Reload Page
function updaterefresh(){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!");
return false;
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if (xmlHttp.status==200){
//this will be called after update
doSomethingAfterUpdate4(xmlHttp.responseText);
}
}
}
//this will send the data to server to be updated
xmlHttp.open("GET", 'ajax/reload_page.php', true);
xmlHttp.send(null);
}

// HIDE ALL PROPERTY
function hideall(nameValue,getid){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!");
return false;
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if (xmlHttp.status==200){
//this will be called after update
doSomethingAfterUpdate(xmlHttp.responseText);
}
}
}
//this will send the data to server to be updated
xmlHttp.open("GET", 'ajax/hideall.php?getvalue='+ nameValue + '&id=' + getid, true);
xmlHttp.send(null);
}

// HIDE ALL AGENT
function hideall2(nameValue,getid){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!");
return false;
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if (xmlHttp.status==200){
//this will be called after update
doSomethingAfterUpdate(xmlHttp.responseText);
}
}
}
//this will send the data to server to be updated
xmlHttp.open("GET", 'ajax/hideall2.php?getvalue='+ nameValue + '&id=' + getid, true);
xmlHttp.send(null);
}

// HIDE ALL OPEN HOUSE
function hideall3(nameValue,getid){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!");
return false;
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if (xmlHttp.status==200){
//this will be called after update
doSomethingAfterUpdate(xmlHttp.responseText);
}
}
}
//this will send the data to server to be updated
xmlHttp.open("GET", 'ajax/hideall3.php?getvalue='+ nameValue + '&id=' + getid, true);
xmlHttp.send(null);
}

// HIDE ALL EMAIL AGENT
function hideall4(nameValue,getid){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!");
return false;
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if (xmlHttp.status==200){
//this will be called after update
doSomethingAfterUpdate(xmlHttp.responseText);
}
}
}
//this will send the data to server to be updated
xmlHttp.open("GET", 'ajax/hideall4.php?getvalue='+ nameValue + '&id=' + getid, true);
xmlHttp.send(null);
}

// HIDE ALL SEND TO A FRIEND
function hideall5(nameValue,getid){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!");
return false;
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if (xmlHttp.status==200){
//this will be called after update
doSomethingAfterUpdate(xmlHttp.responseText);
}
}
}
//this will send the data to server to be updated
xmlHttp.open("GET", 'ajax/hideall5.php?getvalue='+ nameValue + '&id=' + getid, true);
xmlHttp.send(null);
}

// HIDE ALL COMM INFO
function hideall6(nameValue,getid){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!");
return false;
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if (xmlHttp.status==200){
//this will be called after update
doSomethingAfterUpdate(xmlHttp.responseText);
}
}
}
//this will send the data to server to be updated
xmlHttp.open("GET", 'ajax/hideall6.php?getvalue='+ nameValue + '&id=' + getid, true);
xmlHttp.send(null);
}

function doSomethingAfterUpdate(retValFromPHP){

//retValFromPHP can be any thing you want!
var myArray = retValFromPHP.split(':');
var id = myArray[0];
var image = '<img src="'+ myArray[1] +'" border="0" />';
var msg = myArray[2];

if (!msg)
{
//document.getElementById(id).innerHTML  = image;
document.images[ id ].src = myArray[1];

}
else
{
document.images[ id ].src = myArray[1];
document.getElementById(id).innerHTML  = image +'<br /><span class="errortext">'+msg+'</span>';
}

}

function updateanalytics(nameValue,getid){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!");
return false;
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if (xmlHttp.status==200){
//this will be called after update
AnalyticsAfterUpdate(xmlHttp.responseText);
}
}
}
//this will send the data to server to be updated
//xmlHttp.open("GET", 'ajax/updateproperty.php?'+ nameValue + '&id=' + getid, true);
//xmlHttp.send(null);

var url = "ajax/updateproperty.php";
var params = nameValue + "&id=" + getid;

xmlHttp.open("POST", url, true);

xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

xmlHttp.send(params);
}

function AnalyticsAfterUpdate(retValFromPHP){

//retValFromPHP can be any thing you want!
var myArray = retValFromPHP.split(':');
var id = myArray[0];
var image = '<img src="'+ myArray[1] +'" border="0" />';
var msg = myArray[2];
if (!msg)
{
document.getElementById(id).innerHTML  = image +'';
}
else
{
document.getElementById(id).innerHTML  = image +'<span class="errortext">'+msg+'</span>';
}

}

function doSomethingAfterUpdate2(retValFromPHP){
document.getElementById('bgframe').innerHTML  = retValFromPHP;
}

function doSomethingAfterUpdate3(retValFromPHP){

//retValFromPHP can be any thing you want!
var myArray = retValFromPHP.split(':');
var id = myArray[0];
var image = '<img src="'+ myArray[1] +'" border="0" />';
var msg = myArray[2];
if (!msg)
{
document.getElementById(id).innerHTML  = image;
}
else
document.getElementById(id).innerHTML  = image +'<span class="errortext">'+msg+'</span>';

function substr( f_string, f_start, f_length ) {
    // http://kevin.vanzonneveld.net
    // +     original by: Martijn Wieringa
    // *         example 1: substr('abcdef', 0, -1);
    // *         returns 1: 'abcde'
 
    if(f_start < 0) {
        f_start += f_string.length;
    }
 
    if(f_length == undefined) {
        f_length = f_string.length;
    } else if(f_length < 0){
        f_length += f_string.length;
    } else {
        f_length += f_start;
    }
 
    if(f_length < f_start) {
        f_length = f_start;
    }
 
    return f_string.substring(f_start, f_length);
}

if (substr(myArray[1],0, 13) == "images/accept")
document.getElementById('formz').innerHTML  = '';

}

function doSomethingAfterUpdate4(retValFromPHP){
document.getElementById('reloadit').innerHTML  = retValFromPHP;
}
