// загрузка контента в div
function getHTMLContent(obj_id, url)
{
  if(!this.http){  this.http = get_http(); this.working = false;  } else this.working = false; 
  if (!this.working && this.http) 
  {
    var http = this.http;
    this.http.open("GET", url, true);
    this.http.onreadystatechange = function() {
    	if (http.readyState == 4) {
    	  document.getElementById(obj_id).innerHTML = http.responseText;

          if (obj_id =='img') correctHeight();
          this.working = false;
        }
    	else{ // данные в процессе получения,
		}
    }
    this.working = true;
    this.http.send(null);
  }
  if(!this.http){  alert('Ошибка при создании XMLHTTP объекта!'); }     
}


function correctHeight()
{
   var height = element('page').clientHeight;
   element('scrollable').style.height = (height-90)+'px';
   element('table_img').style.width = 670+'px';
  element('img').style.width = 500+'px';

}


// document.getElementById
function element(id)
{
	return document.getElementById(id);
}

// загрузка списка в select
function lookup(obj_id, url)
{
  if(!this.http){  this.http = get_http(); this.working = false;  } else this.working = false; 
  if (!this.working && this.http) 
  {
    var http = this.http;
    this.http.open("GET", url, true);
    this.http.onreadystatechange = function() {
    	if (http.readyState == 4) {
    	  loadSelect(obj_id, http.responseText);
          this.working = false;
        }
    	else{ // данные в процессе получения,
		}
    }
    this.working = true;
    this.http.send(null);
  }
  if(!this.http){  alert('Ошибка при создании XMLHTTP объекта!'); }     
}

function loadSelect(id, data)
{
  var sel = document.getElementById(id);
  while (sel.options.length) {  sel.options[0] = null;  }
  if(data.length == 0) return;
  var arr = data.split('|');
  for(var i=0; i<arr.length; i++){
	val = arr[i].split('~');
	sel.options[i]= new Option(val[1], val[0]);
  }
}

  // загрузка списка в select
function getValue(obj_id, url)
{
  if(!this.http){  this.http = get_http(); this.working = false;  } else this.working = false; 
  if (!this.working && this.http) 
  {
    var http = this.http;
    this.http.open("GET", url, true);
    this.http.onreadystatechange = function() {
    	if (http.readyState == 4) {
    	    document.getElementById(obj_id).value = http.responseText;
          this.working = false;
        }
    	else{ // данные в процессе получения,
		}
    }
    this.working = true;
    this.http.send(null);
  }
  if(!this.http){  alert('Ошибка при создании XMLHTTP объекта!'); }     
}


function changeLanguage(lang_id, lang_url)
{
	document.getElementById('lang_id').value=lang_id; 
	var f = document.getElementById('lang_form');
	f.action += lang_url;
	f.submit();
}
