
var imap=2;
 var oldmap=1;  
var br=0;
var titlayer;
var Id;
  function setDate(){
    if(document.request.dt.value!="") return;
    d = new Date();
    m = d.getUTCMonth() + 1;
    if(m<10) m = "0" + m;
    n = d.getUTCDate();
    if(n<10) n = "0" + n;
    document.request.dt.value = d.getUTCFullYear()+"-"+m+"-"+n;
  }

///////////////////////////////////////////////////

function checkNumber(d1)
  {
    var pattern =/^[0-9.,-]+$/
    if (pattern.exec(d1) != null)
      {
      return true;
      }
  //alert("not  Number");

  return false;
  }

////////////////////////////////////////////////////
  function checkdate(){
var d=document.request.dt.value;
var i = d.indexOf("-");
var tmp;
var gg;
var dd;
var mm;
var pr=true;
gg=d.substring(0,i);
//var l=gg.length;
if(i!=4){ alert("Ошибка в поле Дата. Проверьте год");
document.request.dt.focus();
pr=false;
}
if(!checkNumber(gg)){
 alert("Ошибка в поле Дата. Нечисловой символ");
document.request.dt.focus();
pr=false;
}
tmp=d.substring(i+1);
i = tmp.indexOf("-");
mm=tmp.substring(0,i);
mm=((mm<10 &mm.length==1) ? "0" : "")+mm;
if(mm>12){
alert("Ошибка в поле Дата.   Месяц больше 12");
document.request.dt.focus();
pr=false;
}
if(mm<1){
alert("Ошибка в поле Дата.   Месяц меньше 1");
document.request.dt.focus();
pr=false;
}
if(mm.length>2){
alert("Ошибка в поле Дата.   Месяц больше двух цифр:("+mm+")");
document.request.dt.focus();
pr=false;
//alert(tmp);
}
if(!checkNumber(mm)){
 alert("Ошибка в поле Дата. Нечисловой символ");
document.request.dt.focus();
pr=false;
}
//////////////////// day
tmp=tmp.substring(i+1);
dd=((tmp<10 & tmp.length==1 ) ? "0" : "")+tmp;

if(dd>31){
alert("Ошибка в поле Дата.   День больше 31:"+dd);
document.request.dt.focus();
pr=false;
}
if(dd<1){
alert("Ошибка в поле Дата.   День 01:"+dd);
document.request.dt.focus();
pr=false;
}
if(dd.length>2){
alert("Ошибка в поле Дата.   День больше двух цифр:("+dd+")");
document.request.dt.focus();
pr=false;
//alert(tmp);
}
if(!checkNumber(dd)){
 alert("Ошибка в поле Дата. Нечисловой символ");
document.request.dt.focus();
pr=false;
}
//////////////////////////////////
if((mm==04 || mm==06 || mm==09 || mm==11) & dd>30){
alert("Ошибка в поле Дата.   День больше 30");
document.request.dt.focus();
pr=false;
}
if((mm==02 ) & dd>29){
alert("Ошибка в поле Дата.   День больше 29");
document.request.dt.focus();
pr=false;
}
//////////////////////////////
var da=gg+"-"+mm+"-"+dd;
//Date dtemp=new Date(gg,mm-1,dd,0,0);
document.request.dt.value=da;
return pr;

}
//////////////////////////////////////////////////////////
  function scale(){
     if(!checkdate()) return;
   document.request.clear.value='n'; 
   document.request.daten.value="TIME="+getSelDate();
   document.request.submit();
//window.frames ['frmMapsContent'].location.replace ("maps1.jsp?" + mapSrc);

  }

//********************************************************
  function getSelDate(){
//alert("gg");
var selNum =document.request.hh.selectedIndex;
var Isel = document.request.hh.options[selNum].value;
    return document.request.dt.value + "T" + Isel+"Z";
          
  }
//****************************************
  function newMap(){
 document.request.clear.value='m'; 
document.request.action="index.jsp";
document.request.submit();
   
//window.frames ['frmMapsContent'].location.replace ("maps1.jsp?mapaction=*");
  
  }

/////////////////////
//**********************************************
////////////////////////////////////


