function fo(id){return document.getElementById(id)}

function isEmailValid(em)
{
  var p1=em.indexOf('@'), p2=em.lastIndexOf('.'), l=em.length; 
  return (p1 > 0) && (p2 > p1+1) && (p2 < l-1); 
}

function checkSubscrForm()
{
  var sError = "";
//  if (!isEmailValid(fo("email").value)) sError += "Введенный Вами Email адрес не корректен.\n";
  if (fo("name").value == "") sError += "Не указано Ваше имя.\n";
  if (fo("phone").value == "") sError += "Не указан Контактный телефон.\n";
  if (fo("notes").value == "") sError += "Не введен текст сообщения.\n";
  if (fo("number").value == "") sError += "Не введены цифры с картинки.\n";
  if (sError) alert("Возникли следующие ошибки:\n\n"+sError);
  return (sError == "");
}

function pic(imgurl,wid,heg,alt) {
	wtop = (screen.height/2-heg/2);
	wleft = (screen.width/2-wid/2);
	blank = window.open('','_blank','status=0,width='+ wid +',height='+ heg +',top=' + wtop + ',left='+ wleft);
	page =	 '<html><head><title>'+ alt +'</title></head><body style="padding:0;margin:0; background:#6E849B 50% 50% no-repeat">'+
			 '<img alt="Кликните, чтобы закрыть" src="' + imgurl +'" width="'+ wid +'" height="'+ heg +'" style="cursor:pointer;cursor:hand" onclick="self.close()" />'+
			 '</body></html>';
	blank.document.open();
	blank.document.write(page);
	blank.document.close();
	return false;
}

function show(u,b)
{
  var fnSpacer = "img/spacer.gif";
  var fnSpinner = "img/spinner.gif";
  var colBackground = "#606060";

  var html = document.documentElement;  
  var iMargin = 40;
  var iWidth = 100;
  var iHeight = 100;
  var o = fo('bigimg');
  var l0 = html.clientWidth - document.body.clientWidth;
  if (l0 < 0) l0 = 0;

  function setWH(b)
  {
    if (b)
    {
      o.style.left   = ((html.clientWidth - iWidth - l0) / 2 + html.scrollLeft) + "px";
      o.style.top    = ((html.clientHeight - iHeight) / 2 + html.scrollTop) + "px";
      o.style.width  = (iWidth+iMargin/4)+"px";
      o.style.height = (iHeight+iMargin/4)+"px";
      if (o.i)
      {
        o.i.width = iWidth;
        o.i.height= iHeight;
      }
    }
    else
    {
      o._left   = parseInt((html.clientWidth - iWidth - l0) / 2 + html.scrollLeft);
      o._top    = parseInt((html.clientHeight - iHeight) / 2 + html.scrollTop);
      o._width  = parseInt(iWidth+iMargin/4);
      o._height = parseInt(iHeight+iMargin/4);
      o.step=function()
      {

        var n = 2;
        var dl = (o._left   - o.offsetLeft  )/n;
        var dt = (o._top    - o.offsetTop   )/n;
        var dw = (o._width  - o.offsetWidth )/n;
        var dh = (o._height - o.offsetHeight)/n;
        o.style.left   = parseInt(o.offsetLeft+dl)+"px";
        o.style.top    = parseInt(o.offsetTop+dt)+"px";
        o.style.width  = parseInt(o.offsetWidth+dw)+"px";
        o.style.height = parseInt(o.offsetHeight+dh)+"px";
        o.i.width = o.clientWidth-iMargin/4;
        o.i.height= o.clientHeight-iMargin/4;
        if ((Math.abs(dl)>=1) || (Math.abs(dt)>=1))
          setTimeout("o=fo('"+o.id+"');o.step()",25);
      }
      o.step();
    }
  }
  if (!o)
  {
    o = document.createElement("div");
    document.body.appendChild(o);
    o.id = "bigimg";
    o.style.cssText = "border-style:solid;border-color:#666666;border-width:1px;cursor:pointer;cursor:hand;position:absolute;display:none;background:"+colBackground+" url("+fnSpinner+") no-repeat center center;";
    o.title = "Закрыть...";
    o.onclick = function(){this.style.display='none';};
  }
  setWH(1);

  o.innerHTML="<table border='0' width='100%' height='100%'><tr><td align='center' valign='middle'><img id='theBigImg' src='"+fnSpacer+"' /></td></tr></table>";
  o.style.display = "block";

  var img = new Image();
  img.onload = function()
  {
    var i = fo('theBigImg');
    i.width = iWidth;
    i.height = iHeight;

    iWidth = img.width;
    iHeight = img.height;
    var k = iWidth / iHeight;

    if (iWidth > html.clientWidth - iMargin)
    {
      iWidth = html.clientWidth - iMargin;
      iHeight = iWidth / k;
    }
    if (iHeight > html.clientHeight - iMargin)
    {
      iHeight = html.clientHeight - iMargin;
      iWidth = iHeight * k;
    }

    i.src = u;
    o.i = i;
    setWH(b?0:1);
  }
  img.src = u;
}

