﻿function PopupCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}

function popWindow(wName, w, h){

        if (SprawdzWiadomosc())
	{
		var left = (screen.width/2)-(w/2);
		var top = (screen.height/2)-(h/2);
		features = 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+',left='+left;
		pop = window.open('',wName,features);
		if(pop.focus){ pop.focus(); }
		return true;
	}
	else return false;
}


function popWindowOpen(wName, w, h){

        if (SprawdzRezerwacjeOpen())
	{
		var left = (screen.width/2)-(w/2);
		var top = (screen.height/2)-(h/2);
		features = 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+',left='+left;
		pop = window.open('',wName,features);
		if(pop.focus){ pop.focus(); }
		return true;
	}
	else return false;
}


function popWindowSolo(wName, w, h){

        if (SprawdzRezerwacjeSolo())
	{
		var left = (screen.width/2)-(w/2);
		var top = (screen.height/2)-(h/2);
		features = 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+',left='+left;
		pop = window.open('',wName,features);
		if(pop.focus){ pop.focus(); }
		return true;
	}
	else return false;
}


function popWindowDlaPar(wName, w, h){

        if (SprawdzRezerwacjeDlaPar())
	{
		var left = (screen.width/2)-(w/2);
		var top = (screen.height/2)-(h/2);
		features = 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+',left='+left;
		pop = window.open('',wName,features);
		if(pop.focus){ pop.focus(); }
		return true;
	}
	else return false;
}

function SprawdzMail(str) 
	{

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Podano błędny adres e-mail")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Podano błędny adres e-mail")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Podano błędny adres e-mail")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Podano błędy adres e-mail")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Podano błędny adres e-mail")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Podano błędny adres e-mail")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Podano błędny adres e-mail")
		    return false
		 }

 		 return true					
	}

function SprawdzEMail()
	{
	var emailID=document.forms["MAIL"].email
	
	if ((emailID.value==null)||(emailID.value==""))
		{
		alert("Podano błędny adres e-mail")
		emailID.focus()
		return false
		}
	if (SprawdzMail(emailID.value)==false)
		{
		emailID.value=""
		emailID.focus()
		return false
		}
	return true
 	}

function SprawdzWiadomosc()
	{ 	

	if (document.forms["wiad"].imienazwisko.value=="")
		{ 
		document.forms["wiad"].imienazwisko.focus();
		alert("Nie podano imienia i nazwiska"); return false;
		};
	if (document.forms["wiad"].numer.value=="")
		{ 
		document.forms["wiad"].numer.focus();
		alert("Nie podano numeru telefonu"); return false;
		};
	if (document.forms["wiad"].email.value=="")
		{ 
		document.forms["wiad"].email.focus();
		alert("Nie podano e-maila"); return false;
		};
	if (document.forms["wiad"].wiadomosc.value=="")
		{ 
		document.forms["wiad"].wiadomosc.focus();
		alert("Nie podano tresci wiadomosci"); return false;
		};


	var emailID=document.forms["wiad"].email
	
	if ((emailID.value==null)||(emailID.value==""))
		{
		alert("Podano błędny adres e-mail")
		emailID.focus()
		return false
		}
	if (SprawdzMail(emailID.value)==false)
		{
		emailID.value=""
		emailID.focus()
		return false
		}

	return true; 
	} 

function SprawdzNewsletter()
	{ 	

	if (document.forms["wiad"].email.value=="")
		{ 
		document.forms["wiad"].email.focus();
		alert("Nie podano e-maila"); return false;
		};
	if (document.forms["wiad"].imie.value=="")
		{ 
		document.forms["wiad"].imie.focus();
		alert("Nie podano imienia"); return false;
		};
	if (document.forms["wiad"].miasto.value=="")
		{ 
		document.forms["wiad"].miasto.focus();
		alert("Nie podano miasta"); return false;
		};
	var emailID=document.forms["wiad"].email
	
	if ((emailID.value==null)||(emailID.value==""))
		{
		alert("Podano błędny adres e-mail");
		emailID.focus();
		return false;
		}
	if (SprawdzMail(emailID.value)==false)
		{
		emailID.value="";
		emailID.focus();
		return false;
		}

	return true; 
	} 



function SprawdzKomentarz()
	{
	if (document.forms["komentarze"].tresc.value=="")
		{ 
		document.forms["komentarze"].tresc.focus();
		alert("Nie podano tresci komentarza");
                return false;
		}
	if (document.forms["komentarze"].autor.value=="")
		{ 
		document.forms["komentarze"].autor.focus();
		alert("Nie podano autora");
		return false;
		}
        return true;
        }


