var ETest  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

function doPic(imgName, imgBig)
{
   imgOn = imgName;
   Widok = imgBig;
   document.getElementById('widok').src = imgOn;
}

function doWidok(imgBig)
{
   document.getElementById('grafika').src = ("../pliki/widoki/" + imgBig);
}

function displayWindowWR(url, width, height, nazwa, id, rzut)
{
   window.open(url + '&nazwap=' + nazwa + '&idp=' + id + '&rzut=' + rzut ,"displayWindow",'width=' + width + ',height=' + height +
      ',resizable=no,scrollbars=no,menubar=no,personalbar=no,toolbar=no,' +
      'status=no' );
}

function displayPromesa(url, width, height, nazwa)
{
   window.open(url + '?nazwa=' + nazwa ,"displayWindow",'width=' + width + ',height=' + height +
      ',resizable=no,scrollbars=no,menubar=no,personalbar=no,toolbar=no,' +
      'status=no' );
}

function displayCharakterystyka(url, width, height, nazwa)
{
   window.open(url + '?nazwa=' + nazwa ,"displayWindow",'width=' + width + ',height=' + height +
      ',resizable=yes,scrollbars=yes,menubar=no,personalbar=no,toolbar=no,' +
      'status=no' );
}

function displayWindow(url, width, height)
{
   window.open(url,"displayWindow",'width=' + width + ',height=' + height +
      ',resizable=no,scrollbars=no,menubar=no,personalbar=no,toolbar=no,' +
      'status=no' );
}

function displayLustro(url, width, height)
{
   window.open(url,"displayWindow",'width=' + width + ',height=' + height +
      ',resizable=no,scrollbars=yes,menubar=no,personalbar=no,toolbar=no,' +
      'status=no' );
}

function displayTablica(nazwa, width, height)
{
   window.open(strona + "/popUp/tablica.php?nazwa=" + nazwa,"displayWindow",'width=' + width + ',height=' + height +
      ',resizable=no,scrollbars=no,menubar=no,personalbar=no,toolbar=no,' +
      'status=no' );
}

function displayArchPakiet(nazwa, width, height)
{
   window.open(strona + "/popUp/archpakiet.php?nazwa=" + nazwa,"displayWindow",'width=' + width + ',height=' + height +
      ',resizable=no,scrollbars=no,menubar=no,personalbar=no,toolbar=no,' +
      'status=no' );
}

function display(url)
{
   window.open(url,'','');
   return false;
}

function promocja_func(co,gdzie) {
var pokaz = 'pokaż';
var ukryj = 'ukryj';
	if(document.getElementById(gdzie).innerHTML == pokaz) {
		document.getElementById(co).style.display = "block";
		document.getElementById(gdzie).innerHTML = ukryj;
	} else {
		if(document.getElementById(gdzie).innerHTML == ukryj) {
			document.getElementById(co).style.display = "none";
			document.getElementById(gdzie).innerHTML = pokaz;
		}
	}
}

function setCheckboxes(the_form, do_check)
{
    var elts      = document.forms[the_form].elements['notes[]'];
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = do_check;
        }
    } else {
        elts.checked        = do_check;
    }

    return true;
}


function notes_submit(val)
{
   document.getElementById('sub').value = val;
   
   if (val == 2)
      document.forms['notesik'].target='_blank';
   else
      document.forms['notesik'].target='_self';
      
   document.forms['notesik'].submit();
}

function pokaz_regulamin(url, width, height)
{
   window.open(url,"displayWindow",'width=' + width + ',height=' + height +
      ',resizable=no,scrollbars=yes,menubar=no,personalbar=no,toolbar=no,' +
      'status=no' );
}

function zglosreklamacje()
{
   error = '';
   if (document.getElementById('imie').value == '') error += "Podaj imie i nazwisko\n";
   if (document.getElementById('tresc').value == '') error += "Podaj czego dotyczy reklamacja\n";
   if (!ETest.test(document.getElementById('mejl').value)) error += "Podaj poprawny adres e-mail.\n";
   if (document.getElementById('zgoda').checked != 1) error += "Aby wysłać zgłoszenie musisz zgodzić\n się na wykorzystanie twoich danych.\n";

   if (error != '')
   {
      alert (error);
      return false;
   }
   else
      return true;
}

function zglosblad()
{
   error = '';
   if (document.getElementById('tresc').value == '') error += "Podaj opis bledu\n";
   if (document.getElementById('lnk').value == '') error += "Podaj link do bledu\n";
   if (!ETest.test(document.getElementById('mejl').value)) error += "Podaj poprawny adres e-mail.\n";
   
   if (error != '')
   {
      alert (error);
      return false;
   }
   else
      return true;
}

function polaczenie_szyfrowane()
{
	if (location.protocol=="http:") {
  		location.href = location.href.replace(/^http:/, "https:")
	}
}

function polaczenie_nieszyfrowane()
{
	if (location.protocol=="https:") {
  		location.href = location.href.replace(/^https:/, "http:")
	}
}

function zgoda_func(co,gdzie) {
var pokaz = 'pokaż';
var ukryj = 'ukryj';
	if(document.getElementById(gdzie).innerHTML == pokaz) { 
		document.getElementById(co).style.display = "block";
		document.getElementById(gdzie).innerHTML = ukryj;
	} else {
		if(document.getElementById(gdzie).innerHTML == ukryj) { 
			document.getElementById(co).style.display = "none";
			document.getElementById(gdzie).innerHTML = pokaz;
		}
	}
}

function promocja_mtm_func(co,gdzie) {
var pokaz = 'pokaż';
var ukryj = 'ukryj';
	if(document.getElementById(gdzie).innerHTML == pokaz) { 
		document.getElementById(co).style.display = "block";
		document.getElementById(gdzie).innerHTML = ukryj;
	} else {
		if(document.getElementById(gdzie).innerHTML == ukryj) { 
			document.getElementById(co).style.display = "none";
			document.getElementById(gdzie).innerHTML = pokaz;
		}
	}
}
