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,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
function validateEmail(field, alertText)
{
    var emailRegExp = /^[A-Za-z0-9._\-]+@[A-Za-z0-9]([A-Za-z0-9._\-]*\.)+[A-Za-z]+$/;
     if (!emailRegExp.test(document.getElementsByName(field)[0].value))
     {
        alert(alertText);
        document.getElementsByName(field)[0].focus();
        return false;
     }
     else
        return true;
}

function validateTxt(field, alertText)
{
    if (document.getElementsByName(field)[0].value == '')
    {
        alert(alertText);
        document.getElementsByName(field)[0].focus();
        return false;
    }
    else
        return true;
}
function check()
{
    if 			(!validateTxt('nazwisko', 'Proszę wypełnić pole imię i nazwisko.')) return false;
	else if     (!validateEmail('email', 'Proszę podać poprawny e-mail.')) return false;
	else if     (!validateTxt('telefon', 'Proszę podać numer telefonu.')) return false;
	else if     (!validateTxt('text', 'Proszę wypełnić pole pytania.')) return false;
    else return true;
}

function przekieruj(){
	var kraj = (document.form_panstwa.wykaz.value).toString();	
	document.location.href = kraj;
}

function szukaj()
{
	var departs = (document.sform.departs.value).toString();
	var arrives = (document.sform.arrival.value).toString();
	var URL = 'http://sale.euroticket.pl/start.php?profile=bileciarnia_html&cnt=cts&dctr=' + departs + '&actr=' + arrives + '&mode=prom';
	document.location.href = URL;
}

function check_ticket()
{
  if(!validateTxt('imie', 'Proszę podać imię.')) return false;
	else if(!validateTxt('nazwisko', 'Proszę podać nazwisko.')) return false;
	else if(!validateTxt('przewoznik', 'Proszę podać nazwę przewoźnika.')) return false;
	else if(!validateTxt('nrbiletu', 'Proszę podać numer biletu.')) return false;
	else if(!validateTxt('skad', 'Proszę podać miejsce wyjazdu.')) return false;
	else if(!validateTxt('dokad', 'Proszę podać miejsce przyjazdu.')) return false;
  else if(!validateTxt('datapowrotu', 'Proszę podać datę powrotu.')) return false;
  else if(!validateEmail('email', 'Proszę podać poprawny e-mail.')) return false;
	else if(!validateTxt('telefon', 'Proszę podać numer telefonu.')) return false;
  else return true;
}