var ie = 0;
var ie6 = 0;
//----------------------------------------------------------------------------
function StylePrintOn(site) {
  if (site == null) {
    var vers_name = "Полная версия";
    var js = "javascript:StylePrintOff()";
  } else {
    var vers_name = "For screen";
    var js = "javascript:StylePrintOff(2)";
  }
  var inHead = document.documentElement.firstChild.childNodes;
  for (i=0; i<inHead.length; i++) {
  	if (inHead[i].nodeName == 'LINK') {
  		str = inHead[i].getAttribute("href");
  		str = str.substring(str.length-8);
  		if (str == "null.css") {inHead[i].setAttribute("href","/include/print.css");}
  	}
  }
  var obj = document.getElementById("switch_style");
  obj.innerHTML = vers_name;
  obj.setAttribute("href",js);

}
//----------------------------------------------------------------------------
function StylePrintOff(site) {
  if (site == null) {
    var vers_name = "Версия для печати";
    var js = "javascript:StylePrintOn()";
  } else {
    var vers_name = "For print";
    var js = "javascript:StylePrintOn(2)";
  }
  var inHead = document.documentElement.firstChild.childNodes;
  for (i=0; i<inHead.length; i++) {
  	if (inHead[i].nodeName == 'LINK') {
  		str = inHead[i].getAttribute("href");
  		str = str.substring(str.length-9);
  		if (str == "print.css") {inHead[i].setAttribute("href","/include/null.css");}
  	}
  }
  var obj = document.getElementById("switch_style");
  obj.innerHTML = vers_name;
  obj.setAttribute("href",js);
}
//----------------------------------------------------------------------------
function vkl(node) {
  node.className="over ";
}
//----------------------------------------------------------------------------
function vykl(node) {
  node.className="";
}
//----------------------------------------------------------------------------
function ShowBlock(o,id_block) {
  var obj = document.getElementById(id_block);
  obj.style.top = absPosition(o).y+'px';
  obj.style.display = 'block';
}
//----------------------------------------------------------------------------
function HideBlock(id_block) {
  var obj = document.getElementById(id_block);
  obj.style.display = 'none';
}
//----------------------------------------------------------------------------
function absPosition(obj) {
  var x = y = 0;
  while(obj) {
        x += obj.offsetLeft;
        y += obj.offsetTop;
        obj = obj.offsetParent;
  }
  return {x:x, y:y};
}
//=========================
function ChangeZakaz(o_sel,idmodel) {
  var v_now = o_sel.value;
  var o_sel2 = document.getElementById(idmodel);

  var sel_str = '<select name="model" id="model_sel">';
  var str = '';
  if (v_now == 0) {
    str = '<option></option>';
  } else {
    if (!zakaz_arr[v_now]) {str = '<option></option>';}
    else {
      var len = zakaz_arr[v_now].length;
      for (var i = 0; i < len; i++) {
        str += '<option value="' + v_now + i + '">' + zakaz_arr[v_now][i] + '</option>';
      }
    }
  }
  if (ie) {o_sel2.outerHTML = sel_str + str + '</select>';}
  else {o_sel2.innerHTML = str;}
}
//=========================
function ChangeZakazZapch(o_sel,idmodel) {
  var v_now = o_sel.value;
  var o_sel2 = document.getElementById(idmodel);

  var sel_str = '<select name="model" id="model_sel">';
  var str = '';
  if (v_now == 0) {
    str = '<option></option>';
  } else {
    if (!zakaz_arr1[v_now]) {str = '<option></option>';}
    else {
      var len = zakaz_arr1[v_now].length;
      for (var i = 0; i < len; i++) {
        str += '<option value="' + v_now + i + '">' + zakaz_arr1[v_now][i] + '</option>';
      }
    }
  }
  if (ie) {o_sel2.outerHTML = sel_str + str + '</select>';}
  else {o_sel2.innerHTML = str;}
}
//=========================
function BlockShowHide(idblock) {
  var obj = document.getElementById(idblock);
  var disp = obj.style.display;
  if (disp == 'block') {obj.style.display = 'none'}
  else {obj.style.display = 'block';}
}
//----------------------------------------------------------------------------
function video_open(f,w,h) {
	if (w == null) {w = 600};
	if (h == null) {h = 500};
  window.open("/video.php?f=" + f + "&width=" + w + "&height=" + h, "", "help=no; status=no,location=no,toolbar=no,menubar=0,directories=no,height=" + h + ",width=" + w + ",top=100,left=300,dependent=yes,scrollbars=no");
}
//----------------------------------------------------------------------------
function recl_win_open() {
	rx = getClientWidth() - 408;
  img_window = window.open("/recl.php", "", "help=no; status=no,location=no,toolbar=no,menubar=0,directories=no,resizable=yes,height=300,width=400,top=100,left="+rx+",dependent=yes,scrollbars=yes");
}
//========================================
function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

//- Подсветка невведенных окошек ----------------------------------------------
var o;
var o_color = 'red';
var counter = 1;
//----------------------------------------------------------------------------
function CheckRequared(o_frm,vars) {
  for (var k in vars) {
    if (o_frm[vars[k]].value) {continue;}
    o = o_frm[vars[k]];
    if (!o.type || o.type == 'file') {continue;}
    counter = 1;
    o_color = 'red';
    o.value = ' Введите данные';
    o.focus();
    setTimeout("ChangeBg()",10);
    return false;
  }
  return true;
}
//----------------------------------------------------------------------------
function ChangeBg() {
  counter++;
  if (counter > 8) {o.value = ''; return;}
  o_color = (o_color == 'red') ? 'white' : 'red';
  o.style.background = o_color;
  setTimeout("ChangeBg()",300)
}
//----------------------------------------------------------------------------

