/* -- input --*/	
inputBg = new Image();
	inputBg.src = '/img/input-bg.gif';
	function init(){
		inputs = document.getElementById('input').getElementsByTagName('input');
		for(i=0; i < inputs.length; i++){
			if(inputs[i].type == 'text' || inputs[i].type == 'password'){
				inputs[i].onfocus=function() {
					this.style.background='#FFF url(/img/input-bg.gif) repeat-x';
				}
				inputs[i].onblur=function() {
					this.style.background='#FFDDCA';
				}
			}
		}
	}
	window.onload = init;
	
	
/* -- Search --*/
function doHighlight(bodyText, searchTerm) 
{
    highlightStartTag = "<font style='background-color:#FFCC00;'>";
    highlightEndTag = "</font>";
  
  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
  var lcBodyText = bodyText.toLowerCase();
    
  while (bodyText.length > 0) {
    i = lcBodyText.indexOf(lcSearchTerm, i+1);
    if (i < 0) {
      newText += bodyText;
      bodyText = "";
    } else {
      if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
        if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
          newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
          bodyText = bodyText.substr(i + searchTerm.length);
          lcBodyText = bodyText.toLowerCase();
          i = -1;
        }
      }
    }
  }

  return newText;
}

function highlightSearchTerms(searchText)
{
  searchArray = searchText.split(" ");
  
  var bodyText = document.body.innerHTML;
  for (var i = 0; i < searchArray.length; i++) {
    bodyText = doHighlight(bodyText, searchArray[i]);
  }
  
  document.body.innerHTML = bodyText;
}


/* -- Feedback: Message Send --*/
function ValidateX() {
  if (document.form.email.value == "" || document.form.name.value == "" || document.form.subject.value == "" || document.form.message.value == "") {
    alert ("Все поля являются обязательными!");
    return false;
  }
}

/* -- Hide Form Comment --*/
function Slide(id) {
	if(!(obj = document.getElementById(id)))
		return;

	if(!obj.style.display || obj.style.display == 'none')
		obj.style.display = 'block';
	else
		obj.style.display = 'none';
}


/* --  --*/
hash = new Array();

function getLeft(element) {
  var iPos = 53;
  while (element!=null) {
    iPos+=element.offsetLeft;
    element = element.offsetParent;
  }
  return iPos;
}

function getTop(element) {
  var iPos = -220;
  while (element!=null) {
    iPos+=element.offsetTop;
    element = element.offsetParent;
  }
  return iPos;
}

function OpenSubMenu( parent, menu )
{
//  document.getElementById(menu).style.left = getLeft(document.getElementById(parent));
//  document.getElementById(menu).style.top = getTop(document.getElementById(parent)) + document.getElementById(parent).offsetHeight;
  document.getElementById(menu).style.visibility = "visible";
  hash[ menu ] = true;
}

function CloseSubMenu( menu )
{
  setTimeout( "HideSubMenu('" + menu + "');", 100 );
  hash[ menu ] = false;
}
     
function HideSubMenu( menu )
{
  if( !hash[ menu ] )
  {
    document.getElementById(menu).style.visibility = "hidden";
  }
}

/*
function Validate() {
  if (document.fo.company.value == "" || document.fo.name.value == "" || document.fo.doljnost.value == "" || document.fo.phone.value == "") {
    alert ("Вы не заполнили необходимые поля");
    return false;
  }
}

function Validate1() {
  if (document.fo.company.value == "" || document.fo.name.value == "" || document.fo.status.value == "" || document.fo.phone.value == "" || document.fo.mail.value == "" || document.fo.message.value == "") {
    alert ("Вы не заполнили необходимые поля");
    return false;
  }
}

function Validate2() {
  if (document.fo.bank.value == "" || document.fo.company.value == "" || document.fo.name.value == "" || document.fo.phone.value == "" || document.fo.fax.value == "" || document.fo.phone.value == "" || document.fo.mail.value == "" || document.fo.message.value == "") {
    alert ("Вы не заполнили необходимые поля");
    return false;
  }
}

function Validate3() {
  if (document.fo.bank.value == "" || document.fo.company.value == "" || document.fo.name.value == "" || document.fo.phone.value == "" || document.fo.mail.value == "" || document.fo.message.value == "") {
    alert ("Вы не заполнили необходимые поля");
    return false;
  }
}
*/
function check_length(){
		total=parseInt(document.form.local_man.value) + parseInt(document.form.near_man.value) + parseInt(document.form.far_man.value);
		document.form.total_man.value = total;
		document.form.l_man.value=parseInt(document.form.local_man.value);
		document.form.n_man.value=parseInt(document.form.near_man.value);
		document.form.f_man.value=parseInt(document.form.far_man.value);
//		if(total%30==0){
//			document.form.pri.value = total/30;
//		}else{
//			document.form.pri.value = Math.ceil(total/30);
//		}
	}


