//--------------------------------------
if (document.images) {
//	mDef = newImage("img/m_default.jpg");
//	m8_on = newImage("/img/m8_over-mod.jpg");
}
//--------------------------------------
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
//--------------------------------------
function rollover(id1,name1, nMode){
  if (document.images) {
  	if (nMode==0){
  		document.images[id1].src=eval(name1+".src");
	}else{
		document.images[id1].src=name1;
	}
  }
  return true;
}//rollover
//--------------------------------------
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
//--------------------------------------
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//--------------------------------------
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
//--------------------------------------
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//--------------------------------------
//--------------------------------------

//MM_preloadImages('/img/menu_comp02.gif','/img/menu_pro02.gif','/img/menu_kach02.gif','/img/menu_usug02.gif','/img/menu_garan02.gif','/img/menu_kak02.gif')

//--------------------------------------
//--------------------------------------
function showpict(isrc, w, h, talt) {
	var appear,pic;
appear='top=' + (screen.height/2-330) + ',left=' + (screen.width/2-290) + ',width=' + w + ',height=' + h + ',directories=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0';
pic=window.open('', 'pictw', appear);
pic.document.open();
	pic.document.write("<HTML><HEAD><SCRIPT>window.focus();</SCRIPT></HEAD><BODY LEFTMARGIN=\"0\" TOPMARGIN=\"0\" MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\"><table border=0 cellpadding=0 cellspacing=0><tr align=center valign=middle><td><a href=\"#\" onclick='if (window.opener) {window.opener.focus();window.close();}'><IMG border=0 SRC=\"" + isrc + "\" WIDTH=\"" + w + "\" HEIGHT=\"" + h + "\" ALT=\"" + talt + "\"></a></td></tr></table></BODY></HTML>");
pic.document.close();
}
//--------------------------------------
function popupW(isrc, ihref, ialt, iw, ih, ww, wh) {
	var appear,pic;
appear='top=' + (0) + ',left=' + (0) + ',width=' + ww + ',height=' + wh + ',directories=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0';
//screen.height/2-90
//screen.height/2-90
adv=window.open('', 'wadv', appear);
adv.document.open();
adv.document.write("<HTML><HEAD lang=ru><meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\"><SCRIPT>window.focus();</SCRIPT></HEAD><BODY bgcolor=\"white\" LEFTMARGIN=\"0\" bottommargin=0 TOPMARGIN=\"0\" MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\"><table border=0 cellpadding=0 cellspacing=0 align=center><tr align=center valign=middle WIDTH=\"" + (ww) + "\" HEIGHT=\"" + (wh) + "\"><td><a href=\"" + "#" + "\" onclick=\"window.open('" + ihref + "');self.close();//if (navigator.appName!='Netscape') self.close();\"><IMG border=0 SRC=\"" + isrc + "\" WIDTH=\"" + iw + "\" HEIGHT=\"" + ih + "\" ALT=\"" + ialt + "\" vspace=0 hspace=0></td></tr></table></BODY></HTML>");
adv.document.close();
}
//---------------------------------------
function is_digit(checkStr, smode) {
	 	var checkOK;
		if 		(smode==1) checkOK = "0123456789.,"
		else if (smode==2) checkOK = "0123456789"
		else if (smode==3) checkOK = "0123456789,"
		else if (smode==4) checkOK = "0123456789."
		else if (smode==5) checkOK = "0123456789/"
		else			   checkOK = "0123456789.,"
		var allValid
		if (checkStr.length==0)
			allValid=0
		else {
		 allValid = 1;
		 for (i = 0;  i < checkStr.length;  i++) {
		    ch = checkStr.charAt(i);
		    for (j = 0;  j < checkOK.length;  j++)
		      if (ch == checkOK.charAt(j))
        			{break;}//alert(checkOK);
			if (j == checkOK.length)  {
		      allValid = 0;
		      break;
		    }
		 }//for
		 }//if
		return allValid;
}//is_digit
//----------------------
function y2k(number) { return (number < 1000) ? number + 2000 : number; }
														//+ 1900
function isDate (day,month,year) {
// checks if date passed is valid
// will accept dates in following format:
// isDate(dd,mm,ccyy), or
// isDate(dd,mm) - which defaults to the current year, or
// isDate(dd) - which defaults to the current month and year.
// Note, if passed the month must be between 1 and 12, and the
// year in ccyy format.
    var today = new Date();
    year = ((!year) ? y2k(today.getYear()):year);
    month = ((!month) ? today.getMonth():month-1);
    if (!day) return false
    var test = new Date(year,month,day);
	//alert('test.getYear()= '+ test.getYear() + 'y2k(test.getYear())= ' + y2k(test.getYear()) + 'year= ' +  year)
    if ( (y2k(test.getYear()) == year) &&
         (month == test.getMonth()) &&
         (day == test.getDate()) ){
        return true;
    }else
        return false
}//isDate
//--------------------------------------
	// вызывается из текстовых полей для очистки дефолтового зн-я
	// onfocus="clearVal(this, ' Пароль:', '');" onblur="clearVal(this, '', ' Пароль:');"
function clearVal(fld, fval1, fval2) {
	if (fld.value==fval1)
		fld.value=fval2;
	//fld.select();
}//clearVal
//--------------------------------------


// -------------------------
// ---- menu functions -----
// -------------------------

 var t;
 var onl=0; 

// Показ или скрытие подменю
function set_menu(num,on_off,parent)
{
   if(!onl) return;

    // Если нам нужно показать подменю on_off=1
    if(on_off)
     {
      // Прячем все подменю
	 all_off();
      // Очищаем таймер
         clearTimeout(t);
      // показываем подменю
	 show_menu(num);
     }
    else 
     {
      // Прячем подменю on_off=0, замораживая его на время, дабы успеть переключиться на него 
	off(num)
     }
}

// Замораживаем подменю
  function off(num)
   {
    t = setTimeout("document.all.sm"+num+".style.visibility='hidden';document.all.sm"+num+".style.display='none';", 500);
   }


// Прячет все подменю
  function all_off()
   {
    for(var i=1;i<=4;i++)
      {
       var id=document.getElementById("sm"+i);
       if(id){id.style.visibility='hidden';id.style.display='none';}
      }
    }

// Показывает подменю
  function show_menu(num)
   {
    var id=document.getElementById("sm"+num);
    id.style.visibility='visible';
	id.style.display='block';
    }



