var popUpWin=0;

function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=1,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function popUpWindowNS(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=0,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


function checkEmail()	{

	var emailRegExp = /^[A-Za-z0-9._\-]+@(([A-Za-z]\.)|([A-Za-z0-9][A-Za-z0-9\-]+\.))+[A-Za-z]+$/;
	
	if ((!emailRegExp.test(document.formEmail.EmailAddress.value)) || (document.formEmail.EmailAddress.value == 'tutaj wpisz swój email'))	{

		document.formEmail.EmailAddress.focus();
		alert('Wpisz poprawny adres email!');
		return false;
	}
	
	return true;
}

function RecommendFormCheck1()	{
	
	var emailRegExp = /^[A-Za-z0-9._\-]+@(([A-Za-z]\.)|([A-Za-z0-9][A-Za-z0-9\-]+\.))+[A-Za-z]+$/;
	
	if(!emailRegExp.test(document.RecommendForm.RecommendFromEmail.value))	{
		
		document.RecommendForm.RecommendFromEmail.focus();
		alert('Wpisz poprawny adres email nadawcy!');
		return false;
	}
	
	if(!emailRegExp.test(document.RecommendForm.RecommendToEmail.value))	{
		
		document.RecommendForm.RecommendToEmail.focus();
		alert('Wpisz poprawny adres email odbiorcy!');
		return false;
	}
	
	return true;
}


function FormCheckEmail(email)	{
	var emailRegExp = /^[A-Za-z0-9._\-]+@(([A-Za-z]\.)|([A-Za-z0-9][A-Za-z0-9\-]+\.))+[A-Za-z]+$/;
	if (!emailRegExp.test(email)){
		return false;
	}
	return true;
}

function FormCheckValue(temp){
	if (temp == 0)	{
		return false;
	}
	return true;
}

function FormCheckFormatFile(file) {		
	var tab = new Array();
	tab = file.split(".");
	var i = tab.length;
	var ext = tab[i-1];		
	if(ext != 'doc' && ext!= 'pdf') {			
		return false;
	}		
	return true;
}

function FormCheckConfirm(inp) {
	if(inp.checked == false)		
		return false;		
	return true; 
}

function ContactFormCheck1()	{

	var emailRegExp = /^[A-Za-z0-9._\-]+@(([A-Za-z]\.)|([A-Za-z0-9][A-Za-z0-9\-]+\.))+[A-Za-z]+$/;
	if (!emailRegExp.test(document.cf.cfEmail.value))	{
		
		document.cf.cfEmail.focus();
		alert('Wpisz poprawny adres email!');
		return false;
	}
	if (document.cf.cfSubject.value == 0)	{

		document.cf.cfSubject.focus();
		alert('Podaj temat wiadomości!');
		return false;
	}
	if (document.cf.cfContent.value == 0)	{

		document.cf.cfContent.focus();
		alert('Podaj treść wiadomoci!');
		return false;
	}
	return true;
}

function RegisterFormCheck1()	{

	var emailRegExp = /^[A-Za-z0-9._\-]+@(([A-Za-z]\.)|([A-Za-z0-9][A-Za-z0-9\-]+\.))+[A-Za-z]+$/;
	if (!emailRegExp.test(document.cf.cfEmail.value))	{
		
		document.cf.cfEmail.focus();
		alert('Wpisz poprawny adres email!');
		return false;
	}
	return true;
}