var ETest = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var LTest = /^([a-z0-9\.\-])+$/;

function rejestracja1()
{
   error = '';
   
   if (document.getElementById('loginr').value.length<5) error += "Login musi składać się z minimum 5 znaków!\n";
   if (!LTest.test(document.getElementById('loginr').value)) error += "Login może składać się z małych liter (bez polskich znaków), cyfr lub myślnika!\n";
   if (document.getElementById('pass1').value != document.getElementById('pass2').value)
      error += "Wprowadzone hasła różnią się od siebie!\n";
   else if (document.getElementById('pass1').value.length<5) error += "Hasło musi składać się z minimum 5 znaków!\n";
   if (!ETest.test(document.getElementById('email').value)) error += "Podaj poprawny adres e-mail (np. nazwa@domena.pl)!\n";
   if (document.getElementById('city').value.length<2) error += "Podaj miasto!\n";
   if (document.getElementById('passkod').value.length!=6) error += "Przepisz kod z obrazka!\n";
   if (document.getElementById('regulamin').checked != 1) error += "Brak akceptacji regulaminu!\n";

   if (error != '')
   {
      alert(error);
      return false;
   }
   else
      return true;
}

function rejestracja2()
{
   error = '';

   if (document.getElementById('typbudynku').value == 0) error += "Wybierz typ budynku!\n";
   if (document.getElementById('rodzajbudynku').value == 0) error += "Wybierz rodzaj budynku!\n";
   if (document.getElementById('technologia').value == 0) error += "Wybierz technologię!\n";
   if (document.getElementById('project_city').value == 0) error += "Wpisz miejsce budowy!\n";

   if (error != '')
   {
      alert(error);
      return false;
   }
   else
      return true;
}

function rejestracjakonto1()
{
   error = '';
   
   if (document.getElementById('nick').value.length<3) error += "Nick musi składać się z minimum 3 znaków!\n";
   if (!ETest.test(document.getElementById('email').value)) error += "Podaj poprawny adres e-mail (np. nazwa@domena.pl)!\n";
   if (document.getElementById('pass1').value != document.getElementById('pass2').value)
      error += "Wprowadzone hasła różnią się od siebie!\n";
   else if (document.getElementById('pass1').value.length<5) error += "Hasło musi składać się z minimum 5 znaków!\n";
   if (document.getElementById('passkod').value.length!=6) error += "Przepisz kod z obrazka!\n";
   if (document.getElementById('regulamin').checked != 1) error += "Brak akceptacji regulaminu!\n";

   if (error != '')
   {
      alert(error);
      return false;
   }
   else
      return true;
}

function zatwierdz(strona)
{
  error = '';

   if (document.getElementById('login').value.length<3) error += "Podaj login!\n";
   if (document.getElementById('pass').value.length<3) error += "Podaj hasło!\n";

   if (error != '') {
      alert(error);
      return false;
   }
   else
   {
	if (!ETest.test(document.getElementById('login').value)) document.getElementById('forma').action = "http://www."+document.getElementById('login').value+"."+strona;
	else document.getElementById('forma').action = "http://"+strona;	
      return true;
   }
}

function sprawdzenie_komentarz()
{
   error = '';
   if (document.getElementById('tresc').value.length<2) error += "Wpisz treść komentarza!\n";
   if (!document.getElementById('reg').checked) error += "Brak zgody na publikację!\n";

   if (error != '')
   {
      alert(error);
      return false;
   }
   else
      return true;
}

function przypomnienie()
{
   error = '';
   if (document.getElementById('loginp').value.length<4) error += "Wpisz poprawny login!\n";
   if (!ETest.test(document.getElementById('mailp').value)) error += "Podaj poprawny adres e-mail!\n";
      
   if (error != '')
   {
      alert(error);
      return false;
   }
   else
      return true;
}

function mail_do_uzytkownika() {
	error = '';
	if (!ETest.test(document.getElementById('user_email').value)) error += "Podaj poprawny adres e-mail!\n";

	if (error != '') {
		alert(error);
		return false;
	} else return true;
}

function showhide(co)
{

   if (document.getElementById(co).style.display == 'none') document.getElementById(co).style.display = 'block'; else document.getElementById(co).style.display = 'none';

   return false;
}

function nowe_okno(adres)
{
   window.open(adres,'','');

}

function new_window_zdjecie(adres)
{
   window.open(adres, 'Zdjecie', 'resizable=yes,scrollbars=yes,menubar=yes,toolbar=yes,status=no, width=600, height=600');
}

//function new_window_img(adres)
//{
//   window.open(adres, 'Zdjecie', 'resizable=no,scrollbars=yes,menubar=yes,toolbar=no,status=no, width=820, height=720');
//}

function new_window_img(adres)
{
   window.open('powiekszenie.php?plik='+adres, 'Zdjecie', 'resizable=yes,scrollbars=yes,menubar=yes,toolbar=no,status=no,width=820,height=700');
}

function new_window(adres)
{
   window.open(adres, 'Pomoc', 'resizable=yes,scrollbars=yes,menubar=yes,toolbar=yes,status=no, width=600, height=600');
}

function wstawkolor(pole, wartosc)
{
      document.kolory.getElementById(pole).value = wartosc;	
      return true
}

function reklamastyle()
{

element = document.getElementById("reklama");

  element.style.fontSize = "14px";
  element.style.fontWeight = "bold";
  element.style.color = "red";

        x = document.body.scrollWidth;
        y = document.body.scrollHeight;

//alert((y-100));

  element.style.right = ((x-980)/2)+'px';
//  element.style.bottom = ((y-150))+'px';
}


function zamknij() {
  widoczne=false;
}

function go() {
  if (window.scrollX>=0) { // przesunięcie okna dla Netscape
    x = window.scrollX; y = window.scrollY;
  } else { // dla IE, Opery, Firefox
    x = document.body.scrollLeft;
    //y = document.body.scrollTop; // nie dziala w IE 7
    y = document.documentElement.scrollTop;
  }
  docelowax = pozycjax + x;
  doceloway = pozycjay + y;

  yd = (doceloway - parseInt(obj.style.top)) / 5;
  xd = (docelowax - parseInt(obj.style.left)) / 5;

  obj.style.left = parseInt(obj.style.left) + xd + "px";
  obj.style.top = parseInt(obj.style.top) + yd + "px";

  if (widoczne) { setTimeout("go()", 50); }
  else { obj.style.visibility = "hidden"; }

}
