function opensmallwindow(w, h) {
	if (window.smallwindow) {smallwindow.close();}
	smallwindow = window.open('', 'smallwindow', 'width='+w+', height='+h+', toolbar=no, scrollbars=yes')
	smallwindow.focus();
}

function openimgwindow(w, h) {
	if (window.imgwindow) {imgwindow.close();}
	imgwindow = window.open('', 'imgwindow', 'width='+w+', height='+h+', toolbar=no, scrollbars=no')
	imgwindow.focus();
}

function openhelpwindow(w, h) {
	if (window.helpwindow) {helpwindow.close();}
	helpwindow = window.open('', 'helpwindow', 'width='+w+', height='+h+', toolbar=no, scrollbars=yes')
	helpwindow.focus();
}

function se(a,b) {
	window.location.href = 'mailto:'+a+'@'+b+'.pl';
}

function validateform() {
 for(var i=0; i<fields.length; i++) {
  if (document.f.elements[fields[i]].value == '' || document.f.elements[fields[i]].value == 0) {
   alert(fields_info[i]);
   document.f.elements[fields[i]].focus();
   return false;
  }
 }
 if (!validateemail(document.f.elements['email'].value)) {
  return false;
 }
 if (!validatepass()) {
  return false;
 }
 return true;
}

function validateemail(t) {
  maska = /^[0-9a-z_.-]+@([0-9a-z-]+.)+[a-z]{2,4}$/;
  if (maska.test(t)==false) { 
    alert("Podaj poprawny adres e-mail");
    document.f.elements['email'].focus();
    return false;
  }
  return true;
}

function validatepass(t) {
  if (document.f.elements['pass'].value != document.f.elements['pass2'].value) { 
    alert('Pola "Hasło" i "Powtórz hasło" muszą być równe');
    document.f.elements['pass2'].focus();
    return false;
  }
  return true;
}

function p(x) {
   return x.toString().replace(/\,/,'.');
}

function checkext(name) {
  var ext = document.f.elements[name].value;
  if (ext.length > 0) {
  	ext = ext.substring(ext.length-3,ext.length);
  	ext = ext.toLowerCase();
  	if(ext != 'jpg') {
      alert('Akceptowane są wyłącznie pliki JPG.');
      return false;
    } else {
      return true;
    }
  }
  return true;
}