function rnd(n){return Math.floor(Math.random()*n);}
function SlideShow(id,n,ar,pt,dl,w,h,v,st)
{
  var d;
  this.sError = "";
  if (n*2 > ar.length)
  {this.sError = "Много картинок, мало файлов.";return;}
  var o = fo(id);
  if (!o)
  {this.sError = "Не найден объект-родитель.";return;}
  this.bError = false;
  this.oar = new Array();
  for (var i = 0; i < n; i++)
  {
    this.oar[i] = document.createElement("img");
    if (v)d = document.createElement("div");
    if (w > 0) this.oar[i].width  = w;
    if (h > 0) this.oar[i].height = h;
    if (v)o.appendChild(d);else d=o;
    d.appendChild(this.oar[i]);
    this.oar[i].style.cssText = st;
  }
  this.ar = ar;
  this.n = n;
  this.pt = pt;
  this.dl = dl;
  this.ca = "";
  this.oid = id;
  o._slideshow = this;
}
SlideShow.prototype =
{
  InitAll: function(p)
  {
    this.ca_old = this.ca+"";
    this.ca = "";
    for (var i = 0; i < this.n; i++)
      this.oar[i].src = this.pt+this.GetNewUniqueImg();
    setTimeout("fo('"+this.oid+"')._slideshow.InitAll(1)",this.dl*1000);
    if (!p) this.Preload();
  },
  Preload: function()
  {
    this.images = new Array();
    for (var i=0;i<this.ar.length;i++)
    {
      this.images[i] = new Image();
      this.images[i].src = this.pt+this.ar[i];
    }  
  },
  GetNewUniqueImg: function()
  {
    var s = this.ar[rnd(this.ar.length)];
    var cnt = 100;
    while (((this.ca.indexOf(s)>=0) || (this.ca_old.indexOf(s)>=0)) && (cnt > 0))
    {
      s = s = this.ar[rnd(this.ar.length)];
      cnt++;
    }
    if (cnt <= 0) alert("SlideShow: Аварийный останов выбора!");
    this.ca += s+"|";
    return s;
  }
}

function checkSubscrForm()
{
  var sError = "";
//  if (!isEmailValid(fo("email").value)) sError += "Введенный Вами Email адрес не корректен.\n";
  if (fo("name").value == "") sError += "Не указано Ваше имя.\n";
  if (fo("phone").value == "") sError += "Не указан Контактный телефон.\n";
  if (fo("notes").value == "") sError += "Не введен текст сообщения.\n";
  if (fo("number").value == "") sError += "Не введены цифры с картинки.\n";
  if (sError) alert("Возникли следующие ошибки:\n\n"+sError);
  return (sError == "");
}

(function(){var menu,userAgent=navigator.userAgent.toLowerCase(),opera=/opera/.test(userAgent),onLoad=function(){var divs=document.getElementsByTagName("div");for(var i=0;i<divs.length;i++){if(divs[i].className=="MM"){menu=divs[i];var lis=menu.getElementsByTagName("li");for(var n=lis[0];n;n=n.nextSibling)if(n.tagName=="LI"){n.mm_top=true;if(opera)n.style.width=n.offsetWidth-(n.className.indexOf("tlast")==-1? 2:0);}for(var j=0;j<lis.length;j++){lis[j].className=lis[j].className;lis[j].style.position="static";var uls=lis[j].getElementsByTagName("ul");if(uls.length>0)uls[0].style.display="none";lis[j].shown=lis[j].show=false;lis[j].onmouseover=function(){clearTimeout(menu.timer);if(this.className.indexOf("mm_over")==-1)this.className+=" mm_over";this.show=true;menu.timer=setTimeout(update,160);};lis[j].onmouseout=function(){clearTimeout(menu.timer);if(!this.shown)this.className=this.className.replace(new RegExp(" ?mm_over\\b"), "");this.show=false;menu.timer=setTimeout(update,600);};}}}},update=function(){var lis=menu.getElementsByTagName("li");for(var i=lis.length-1;i>=0;i--){if(lis[i].show){if(!lis[i].shown){if(!lis[i].parentNode.style.filter){var uls=lis[i].getElementsByTagName("ul");if(uls.length>0){lis[i].style.position="relative";uls[0].style.filter="alpha(opacity=0)";uls[0].style.opacity=0;uls[0].style.display="block";fadeIn(uls[0]);lis[i].shown=true;}}else setTimeout(update,13);}}else{var uls=lis[i].getElementsByTagName("ul");if(uls.length>0){uls[0].style.display="none";lis[i].style.position="static";lis[i].shown=false;if(lis[i].className.indexOf("mm_over")!=-1)lis[i].className=lis[i].className.replace(new RegExp(" ?mm_over\\b"), "");}}}},fadeIn=function(o){o.tstart=new Date;if(!o.timer)o.timer=setInterval(function(){var s=(new Date-o.tstart)/400;if(s<1){var v=(s<0.5? s*s*s*4:1+(--s)*s*s*4);o.style.filter="alpha(opacity="+v*100+")";o.style.opacity=v;}else{clearInterval(o.timer);o.timer=undefined;o.style.filter="";o.style.opacity=1;}}, 13);},addOnReady=function(f,fu){var isReady=false,ready=function(){if(!isReady){isReady=true;f();};};if(document.addEventListener){document.addEventListener('DOMContentLoaded',ready,false);window.addEventListener("load",ready,false);window.addEventListener("unload",fu,false);}if(window.attachEvent)window.attachEvent("onload",ready);if(document.documentElement.doScroll&&window==top){(function(){if(!isReady){try{document.documentElement.doScroll("left");}catch(E){setTimeout(arguments.callee,0);return;}ready();}})()}};addOnReady(onLoad, onLoad);})();

