function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function cityfind(ctry) {
    http.open('get', '../comments/searchcity.php?country='+ctry);
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function cityfinder(ctry) {
    http.open('get', '../users/searchcity.php?country='+ctry);
    http.onreadystatechange = handleResponse;
    http.send(null);
}
function validcomm(comm) {
    http.open('get', '../comments/validat.php?comm='+comm);
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function citybla(IDcommented_item,commented_item_name,name,email,comments) {
    http.open('get', 'comments/make_comments.php?IDcommented_item='+IDcommented_item+'&commented_item_name='+commented_item_name+'&name='+name+'&email='+email+'&comments='+encodeURI(comments));
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
            document.getElementById(update[0]).innerHTML = update[1];
        }
    }
}

function submitting()
{
  var str="";
  
  elt = document.getElementById('name');
  if (elt.value=="") str+="\n- name";
    
  elt = document.getElementById('comment');
  if (elt.value=="") str+="\n- comment";
  
  elt = document.getElementById('code');
  if (elt.value=="") str+="\n- form verification code";

  
if (str!="") 
  {
    alert("Please enter the following fields:"+str);
    return false;
  }
  
  return true;
}
function validat()
{
  var str="";
   
  elt = document.getElementById('compname');
  if (elt.value=="") str+="\n- company name";
    
  elt = document.getElementById('phnr1');
  if (elt.value=="") str+="\n- phone number1";
  
  if (str!="") 
  {
    alert("Please enter the following fields:"+str);
    return false;
  }
  
  return true;
}