function opensmallwindow(w, h) {
	if (window.smallwindow) {smallwindow.close();}
	smallwindow = window.open('', 'smallwindow', 'width='+w+', height='+h+', toolbar=no, scrollbars=yes')
	smallwindow.focus();
}

function openprintwindow(w, h) {
	if (window.printwindow) {printwindow.close();}
	printwindow = window.open('', 'printwindow', 'width='+w+', height='+h+', toolbar=no, scrollbars=yes')
	printwindow.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 se_status(a,b) {
	window.status = a+'@'+b+'.pl';
	return true;
}

function validateorderform() {
	for (var i=0; i<fields.length; i++) {
		if (document.forms['f'].elements[fields[i]].value == '') {
			alert(fields_info[i]);
			document.forms['f'].elements[fields[i]].focus();
			return false;
		}
	}
  if (!validateemail(document.forms['f'].elements['email'].value)) {
      return false;
  }
  if (!document.forms['f'].acceptreg.checked) {
  	alert('Przeczytaj i zaakceptuj regulamin sklepu internetowego'); return false;
  }
  if (!document.forms['f'].acceptpersonal.checked) {
  	alert('Aby wysłać zamówienie należy wyrazić zgodę na przetwarzanie danych w celu kontaktu i realizacji zamówienia.');
	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 p(x) {
   return x.toString().replace(/\,/,'.');
}

function checkext(name) {
  var ext = document.f.elements[name].value;
  var ext2 = document.f.elements[name].value;
  if (ext.length > 0) {
  	ext = ext.substring(ext.length-3,ext.length);
  	ext = ext.toLowerCase();
  	ext2 = ext2.substring(ext2.length-4,ext2.length);
  	ext2 = ext2.toLowerCase();
  	if(ext != 'jpg' && ext2 != 'jpeg') {
      alert('W tym polu akceptowane są wyłącznie pliki JPG.');
	  document.f.elements[name].focus();
	  document.f.elements[name].select();
      return false;
    } else {
      return true;
    }
  }
  return true;
}

function showdivlab1() {
	if (document.f.fvat.checked) {
		divlab1.style.display = 'block';
	} else {
		divlab1.style.display = 'none';
	}
}

function showdivlab2() {
	if (document.f.sendaddr.checked) {
		divlab2.style.display = 'block';
	} else {
		divlab2.style.display = 'none';
	}
}

