// й 2000 - 2002 LaCoNix. All rights reserved.
// Patent Pending
// Version 1.0
// by Alexander Kolpakov

var m1c, m1t;
var m2c, m2t;
var m3c, m3t;
var ms = 300;

function layer_show (name,x) {
	if (document.layers) {
		if (document.layers[name])
			document.layers[name].visibility = "show";
	} else {
		if (document.all[name] && document.all[name].style){
			if (!document.all[name].oldleft){
				document.all[name].oldleft=document.all[name].style.left;
				old=document.all[name].oldleft.indexOf("px");
				document.all[name].oldleft=document.all[name].oldleft.substr(0,old);
			}
			oldx=document.all[name].oldleft;
			document.all[name].style.visibility = "visible";
			shift=109-x;
			document.all[name].style.left=oldx-shift;
		}
	}
}

function layer_hide (name) {
	if (document.layers) {
		if (document.layers[name])
			document.layers[name].visibility = "hide";
	} else {
		if (document.all[name] && document.all[name].style)
			document.all[name].style.visibility = "hidden";
	}
}

function m1s(name,x) {
	if ( m1c && m1c != name )
		layer_hide(m1c);
	m1c = name;
	layer_show(m1c,x);
	if ( m1t )
		clearTimeout(m1t);
	m1t = 0;
}

function m1h(name) {
	m1t = setTimeout('layer_hide(\''+name+'\')', ms);
}

function m2s(name) {
	if ( m2c && m2c != name )
		layer_hide(m2c);
	m2c = name;
	layer_show(m2c);
	if ( m1t )
		clearTimeout(m1t);
	if ( m2t )
		clearTimeout(m2t);
	m1t = 0;
	m2t = 0;
}

function m2h(name) {
	m1t = setTimeout('layer_hide(\''+m1c+'\')', ms);
	m2t = setTimeout('layer_hide(\''+name+'\')', ms);
}

function m3s(name) {
	m3c = name;
	if ( m1t )
		clearTimeout(m1t);
	if ( m2t )
		clearTimeout(m2t);
	if ( m3t )
		clearTimeout(m3t);
	m1t = 0;
	m2t = 0;
	m3t = 0;
}

function m3h(name) {
	m1t = setTimeout('layer_hide(\''+m1c+'\')', ms);
	m2t = setTimeout('layer_hide(\''+m2c+'\')', ms);
	m3t = setTimeout('layer_hide(\''+name+'\')', ms);
}

//Added by Sergey Mikheev for open popup window
function Start(page) {
  OpenWin = this.open(page, "CtrlWindow", "height=600,width=600,   toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no");
}
//Added by Leonid Piontak for search workaround
function sync(){
	if (event.keyCode==13) {
		document.location.href="search.php3?keyword="+event.srcElement.value;
	}
}

function CheckForm(){
  for(i=0;i<document.MainForm.elements.length;i++){
    if (document.MainForm.elements[i].value=="" &&
        (document.MainForm.elements[i].type=="text" || document.MainForm.elements[i].type=="file"|| document.MainForm.elements[i].type=="textarea") &&
        document.MainForm.elements[i].Null==0
       ) {
      alert("Please enter "+document.MainForm.elements[i].DisplayName+" !");
      document.MainForm.elements[i].focus();
      return false;
    }
    if (!IsNumeric(document.MainForm.elements[i].value) &&
        document.MainForm.elements[i].type=="text" &&
        document.MainForm.elements[i].Numeric==1
       ) {
      alert("Please enter "+document.MainForm.elements[i].DisplayName+" !");
      document.MainForm.elements[i].focus();
      return false;
    }
    if(document.MainForm.elements[i].IsPass==1){
      if (document.MainForm.elements[i].value==""){
        alert("Введите пароль!");
        return false;
      }
      if (document.MainForm.elements[document.MainForm.elements[i].ToCompare].value!=document.MainForm.elements[i].value){
        alert("Пароли не совпадают!");
        return false; 
      }
    }
  }
  return true;
}

function IsNumeric(value){
  var re;
  re=new RegExp("^[0-9.]*$","i");
  if (value==1) return true;
  return (value.match(re)&&(value-1));
}
