function checkform(form) {
	var err = '';
	if (form.name.value.length == 0) {
		err = err + 'Brak imienia i nazwiska\n';
	}
	if (form.email.value.length == 0) {
		err = err + "Brak adresu email\n";
	} else {
		sem = form.email.value;
		if ((sem == "") || (sem.indexOf ('@', 0) == -1) || (sem.indexOf ('.', 0) == -1) || (sem.length < 6|| sem.indexOf ('.',0) == -1)) {
			err = err + "Niepoprawny adres email\n";
		}
	}
	if (form.message.value.length == 0) {
		err = err + 'Brak treści zgłoszenia\n';
	}
    if (err != '') {
    	alert(err);
    	return false;
    }
	return true;
}

function clearform() {
  document.getElementById('name').value = '';
  document.getElementById('email').value = '';
  document.getElementById('message').value = '';
}

function preview(img,opis,width,height) {
	var sw = screen.width;
	var sh = screen.height;
	var swInside = screen.width - 30;
	var shInside = screen.height - 50;
	if (opis == null) {
  		opis = '';
	}
	if ((width >= swInside) && (height >= shInside)) {
		newwidth = swInside;
		newheight = shInside;
		lleft = (sw-newwidth) / 2;
		ltop = (sh-newheight) / 2;
		window.open('preview.php?file='+img+'&name='+opis, '', 'width='+newwidth+',height='+newheight+',left='+lleft+',top='+ltop+',scrollbars=yes,resizable=yes');
	} else if ((width >= swInside) && (height < shInside)) {
		newwidth = swInside;
		newheight = height;
		lleft = (sw-newwidth) / 2;
		ltop = (sh-newheight) / 2;
		window.open('preview.php?file='+img+'&name='+opis, '', 'width='+newwidth+',height='+newheight+',left='+lleft+',top='+ltop+',scrollbars=yes,resizable=yes');
	} else if ((width < swInside) && (height >= shInside)) {
		newwidth = width;
		newheight = shInside;
		lleft = (sw-newwidth) / 2;
		ltop = (sh-newheight) / 2;
		window.open('preview.php?file='+img+'&name='+opis, '', 'width='+newwidth+',height='+newheight+',left='+lleft+',top='+ltop+',scrollbars=yes,resizable=yes');
	} else {
		lleft = (sw-width) / 2;
		ltop = (sh-height) / 2;
		window.open('preview.php?file='+img+'&name='+opis, '', 'width='+width+',height='+height+',left='+lleft+',top='+ltop+',scrollbars=no,resizable=no');
	}
}

function lazyPreview(img,opis) {
  window.open('lazypreview.php?file='+img+'&name='+opis, '', 'width=50,height=50,left=50,top=50,scrollbars=yes,resizable=yes');
}

