

function global_ajax_get(path, items)
{

var http = false;
var randomnumber=Math.floor(Math.random()*1000000)

total_path = path + "?date=" + items + "&time=" + randomnumber;

if(navigator.appName == "Microsoft Internet Explorer") {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  http = new XMLHttpRequest();
}

http.open("GET", total_path);
http.onreadystatechange=function() {
  if(http.readyState == 4) {
    //alert(http.responseText);
	//string = process_function + "('" + escape(http.responseText) + "')";
	//eval(string);
	document.getElementById('content_box').innerHTML = http.responseText;
  }
}
http.send(null);
//document.getElementById('chat_text').value = "";


}

function get_content(para)
{
dir = "ajax/" + para + ".php";
global_ajax_get(dir,'');



}

function get_content_para(para_b,ad_id)
{
dir_b = "ajax/" + para_b + ".php";
items_b = "&ad_id=" + ad_id;
global_ajax_get(dir_b,items_b);

}

function create_ad()
{

title= document.getElementById('title').value;
type = document.submit_ad.type.value;

rooms= document.getElementById('rooms').value;
cats= document.getElementById('cats').value;
dogs= document.getElementById('dogs').value;

address= document.getElementById('address').value;
price= document.getElementById('price').value;
extra_b = document.getElementById('extra').value;

for (var i=0; i < document.submit_ad.display_address.length; i++)
   {
   if (document.submit_ad.display_address[i].checked)
      {
      var display = document.submit_ad.display_address[i].value;
      }
   }

for (var i=0; i < document.submit_ad.smoking.length; i++)
   {
   if (document.submit_ad.smoking[i].checked)
      {
      var smoking = document.submit_ad.smoking[i].value;
      }
   }


amenities = "";

if (document.submit_ad.heat.checked==1)
{
amenities = "0";
}

if (document.submit_ad.lights.checked==1)
{
amenities += ",1";
}
if (document.submit_ad.cable.checked==1)
{
amenities += ",2";
}
if (document.submit_ad.internet.checked==1)
{
amenities += ",3";
}


year= document.submit_ad.year.value;
month= document.submit_ad.month.value;
day= document.submit_ad.day.value;
parking= document.getElementById('parking').value;

postal=document.getElementById('postal').value;

area = document.getElementById('dhtmlgoodies_country').value;
city = document.getElementById('dhtmlgoodies_city').value;

new_path ="&title="+title+"&type="+type+"&rooms="+rooms+"&cats="+cats+"&dogs="+dogs+"&area="+area+"&address="+address+"&postal="+postal+"&year="+year+"&month="+month+"&day="+day+"&amenities="+amenities+"&display="+display+"&parking="+parking+"&smoking="+smoking+"&price="+price+"&extra="+extra_b+"&city="+city;

global_ajax_get('ajax/save_new.php',new_path);

}






























function save_edits()
{

title= document.getElementById('title').value;
type = document.save_edit.type.value;

rooms= document.getElementById('rooms').value;
cats= document.getElementById('cats').value;
dogs= document.getElementById('dogs').value;
area = document.getElementById('dhtmlgoodies_country').value;
city = document.getElementById('dhtmlgoodies_city').value;

address= document.getElementById('address').value;
price = document.getElementById('price').value;
extra_b = document.getElementById('extra').value;

for (var i=0; i < document.save_edit.display_address.length; i++)
   {
   if (document.save_edit.display_address[i].checked)
      {
      var display = document.save_edit.display_address[i].value;
      }
   }
for (var i=0; i < document.save_edit.smoking.length; i++)
   {
   if (document.save_edit.smoking[i].checked)
      {
      var smoking = document.save_edit.smoking[i].value;
      }
   }

amenities = "";

if (document.save_edit.heat.checked==1)
{
amenities = "0";
}

if (document.save_edit.lights.checked==1)
{
amenities += ",1";
}
if (document.save_edit.cable.checked==1)
{
amenities += ",2";
}
if (document.save_edit.internet.checked==1)
{
amenities += ",3";
}




year= document.save_edit.year.value;
month= document.save_edit.month.value;
day= document.save_edit.day.value;
parking= document.getElementById('parking').value;

ref = document.getElementById('ad_id').value;

postal = document.getElementById('postal').value;

ad_approved = document.getElementById('ad_approved').value;

new_path = "&title="+title+"&type="+type+"&rooms="+rooms+"&cats="+cats+"&dogs="+dogs+"&area="+area+"&address="+address+"&year="+year+"&month="+month+"&day="+day+"&amenities="+amenities+"&display="+display+"&parking="+parking+"&ad_id="+ref+"&smoking="+smoking+"&price="+price+"&extra="+extra_b+"&postal="+postal+"&ad_approved="+ad_approved+"&city="+city;

global_ajax_get('ajax/save_edits.php',new_path);



}











function delete_ad(para)
{
items = "&ad_id="+para;
global_ajax_get('ajax/do_delete.php',items);

}

function restore_ad(para)
{
items = "&ad_id="+para;
global_ajax_get('ajax/do_restore.php',items);

}

function select_upload()
{

global_ajax_get('ajax/select_uploads.php','');

}

function load_uploader(para)
{
items = "&ad_id="+para;
global_ajax_get('ajax/upload_images.php',items);

}

function open_window(para)
{

window.open('pages/images.php?ad_id='+para,'mywindow','width=420,height=400');

}

function change_password(para)
{

password = document.getElementById('password').value;
password_copy = document.getElementById('password_copy').value;
items = "&user_id="+para+"&password="+password+"&password_copy="+password_copy;
global_ajax_get('ajax/save_password.php',items);

}


