function createRequestObject(){
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}
var http = createRequestObject();

function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}


function trtover(q) {q.style.backgroundColor='#F4F5F7';}
function trtout(q) {q.style.backgroundColor = '#FFFFFF';}



function show_error()
{
	var width = getClientWidth();
	var div = document.getElementById('error');
	div.style.display = "";
	//div.style.left = (width/2) - (div.clientWidth/2)+"px";
	div.style.left = "30%";
	
 	document.body.color = "#000000"; 
 	document.getElementById('error_fon').style.display = ""; 
}
function save_properties_order(order)
{
    http.open('get', '../include/for_scripts.php?type=save_properties_order&order='+order);
    http.onreadystatechange = save_properties_order_result;
    http.send(null);
}
function save_properties_order_result()
{
    if(http.readyState == 4)
    {
    	document.getElementById('loader').style.display = "none";
        document.getElementById('message').innerHTML = "Порядок сохранён";
    }
    else
    {
    	document.getElementById('loader').style.display = "";
    }
}

function validateRegisterFrom(form)
{
    var i;

    for (i=0; i<form.length; i++) 
    {
        if (form.elements[i].value == "" || form.elements[i].value == "0") 
        {
            alert('Все поля формы должны быть заполнены');
            form.elements[i].focus();
            return false;
        }
    }
    if (! (/\w+@\w+\.[a-z]{2,4}/.test(form.email.value)) )
	{
	   alert("Введите корректный email");
	   form.email.focus();
	   return false;
	}
    if (form.email.value != form.repeat_email.value)
    {
       alert("Адреса email не совпадают");
       form.email.value = "";
       form.repeat_email.value = "";
	   form.email.focus();
	   return false;
    }
    if (form.password.value != form.repeat_password.value)
    {
       alert("Пароли не совпадают");
       form.password.value = "";
       form.repeat_password.value = "";
	   form.password.focus();
	   return false;
    }
return true;
}

function scrollToModel(model_block_id)
{
    destination = $('#'+model_block_id).offset().top;
    destination-=5;
   $("html:not(:animated), body:not(:animated)").animate({ scrollTop: destination}, 1100 );
}
