function showPost(str)
{
if (str=="")
  {
  document.getElementById("expand"+str).innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("expand"+str).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getmess.php?id="+str,true);
xmlhttp.send();
}

//////////////////////////////////////////////////////////////
function deletePost(str)
{
if (str=="")
  {
  document.getElementById("delete"+str).innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("delete"+str).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","delete.php?id="+str,true);
xmlhttp.send();
}
//////////////////////////////////////////////////////////////
function deletePost2(str)
{
if (str=="")
  {
  document.getElementById("delete"+str).innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("delete"+str).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","delete2.php?id="+str,true);
xmlhttp.send();
}
//////////////////////////////////////////////////////////////

function showReplies(str,str2)
{
if (str=="")
  {
  document.getElementById("replies"+str).innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("replies"+str).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getreplies.php?rand="+str2+"&parent="+str,true);
xmlhttp.send();
}
//////////////////////////////////////////////////////////////
function replyPost(str,str2)
{
if (str=="")
  {
  document.getElementById("reply"+str).innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("reply"+str).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","replypost.php?rand="+str2+"&id="+str,true);
xmlhttp.send();
}
///////////////
function showMy(str)
{
if (str=="")
  {
  document.getElementById("listdiv").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("listdiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","list.php?showmy=yes&random="+str,true);
xmlhttp.send();
}
///////////////
function showAll(str)
{
if (str=="")
  {
  document.getElementById("listdiv").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("listdiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","list.php?showmy=no&random="+str,true);
xmlhttp.send();
}

//////////////////////////////////////////////////////////////
function showMore(str)
{
if (str=="")
  {
  document.getElementById("listdiv").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("listdiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","list.php?showmore=yes&random="+str,true);
xmlhttp.send();
}
//////////////////////////////////////////////////////////////

function xmlhttpPost(strURL,formname,responsediv,responsemsg) {
    var xmlHttpReq = false;
    var self = this;
    // Xhr per Mozilla/Safari/Ie7
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText,responsediv);
        }
        else{
	updatepage(responsemsg,responsediv);
		}
    }
    self.xmlHttpReq.send(getquerystring(formname));
}
////////////////////////////////////////
function getquerystring(formname) {
    var form = document.forms[formname];
    var qstr = "";
    function GetElemValue(name, value) {
        qstr += (qstr.length > 0 ? "&" : "")
            + escape(name).replace(/\+/g, "%2B") + "="
            + escape(value ? value : "").replace(/\+/g, "%2B");
			//+ escape(value ? value : "").replace(/\n/g, "%0D");
    }
	var elemArray = form.elements;
    for (var i = 0; i < elemArray.length; i++) {
        var element = elemArray[i];
        var elemType = element.type.toUpperCase();
        var elemName = element.name;
        if (elemName) {
            if (elemType == "TEXT"
                    || elemType == "TEXTAREA"
                    || elemType == "PASSWORD"
					|| elemType == "BUTTON"
					|| elemType == "RESET"
					|| elemType == "SUBMIT"
					|| elemType == "FILE"
					|| elemType == "IMAGE"
                    || elemType == "HIDDEN")
                GetElemValue(elemName, element.value);
            else if (elemType == "CHECKBOX" && element.checked)
                GetElemValue(elemName, 
                    element.value ? element.value : "On");
            else if (elemType == "RADIO" && element.checked)
                GetElemValue(elemName, element.value);
            else if (elemType.indexOf("SELECT") != -1)
                for (var j = 0; j < element.options.length; j++) {
                    var option = element.options[j];
                    if (option.selected)
                        GetElemValue(elemName,
                            option.value ? option.value : option.text);
                }
        }
    }
    return qstr;
}
////////////////////////////////////////

function updatepage(str,responsediv){
    document.getElementById(responsediv).innerHTML = str;
}
////////////////////////////////////////////////////////////////////
function sz(t) {
a = t.value.split('\n');
b=1;
for (x=0;x < a.length; x++) {
 if (a[x].length >= t.cols) b+= Math.floor(a[x].length/t.cols);
 }
b+= a.length;
if (b > t.rows) t.rows = b;
}
//////////////////////////////////////////////////////////////////
function showListings(str)
{
if (str=="")
  {
  document.getElementById("listing"+str).innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("listing"+str).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","listcategory.php?key="+str,true);
xmlhttp.send();
}
//////////////////////////////////////////////////////////////
function deleteClassified(str)
{
if (str=="")
  {
  document.getElementById("viewitem"+str).innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("viewitem"+str).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","delete.php?id="+str,true);
xmlhttp.send();
}
//////////////////////////////////////////////////////////////
function deleteClassified2(str)
{
if (str=="")
  {
  document.getElementById("delete"+str).innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("delete"+str).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","delete2.php?id="+str,true);
xmlhttp.send();
}
//////////////////////////////////////////////////////////////