///////////////////////////////////////////////////
  function SelectClicked()
{

document.request.action="index.jsp";
document.request.submit();
// alert('start');

//alert('end');

}
//=================================
//=================================
function checkClicked() {

var obj = document.request.check1;
    if(obj){
   if (!obj.checked){
  //alert("not");
   br=1;
  if(Id){ window.clearTimeout(Id); Id=0;}
 return;
	         }
}
//==========================
br=0;
// oldmap=imap;
     
var is=1;
if(oldmap==1) is=2;
 imap=is;
//alert(" oldmap="+oldmap+" imap="+imap);
 //      for(i=is;i<10;i++){
                to();
  //     }
}
//===========================
  function to() {
  toggleMapIz ();
   chm();
  changeTitle();
//alert("to");
//if(br==0)  
if(oldmap!=9)  Id = window.setTimeout("to()", 3000);

}
//================================
function chm() {
oldmap=imap; 
 if(oldmap==9){
 	 br=1; 
 	 // alert("stop"); 
 	 }
 if(imap==9) imap=0; 
imap++;

}
//===============================
function re() {

//alert('re()');
checkClicked();
}
//==================================
function sroki() {
br=1;
if(Id) window.clearTimeout(Id);
//oldmap=imap;


//alert("sroki(): oldmap="+oldmap+" imap="+imap);

 toggleMapIz ();
oldmap=imap; 
changeTitle();
if(imap==9) imap=0; 
imap++;
//alert('sroki()');

}
//==================================
function toggleMapIz () {


// index visible 
var mapid;
//alert("toggleMapIz: oldindex="+h+" index="+index);
mapidt= 'divMaptt';
mapidp= 'divMappp';

var str="";
str=mapidt+oldmap;
if(!document.request.chv2) return;
var objt = document.request.chv2[0]; // tt
var objp = document.request.chv2[1]; //pp
    if(objt){
   if (objt.checked){
//alert(str);
if (document.all && document.all (str) )
		 document.all (str).style.visibility =  'hidden';
		else if (document.getElementById && document.getElementById (str))
			document.getElementById (str).style.visibility =  'hidden';
			}}
str=mapidp+oldmap;
//alert(str);
  if(objp){
   if (objp.checked){
if (document.all && document.all (str) )
		 document.all (str).style.visibility =  'hidden';
		else if (document.getElementById && document.getElementById (str))
			document.getElementById (str).style.visibility =  'hidden';
} }
str=mapidt+imap;
  if(objt){
   if (objt.checked){
//alert(str);
if (document.all && document.all (str) )
		 document.all (str).style.visibility =   'visible';
		else if (document.getElementById && document.getElementById (str))
			document.getElementById (str).style.visibility =  'visible';
			} }
str=mapidp+imap;
  if(objp){
   if (objp.checked){
//alert(str);
if (document.all && document.all (str) )
		 document.all (str).style.visibility =  'visible';
		else if (document.getElementById && document.getElementById (str))
			document.getElementById (str).style.visibility =  'visible';
   } }

//alert("end");
  }
///////////////////////////////////////////////////
//===================================
function changeTitle(){
if (document.all && document.all (str) ){
titlayer = document.all["ch"];
var obj1 = document.request.titd.value;
//alert("obj1="+obj1);
var str=titlayer.innerHTML;
//titlayer.innerHTML=oldmap;
//alert("str="+str);
var td=subStrT(obj1,oldmap);
var newt=repTit(str,td);
titlayer.innerHTML=newt;
//" <b><center><H3>"+subStrT(obj1,oldmap)+"</b></center></H3>"
}
}
//====================================
function setVisible(){
/*
countmap1=countmap.value;
alert("setVisible(): "+countmap1);
if(countmap1=="1") return;
*/
}
//===================================
  function subStrT(wr,pos){
  var otv=""; 
    for( j=0; j<pos; j++){ 
    if(j==8) return wr;		
    var i = wr.indexOf(",");
  
    if(i!=-1) {
    otv=wr.substring(0, i);
    wr = wr.toString().substring(i+1);
     }
    }
    return otv;
  }
//====================================
  function repTit(str,td){
   var i = str.indexOf("(");
    if(i==-1) 	return str;
    var otv="";
    otv=str.substring(0, i);
    otv=otv+td;
    var i = str.indexOf(")");
     if(i==-1) return str;
     otv=otv+str.substring(i+1);
     return otv;
  	}

//===================================
function toggleMap (chkbx) {
  //var mapid = 'div' + chkbx.name;
var mapi;
var val=chkbx.value;
mapi= 'divMap'+val;
mapi=mapi+oldmap;
//alert("toggleMap: "+mapi);


  if (chkbx.checked) { 
  
		if (document.all && document.all (mapi) )
		 document.all (mapi).style.visibility = 'visible';
		else if (document.getElementById && document.getElementById (mapi))
			document.getElementById (mapi).style.visibility = 'visible';
		 
		 }
  else {
	if (document.all && document.all (mapi))
		document.all (mapi).style.visibility = 'hidden';
	else if (document.getElementById && document.getElementById (mapi))
		document.getElementById (mapi).style.visibility = 'hidden';

		}
  }

////////////////////////////////////////////
function ohelp(){
 window.open("help.jsp","", "height=400,width=800,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");

}
//=====================================
function openBrWind(url,name,features) {
  window.open(url,name,features);
/*
  <input type="image" src="/images/btn/btn_sts.gif" border="0" alt="Статус сообщения" CLASS="formimage"
                   onclick="openBrWind('/status_frame.xsp?id=2020027634&lang=rus', '', 'scrollbars=0, width=528, height=306'); return false;">
*/
}
//====================================
