function getBodyScrollTop()
{ // получение высоты прокрутки
  return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}
function getDocumentHeight() {
  return (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
}
function view_window(id,sel_id) {
  //alert(index_url+'/ajax/'+sel_id);
 	makeRequest(index_url+'/ajax/'+sel_id+'/',id);
  document.getElementById(id).style.marginTop = (getBodyScrollTop()-100) + 'px';
  document.getElementById(id).style.display = "block";
  lock_screen(true);
}
function hide_window(id) {
  document.getElementById(id).style.display = "none";
  lock_screen(false);
}
function lock_screen(value) {
  if(value) {
    document.getElementById('lock').style.height = getDocumentHeight()+'px';
    document.getElementById('lock').style.display = "block";
  } else {
    document.getElementById('lock').style.display = "none";
  }
}
function add_good(param) {
  hide_window('msg_dlg');
  makeRequest(index_url + "/ajax_script/basket/add_product/" + param + "/" + Uniq() + "/", "add_product_into_basket");
}
function refresh_basket_info() {
  makeRequest(index_url + "/ajax_script/basket/get_basket_info_table/", "basket_info_block");
}
function view_basket() {
  width=600; height=300;
  var left = screen.availWidth/2  - width/2;
  var top  = screen.availHeight/2 - height/2;
  galWin = open(index_url+"/basket/", "displayWindow", "width="+width+",height="+height+",status=no,toolbar=no,menubar=no,top="+top+",left="+left);
  galWin.focus();
}
function Uniq() {
  uniq = Math.random();
  uniq2 = uniq + ' ';
  uniq2 = uniq2.split(".");
  return uniq2[1];
}
function DelDialog(msg) {
  tmp = window.confirm(msg);
  if(tmp) return true;
  else return false;
}
//Проверка формы заказа
function order_test(form) {
  form.fio.value = trim(form.fio.value);
  form.email.value = trim(form.email.value);
  form.telefon.value = trim(form.telefon.value);
  if(form.fio.value == "") {
    alert("Пожалуйста, заполните поле 'Ф.и.о'!");
    return false;
  }
  if(form.email.value == "" && form.telefon.value == "") {
    alert("Пожалуйста, заполните поле 'Телефон' или 'E-mail'!");
    return false;
  }
  form.uniq.value = Uniq();
  return true;
}
function basket_del_element(product_brief, product_id) {
  if(DelDialog("Удалить  '" + product_brief + "' ?")) {
    document.getElementById('id_del').value = product_id;
    document.getElementById('del_good').submit();
  }
}

