// JavaScript Document

var submenu;
var calendar = document.getElementById("calendar_1");
var cal_s;
var month;

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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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];}
}

function showSub(uid) {
	submenu = document.getElementById(uid);
	submenu.style.display = "block";
}

function hideSub(uid) {
	document.getElementById(uid).style.display="none";
}

function menu_event(uid) {
	mmeny = document.getElementById(uid);
	if (mmeny.style.display == "none") {
		showSub(uid);
		} else {
			hideSub(uid);
			}
	}


function winopen(url, width, height) {

                sw = screen.width;
                sh = screen.height;
                var top = (sh/2) - ( height/2 );
                var left = (sw/2) - ( width/2 );
                windowprops = 'width='+width+',height='+height+',top='+top+',left='+left+',scrollbars=0,menbars=0,location=0,statusbar=0,resizable=0';
                mywin=window.open( 'about:blank', '', windowprops);
                mywin.document.open();
                mywin.document.write('<BODY TOPMARGIN=0 LEFTMARGIN=0 SCROLL=no><a href = javascript:window.close(); title = "Закрыть..."><img src='+url+' border=0></a></body>');
                mywin.document.close();

}

function mRestore(lay)
{
var cookies=document.cookie.split("; ");				
var cookieArray=new Array();
for(var cookieIndex in cookies)
{
	var temp=cookies[cookieIndex].split("=");
	cookieArray[temp[0]]=temp[1];
}

	var menuState=new Number(cookieArray["menuItem_"+lay]);
						
      if (menuState==0)	{ 
		document.getElementById(lay).style.display='none';
	}
      if (menuState==1)	{
		document.getElementById(lay).style.display='inline';
	}
}

function m(lay)
{   					
		var expireDate="Wed, 1 Mar 2027 23:59:59 UTC";

            if(document.getElementById([lay]).style.display != 'none')
                {
                    document.getElementById([lay]).style.display='none';
					document.cookie="menuItem_"+lay+"=0; "+"expires="+expireDate+";path=/;";
                }
            else
                {
                    document.getElementById([lay]).style.display='inline';
					document.cookie="menuItem_"+lay+"=1; "+"expires="+expireDate;+";path=/;";
                }
}

function checkmailform()
{
  if ( (document.forms.form.e_mail.value == null) || (document.forms.form.e_mail.value.length < 7) )
  {
    alert("Заполните поле: E-mail");
    document.forms.form.e_mail.focus();
    return false;
  }
  if (! (/^\w+[-_\.]*\w+@\w+-?\w+\.[a-z]{2,4}$/.test(document.forms.form.e_mail.value)) )
  {
    alert("Введите правильный e-mail адрес");
    document.forms.form.e_mail.focus();
    return false;
  }      
  if ( (document.forms.form.name.value == null) || (document.forms.form.name.value.length < 3) )
  {
    alert("Заполните поле: Контактное лицо");
    document.forms.form.name.focus();
    return false;
  }
  if ((document.forms.form.phone.value == null) )
  {
    alert("Заполните поле: Телефон");
    document.forms.form.phone.focus();
    return false;
  }
  return true;
}
