/* ------------------------ */
/*  XMLHTTPRequest Enable   */
/* ------------------------ */
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}

var http = createObject();


/* ----------------------- */
/*      Store             */
/* ----------------------- */
/* Переменная nocache содержит случайное число, добавляемое в запрос 
   для предотвращения кеширования браузером запроса */
var nocache = 0;
function store() {
 // Отображаем соощение в области ID store_list
 document.getElementById('store_list').innerHTML = "Loading..."
    // Проверяем, что все поля не пустые. Используем encodeURI() для кодирования недопустимых символов в запросе.
var city = encodeURI(document.getElementById('city').value);


 // Получаем случайное число
nocache = Math.random();
 // variables like URL variable
http.open('get', 'http://jscasual.ru/camaieu/index.php?city='+city+'&nocache = '+nocache);
http.onreadystatechange = storeReply;
http.send(null);
}
function storeReply() {
if(http.readyState == 4){ 
var response = http.responseText;
 if(response == 0){
// if store_list fails
  document.getElementById('store_list').innerHTML = 'hmmm...';
// else if store_listis ok show a message: "ok".
  } else {
document.getElementById('store_list').innerHTML = response;
  }
}
 }