function SprawdzRezerwacjeDlaPar()
	{ 	

	if (document.forms["pary"].imienazwisko1.value=="")
		{ 
		document.forms["pary"].imienazwisko1.focus();
		alert("Nie podano pierwszego imienia i nazwiska"); return false;
		};
	if (document.forms["pary"].imienazwisko2.value=="")
		{ 
		document.forms["pary"].imienazwisko2.focus();
		alert("Nie podano drugiego imienia i nazwiska"); return false;
		};
	if (document.forms["pary"].technika.value=="")
		{ 
		document.forms["pary"].technika.focus();
		alert("Nie podano techniki"); return false;
		};

	if (document.forms["pary"].email1.value=="")
		{ 
		document.forms["pary"].email1.focus();
		alert("Nie podano pierwszego e-maila"); return false;
		};

	if (document.forms["pary"].email2.value=="")
		{ 
		document.forms["pary"].email2.focus();
		alert("Nie podano drugiego e-maila"); return false;
		};

	if (document.forms["pary"].telefon1.value=="")
		{ 
		document.forms["pary"].telefon1.focus();
		alert("Nie podano pierwszego telefonu"); return false;
		};

	if (document.forms["pary"].telefon2.value=="")
		{ 
		document.forms["pary"].telefon2.focus();
		alert("Nie podano drugiego telefonu"); return false;
		};

	if (document.forms["pary"].multisport1.value=="")
		{ 
		document.forms["pary"].multisport1.focus();
		alert("Nie podano pierwszej informacji dot. karty Benefit Multisport"); return false;
		};

	if (document.forms["pary"].multisport2.value=="")
		{ 
		document.forms["pary"].multisport2.focus();
		alert("Nie podano drugiej informacji dot. karty Benefit Multisport"); return false;
		};

	var emailID=document.forms["pary"].email1
	
	if ((emailID.value==null)||(emailID.value==""))
		{
		alert("Podano błędny pierwszy adres e-mail")
		emailID.focus()
		return false
		}
	if (SprawdzMail(emailID.value)==false)
		{
		emailID.value=""
		emailID.focus()
		return false
		}


	var emailID2=document.forms["pary"].email2
	
	if ((emailID2.value==null)||(emailID2.value==""))
		{
		alert("Podano błędny drugi adres e-mail")
		emailID2.focus()
		return false
		}
	if (SprawdzMail(emailID2.value)==false)
		{
		emailID2.value=""
		emailID2.focus()
		return false
		}


	return true; 
	} 


function SprawdzRezerwacjeSolo()
	{ 	

	if (document.forms["solo"].imienazwisko.value=="")
		{ 
		document.forms["solo"].imienazwisko.focus();
		alert("Nie podano imienia i nazwiska"); return false;
		};
	if (document.forms["solo"].technika.value=="")
		{ 
		document.forms["solo"].technika.focus();
		alert("Nie podano techniki"); return false;
		};

	if (document.forms["solo"].email.value=="")
		{ 
		document.forms["solo"].email.focus();
		alert("Nie podano e-maila"); return false;
		};

	if (document.forms["solo"].telefon.value=="")
		{ 
		document.forms["solo"].telefon.focus();
		alert("Nie podano telefonu"); return false;
		};

	if (document.forms["solo"].multisport.value=="")
		{ 
		document.forms["solo"].multisport.focus();
		alert("Nie podano informacji dot. karty Benefit Multisport"); return false;
		};

	var emailID=document.forms["solo"].email
	
	if ((emailID.value==null)||(emailID.value==""))
		{
		alert("Podano błędny adres e-mail")
		emailID.focus()
		return false
		}
	if (SprawdzMail(emailID.value)==false)
		{
		emailID.value=""
		emailID.focus()
		return false
		}

	return true; 
	} 


function SprawdzRezerwacjeOpen()
	{ 	

	if (document.forms["open"].imienazwisko.value=="")
		{ 
		document.forms["open"].imienazwisko.focus();
		alert("Nie podano imienia i nazwiska"); return false;
		};
	if (document.forms["open"].technika.value=="")
		{ 
		document.forms["open"].technika.focus();
		alert("Nie podano techniki"); return false;
		};

	if (document.forms["open"].email.value=="")
		{ 
		document.forms["open"].email.focus();
		alert("Nie podano e-maila"); return false;
		};

	if (document.forms["open"].telefon.value=="")
		{ 
		document.forms["open"].telefon.focus();
		alert("Nie podano telefonu"); return false;
		};

	if (document.forms["open"].multisport.value=="")
		{ 
		document.forms["open"].multisport.focus();
		alert("Nie podano informacji dot. karty Benefit Multisport"); return false;
		};

	var emailID=document.forms["open"].email
	
	if ((emailID.value==null)||(emailID.value==""))
		{
		alert("Podano błędny adres e-mail")
		emailID.focus()
		return false
		}
	if (SprawdzMail(emailID.value)==false)
		{
		emailID.value=""
		emailID.focus()
		return false
		}

	return true; 
	} 

	
function queryString(parameter) { 
  var loc = location.search.substring(1, location.search.length);
  var param_value = false;

  var params = loc.split("&");
  for (i=0; i<params.length;i++) {
      param_name = params[i].substring(0,params[i].indexOf('='));
      if (param_name == parameter) {
          param_value = params[i].substring(params[i].indexOf('=')+1)
      }
  }
  if (param_value) {
      return param_value;
  }
  else {
      return false; //Here determine return if no parameter is found
  }
}

