var newWindow = null;


function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}


function popUpWin(url, type, strWidth, strHeight){
	closeWin();
	
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	
	leftVal = (screen.width - strWidth ) / 2;
	topVal = (screen.height - strHeight) / 2;	
	
	var tools="";	
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left="+leftVal+",top="+topVal+"";
	if (type == "scroll") tools = "resizable,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left="+leftVal+",top="+topVal+"";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}

function checkForm(){
	var name = document.getElementById('cName');
	var email = document.getElementById('cEmail');
	var subject = document.getElementById('cSubject');
	var message = document.getElementById('cMessage');

	if (name.value == '' || email.value == '' || subject.value == '' || message.value == ''){
		alert('Všechny položky jsou povinné');
		return false;
	}
	var emailFilter=/^.+@.+\..{2,3}$/;
	
	if (!(emailFilter.test(email.value))) { 
	      alert('Vyplňte správně emailovou adresu.\n');
		return false;
	}
	return true;
}
