global_tpArea = 206;
btmArea = 124;
window.onresize = doResize;
var inquiryForm = new Array ("name", "phone", "equipment");
var inquiryDealer = new Array ("name", "phone", "city", "from", "info");
var successStory = new Array ("name", "age", "activity", "abiding-place", "profit", "story");
var global_focusField = 0;


if (document.images)
{
 proximaWestBtnOn = new Image();
 proximaWestBtnOn.src = "/img/menu-top-proxima-west-on.gif";
 proximaWestBtnOff = new Image();
 proximaWestBtnOff.src = "/img/menu-top-proxima-west-off.gif";
 proximaWestBtnOff1 = new Image();
 proximaWestBtnOff1.src = "/img/menu-top-proxima-west-off-1.gif";

 serviceBtnOn = new Image();
 serviceBtnOn.src = "/img/menu-top-service-on.gif";
 serviceBtnOff = new Image();
 serviceBtnOff.src = "/img/menu-top-service-off.gif";
 serviceBtnOff1 = new Image();
 serviceBtnOff1.src = "/img/menu-top-service-off-1.gif";

 dealerBtnOn = new Image();
 dealerBtnOn.src = "/img/menu-top-dealer-on.gif";
 dealerBtnOff = new Image();
 dealerBtnOff.src = "/img/menu-top-dealer-off.gif";
 dealerBtnOff1 = new Image();
 dealerBtnOff1.src = "/img/menu-top-dealer-off-1.gif";

 contactsBtnOn = new Image();
 contactsBtnOn.src = "/img/menu-top-contacts-on.gif";
 contactsBtnOff = new Image();
 contactsBtnOff.src = "/img/menu-top-contacts-off.gif";
 contactsBtnOff1 = new Image();
 contactsBtnOff1.src = "/img/menu-top-contacts-off-1.gif";

 linksBtnOn = new Image();
 linksBtnOn.src = "/img/menu-top-links-on.gif";
 linksBtnOff = new Image();
 linksBtnOff.src = "/img/menu-top-links-off.gif";
 linksBtnOff1 = new Image();
 linksBtnOff1.src = "/img/menu-top-links-off-1.gif";

 interestingBtnOn = new Image();
 interestingBtnOn.src = "/img/menu-top-interesting-on.gif";
 interestingBtnOff = new Image();
 interestingBtnOff.src = "/img/menu-top-interesting-off.gif";
 interestingBtnOff1 = new Image();
 interestingBtnOff1.src = "/img/menu-top-interesting-off-1.gif";

 queryBtnOn = new Image();
 queryBtnOn.src = "/img/menu-top-query-on.gif";
 queryBtnOff = new Image();
 queryBtnOff.src = "/img/menu-top-query-off.gif";
 queryBtnOff1 = new Image();
 queryBtnOff1.src = "/img/menu-top-query-off-1.gif";
}

function swOn(imageNameOn, imageNameOff1)
{
 if (document.images)
 {
  document[imageNameOn].src = eval(imageNameOn + "BtnOn.src");
  if (imageNameOff1 != null)
    document[imageNameOff1].src = eval(imageNameOff1 + "BtnOff1.src");
 }
}

function swOff(imageNameOff, imageNameOff1) 
{
 if (document.images)
 {
  document[imageNameOff].src = eval(imageNameOff + "BtnOff.src");
  if (imageNameOff1 != null)
    document[imageNameOff1].src = eval(imageNameOff1 + "BtnOff.src");
 }
}

function doResize() {
  window_height=(window.innerHeight)?window.innerHeight:((document.all)?document.body.offsetHeight:400);
  if ((window_height-global_tpArea-btmArea) > 0)
    document.getElementById('bufImg').style.height=window_height-global_tpArea-btmArea;
  else
    document.getElementById('bufImg').style.height=30;
}

function makeDocHeight (tpArea) {
  global_tpArea = tpArea;
  window_height=(window.innerHeight)?window.innerHeight:((document.all)?document.body.offsetHeight:400); 
  if ((window_height-global_tpArea-btmArea) > 0)
    document.write("<img src='/img/1x1t.gif' width='30' height='" + (window_height-global_tpArea-btmArea) + "' border='0' id='bufImg'>");
  else
    document.write("<img src='/img/1x1t.gif' width='30' height='1' border='0' id='bufImg'>");
}

function show(url, _w, _h) {
  var wF = "width=" + _w + ",height=" + _h + ",scrollbars=0,menubar=0,toolbar=0,location=0,directories=0,copyhistory=0,status=1,resizable=0";
  var w1 = window.open(url, "topic", wF);
  w1.focus()
} 

function bgChangeOn(name) {
  _name = eval(name);
  _name.style.backgroundColor = "#9B4021";
  _name.style.cursor = "hand";
}

function bgChangeOff(name) {
  _name = eval(name);
  _name.style.backgroundColor = "#B07321";
  _name.style.cursor = "default";
}

function _submit(form){
  switch (form){
    case "dealer" :       
	  bufForm = inquiryDealer;      
	  break;   
	case "success-story" :       
	  bufForm = successStory;      
	  break;   
	default : 
	  bufForm = inquiryForm; 
  }
/*  if (form == "dealer")
  {
    bufForm = inquiryDealer;
  }
  else
  {
    bufForm = inquiryForm;
  }*/
  var str = '';
  var focusField = 0;
  for (i = 0; i < bufForm.length; i++) {
    if (inquiry.elements[bufForm[i]].value == '') {
	  str = str + inquiry.elements[bufForm[i]].title + '\n';	
	  if (focusField == 0) 
	  {
	    focusField = 1; 
		inquiry.elements[bufForm[i]].focus();  
	  }
	}
  }
  if (str != '')
  {
    alert("Вы забыли заполнить следующие поля:\n" + str);
	return;
  }
  else
  {
    inquiry.submit();
  }
}

function getCookieVal(offset) {
  var endstr = document.cookie.indexOf(";", offset)
  if (endstr == -1) endstr = document.cookie.length
    return unescape(document.cookie.substring(offset, endstr))
}

function getCookie(name) {
  var arg = name + "="
  var arg_length = arg.length
  var cookie_length = document.cookie.length
  var i = 0
  while (i < cookie_length) {
    var j = i + arg_length
    if (document.cookie.substring(i, j) == arg) return getCookieVal(j)
      i = document.cookie.indexOf(" ", i) + 1
    if (i == 0) break
  }
  return null
}

function setCookie(name, value, expires) {
  var todayDate = new Date()
  todayDate.setDate(todayDate.getDate() + expires)
  document.cookie = name + "=" + escape(value) + ((expires) ? "; expires=" + todayDate.toGMTString() : "")  + "; path=/"
}




