function getyScroll()
 {
  yScroll = 0;

  if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX)
   {
    yScroll = window.innerHeight + window.scrollMaxY;
    xScroll = window.innerWidth + window.scrollMaxX;

    var deff = document.documentElement;
    var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
    var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;

    xScroll -= (window.innerWidth - wff);
    yScroll -= (window.innerHeight - hff);
   } 
  else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth)
   { // all but Explorer Mac
    yScroll = document.body.scrollHeight;
    xScroll = document.body.scrollWidth;
   } 
  else 
   { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    yScroll = document.body.offsetHeight;
    xScroll = document.body.offsetWidth;
   }

  return yScroll;
 }

function showregistrationform()
 {
  $('registration-pop-up').style.display = 'block';
  $('screen2').style.display = 'block';
  $('screen2').style.height = getyScroll() + 'px'; //window.innerHeight + window.scrollMaxY;
 }

function hideregistrationform()
 {
  $('registration-pop-up').style.display = 'none';
  $('screen2').style.display = 'none';
 }

function showpicuploadform()
{
   var winScroll = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
   $('picuploadform').style.display = 'block'; 
//   $('picuploadform').style.top = (135+winScroll)+'px';
   $('picuploadform').style.top = '410px';
   $('screen').style.display = 'block';
   $('screen').style.height = getyScroll() + 'px'; //window.innerHeight + window.scrollMaxY;
}

function hidepicuploadform()
 {
  $('picuploadform').style.display = 'none';
  $('screen').style.display = 'none';
 }

window.onresize = function()
 {
  if ($('pagemenuszd')) $('pagemenuszd').style.fontSize = (document.body.clientWidth < 991) ? '9px' : '17px'; //1006-7
  if ($('pagemenuszd2')) $('pagemenuszd2').style.fontSize = (document.body.clientWidth < 991) ? '10px' : '15px'; //1006-7
  if (navigator.appName.indexOf('Internet Explorer') != -1 && navigator.appVersion.substr(0, 1) < 7) { //IE lt 7
   if ($('content'))
    $('content').style.width=( document.body.clientWidth < 900)?'724':'';
  }
 }

window.onresize();
window.onload = window.onresize;

function register(evt)
 {
  if (!evt)
   evt = window.event;

  if (evt.ctrlKey && !disKeyTrap)
   {
    switch(evt.keyCode)
     {
      case 37:
       aelt = $('previous_page');
       if (aelt) location.href = aelt.href;
       break;

      case 39:
       aelt = $('next_page');
       if (aelt) location.href = aelt.href;
       break;
     }
   }
 }

disKeyTrap = false;
document.onkeydown = register;



function check_email(e) 
{
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++)
	{
		if(ok.indexOf(e.charAt(i))<0)
		{ 
			return (false);
		}	
	} 

	if (document.images) 
	{
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) 
		{
			return (-1);		
		} 
	}
}


function check_form(f) 
{
	if(f.login.value=='Имя пользователя' || f.login.value.length < 3 || f.login.value.length > 20)
	{
		alert("Введите имя");
		f.login.focus();
		return false;
	}

	if(!check_email(f.email.value))
	{
		alert("Введите e-mail");
		f.email.focus(); 
		return false;
	}
	
	if(f.password.value.length < 4 || f.password.value!=f.repeatpassword.value || f.password.value==f.login.value)
	{
		alert("Введите пароль");
		f.password.focus();
		return false;
	}	
	
	
	return true;
}


