function mSOvr(src,clrOver) { 
	if (!src.contains(event.fromElement)) {
		src.style.cursor = '';//было hand
		src.style.backgroundColor = clrOver; 
	}
}

function mSOut(src,clrIn) {
	if (!src.contains(event.toElement)) {
		src.style.cursor = '';//было hand
		src.style.backgroundColor = clrIn;
	}
}

function setlang( lang, actid, page ) {
  switch(actid)
  {
  	case 1:
  		faction = "setsearchconditions";
  	break;
  	case 2:
  		faction = "dosearch";
  	break;
  	case 3:
  		faction = "gotopage";
  	break;
  }
  
  if (document.all["Message"].style.visibility != "visible") {
  document.forms[0].action = "search.php?action="+faction+"&page="+page+"&lang="+lang;
  //alert(document.forms[0].action);
  document.forms[0].submit();
  }
}

function DoSubmit(act) {
  document.all["Message"].style.visibility = "visible";
  document.all["MainTable"].style.visibility = "hidden";
  window.scrollTo(0,0);
  document.forms[0].action = "search.php?action="+act;
  document.forms[0].submit();
}

function dc(idx) {
  if ( ( document.forms[0] != null ) && ( document.forms[0].elements["f"+idx] != null ))
  {
 	x = document.forms[0].elements["f"+idx].value;
  }
  else
 	x = idx;
  
   window.open( "/searchInvStat/dict.php?fid="+x+"&fcid="+idx, "", "");
}

function hlp(topic) {
  window.open( "/searchInvStat/help.php?name="+topic,"", "scrollbars=1, resizable=1" );
}

function basket(claim_per_page) 
{
  var ni = "", pk, act="";
  for (var i = 1; i <= claim_per_page; i++) 
  {
    pk = document.forms["main"].elements["pk"+i].value;
	if ( document.forms["main"].elements["basket"+i].checked ) 
      ni += pk+"+";
  }
  
  act = "additems";
  if ( claim_per_page == undefined )
  	act = "viewbasket";

  window.open( "/searchInvStat/basket.php?action="+act+"&items="+ni, "", "resizable=1, scrollbars=1");
}

function delfrombasket( count ) {
  var s = "", pk;
  for (var i = 1; i <= count; i++) {
    pk = document.forms["main"].elements["pk"+i].value;
    if ( document.forms["main"].elements["basket"+i].checked ) {
      s += pk+"+";
    }
  }

  document.forms[0].action +="?action=delitems&items="+s;
  document.forms[0].submit();
};

function ata( s ) {
  if (_active != null)
    with (_active) {
      focus();value += s;focus();
    }
}

function clf(idx) {
  with (document.forms[0].elements["qe"+idx]) {
    focus();
    value="";
 }
}

var _active = null, _accessed = "x";

function ma(edt,idx) {
  _active = edt;
  r = new RegExp("x"+idx+"x", "");
  if (_accessed.search(r) == -1) {
    _accessed += idx+"x";
  }
}

function clrall() {
  for (i = 0; i < ff.length; i++)
    if (ff.elements[i].type == "text")
      ff.elements[i].value="";
}

function _movelb() {
  with (document.all.LogicBar.style) {
    posTop = 150 + document.body.scrollTop;
    posRight = 30;
  }
}

function fi(IdClaim, ClaimIndex) {
	window.open( "/searchInvStat/showclaimdetails.php?IdClaim="+IdClaim+"&resId="+ClaimIndex,"", "" );
};

function goto( page ) {
  document.forms[0].action = "search.php?action=gotopage&page="+page;
  document.forms[0].submit();
};


function JumpTo(page, direct) {
	var x = Number(document.forms[0].elements["newpos"].value);
	n = 1;
	if ( direct == "back" ) n = page - x;		
	else
	if ( direct == "fwd" ) n = page + x;		
	else
	if ( direct == "to" ) n = x;

	document.forms[0].action = "search.php?action=gotopage&page="+n;
    document.forms[0].submit();
}

function FormAct(act) {
  document.forms[0].action = "search.php?action="+act;
  document.forms[0].submit();
};

function addtext( idx, txt, quotas ) {
  if ( window.opener != null ) { 
    ed = window.opener.document.forms[0].elements["qe"+idx];
    if (ed != null) {
      r = new RegExp("x"+idx+"x", "");
      if (window.opener._accessed.search(r) == -1) {
        window.opener._accessed += idx+"x";
      }
      window.opener._active="qe"+idx;
      if (quotas == "yes") {
        var str = txt;
        str = str.replace(/&&&&&&/g, "\\\"");
        str = str.replace(/######/g, "\'");
        ed.value += " \""+str+"\"";
      } else
        ed.value += " "+txt;
    }
  }
};

function printpr() {
  var PROMPT = 1;
  var OLECMDID = 7;
  var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
  document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
  WebBrowser1.ExecWB(OLECMDID, PROMPT);
  WebBrowser1.outerHTML = "";
};
