// AJAX
function processStateChange(){
  if (request.readyState == 4){
    contentDiv = document.getElementById(dest);
    if (request.status == 200){
response = request.responseText;
contentDiv.innerHTML = response;
    } else {
contentDiv.innerHTML = "Error: Status "+request.status;
    }
  }
}

function loadHTML(URL, destination){
  dest = destination;
  if (window.XMLHttpRequest){
    request = new XMLHttpRequest();
    request.onreadystatechange = processStateChange;
    request.open("GET", URL, true);
    request.send(null);
  } else if (window.ActiveXObject) {
    request = new ActiveXObject("Microsoft.XMLHTTP");
    if (request) {
request.onreadystatechange = processStateChange;
request.open("GET", URL, true);
request.send();
    }
  }
}

function vis(id) {
if (document.getElementById(id).style.display == "none") {document.getElementById(id).style.display = "block"} else {document.getElementById(id).style.display = "none"}
}

function check_register() {
	email=document.getElementById('email').value;
	password=document.getElementById('password').value;
	password2=document.getElementById('password2').value;
	name=document.getElementById('name').value;
  if (email && name && password && password2) {

     if (email.match(/\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b/)) {} else {alert("Введите корректный адрес e-mail!"); return false;}
     if (password == password2) { return true; } else {alert("Пароли должны совпадать!"); return false;}

// Проверяем телефон на соответствие формату (xxx) xxxxxxx
//   if (subject.match(/\([0-9]{3,5}\).[0-9]{5,7}/)) {} else {}

  }
alert("Заполните пожалуйста все обязательные поля!");
return false;
}

function check_login() {
	login=document.getElementById('auth_l').value;
	password=document.getElementById('auth_p').value;
	if (!login || !password) {return false;}
}

function check_filter() {
	q=document.getElementById('q').value;
	if (q.length > 0 && q.length < 3) {alert("Подстрока должна быть длиной от 3 символов!");return false;} else {return true;}
}

// Подсветка строк таблицы list при наведении
function lon(tr) {
	tr.style.background='#FFFFCC';
	tr.style.border='solid 1px silver';
}

function loff(tr) {
	tr.style.background='';
	tr.style.border='solid 1px white';
}

// Подсветка заголовков (th) таблицы list при наведении
function lhon(th) {
	th.style.background='#5b86a4';
}

function lhoff(th) {
	th.style.background='#416277';
}

// Оформление заказа
function order_display() {
	document.getElementById('order_buttons').style.display = 'none';
	document.getElementById('order_client_info').style.display = '';
}

function kievtime() {
// alert(document.getElementById("user_country").value);return;
  if (document.getElementById('user_country').value == 'Киев') {
	document.getElementById('kiev_time').style.display = '';
  } else {
	document.getElementById('kiev_time').style.display = 'none';
  }
}

function chkorder() {
  fio=document.getElementById('user_fio').value;
  cell=document.getElementById('user_tel_cell').value;
  address=document.getElementById('user_address').value;
if (fio && cell && address) {return true;}
alert("Пожалуйста, заполните все обязательные поля формы заказа\n(Ф.И.О., Мобильный телефон, Адрес доставки заказа)")
return false;
}
