function $(id) {
  if (typeof id == 'string') {
    return document.getElementById(id)
  }
  return id
}
function showbg (id)
  {
  $(id).style.background='url(\'img/menu_curr.gif\') 50% 100% no-repeat';
  }
function hidebg (id)
  {
  $(id).style.background='none';
  }

function bshowbg (id)
  {
  $(id).className='brand_menu_item bbbmenu';
  }
function bhidebg (id)
  {
  $(id).className='brand_menu_item';
  }

function doLoad(act,fio,mail,msg,keystring) {
    var errors='';
    if (fio=='' || fio=='имя')
    {
    errors+=("Введите Ф.И.О.\n");
    }
    if (mail=='' || mail=='e-mail')
    {
    errors+=("Введите E-mail\n");
    }
    if (msg=='')
    {
    errors+=("Введите сообщение\n");
    }
    if (keystring=='' || keystring=='проверочное слово')
      {
      errors+=("Введите проверочный текст");
      }
    if (errors=='')
      {
      // Create new JsHttpRequest object.
      var req = new JsHttpRequest();
      // Code automatically called on load finishing.
      
      req.onreadystatechange = function() {
         if (req.readyState == 4) {
            document.getElementById('z').innerHTML = req.responseText;
            document.getElementById('z').style.display='block';            
          }
      }
      // Prepare request object (automatically choose GET or POST).
      req.open(null, 'send.html', true);
      // Send data to backend.
      req.send( { act: act , fio: fio, mail: mail, msg: msg, keystring: keystring} );
      }
    else
      {
      alert (errors);
      }
    }


function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && document.body.scrollTop ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && document.documentElement.scrollTop ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}
function detect_c () 
{
if (self.innerWidth) 
  {	    
  x = self.innerWidth;	    
  y = self.innerHeight;  
  // IE 6 Strict Mode	
  } 
else if (document.documentElement && document.documentElement.clientWidth) 
  {	    
  x = document.documentElement.clientWidth;	    
  y = document.documentElement.clientHeight;
  // Остальные версии IE	
  } 
else if (document.body) 
  {	    
  x = document.body.clientWidth;	    
  y = document.body.clientHeight;
  }	
  x=x/2;
  y=y/2;
  y=y-170;
  x=x-276;
if (x<0)
  {x=0;}
if (y<0)
  {y=0;}
document.getElementById('z').style.top = getScrollY()+y+'px';
document.getElementById('z').style.left = x+'px';
}
  		
function show_ok (sess) {
detect_c();
document.getElementById('z').innerHTML='<table class=z_table><tr><td class=z1></td><td class=z2></td><td class=z3><a href="javascript:;" onclick="hide_ok();"><img src="blank.gif" width=25 height=25></a></td></tr><tr><td class=z4></td><td class=z5><div class=fname>сообщение</div><form name=sendmail onsubmit="doLoad(\'send\',sendmail.fio.value,sendmail.email.value,sendmail.text.value,sendmail.keystring.value);"><div class=z_name><input type=text name=fio value="имя" onfocus="if (this.value==\'имя\') {this.value=\'\';this.style.color=\'#000000\';}"></div><div class=z_mail><input type=text value="e-mail" name=email onfocus="if (this.value==\'e-mail\') {this.value=\'\';this.style.color=\'#000000\';}"></div><div class=z_text><textarea name=text></textarea></div><table width=100%><tr><td><img src="kcaptcha/?'+sess+'"></td><td class=z_arrow><img src="img/z_arrow.gif" width=12 height=5></td><td><input type="text" name="keystring" class=keystring></td><td width=100% align=right><a href="javascript:;" onclick="doLoad(\'send\',sendmail.fio.value,sendmail.email.value,sendmail.text.value,sendmail.keystring.value);"><img src="img/z_submit.png" width=150 height=22></a></td></tr></table></form></td><td class=z6></td></tr><tr><td class=z7></td><td class=z8></td><td class=z9></td></tr></table>';
document.getElementById('z').style.display = 'block';

}
function hide_ok() 
  {
  document.getElementById('z').style.display = 'none';
  }

window.onresize=detect_c

