function printContents()
{
	iWidth = window.screen.width;
	iHeight = window.screen.height;
    wt = 630;
    ht = 460;
    lt = (iWidth - wt) / 2;
    tp = (iHeight - ht) / 2;
    window.open("print.php", '', 'height='+ht+',width='+wt+',top='+tp+',left='+lt+',toolbar=no,resizable=no,scrollbars=yes'); 
}

function preview(file, desc, width, height)
{
 if (desc == null) {
   desc = '';
 }
 var left = (screen.width - width) / 2;
 var top = (screen.height - height + 20) / 2;
 window.open("preview.php?file="+file+"&desc="+desc, "_preview_", "width="+width+",height="+height+",top="+top+",left="+left);
}

function submitSearch() {
	document.location = "?section=search&searchText=" + document.getElementById('search').value;
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent)	{
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}	else if (obj.y) {
		curtop += obj.y;
	}
	return curtop;
}

function updateHP() {
	var height = findPosY(document.getElementById('footer')) - findPosY(document.getElementById('groups')) - 5;
	document.getElementById('groups').style.height = height + "px";
}

function checkNL(form) {
	var err = '';
	if (form.email.value.length == 0) {
		err = err + "Brak adresu e-mail";
	} 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 format adresu e-mail\n";
		}
	}
	if (err != '') {
		alert(err);
		return false;
	}
	return true;
}

function unsubscribe() {
	var form = document.getElementById('nlForm');
	if (checkNL(form)) {
		var email = document.getElementById('nlForm');
		window.location = 'newsletter,unsubscribe.html?email=' + email.value;
	}
}

function popupImage(file, desc, width, height) {
	preview(file, desc, width, height);
}


