function nowy_token() {
	var id = new Math.random(9999);
	document.getElementById("token").src = "captcha/captcha.php?id=" + id + "";
	document.getElementById("captcha").value = "";
}

function checkAll(aId, aChecked) {
		var table = document.getElementById(aId); 
		var cells = table.getElementsByTagName("input"); 

    for (var x=0; x<cells.length; x++) {
        if (cells[x].type.toUpperCase()=='CHECKBOX')
            cells[x].checked = aChecked;
    }
}


function expand(div)
{
	var Block = document.getElementById('tab'+div);
	if (Block.style.display=='none') {Block.style.display='block';}
	else {Block.style.display='none';}

	var Link = document.getElementById('link'+div);
	
	
	if (Link.className=='sha_lnk_minus')
		{ Link.className='sha_lnk_plus'; }
	else
		{ Link.className='sha_lnk_minus'; }
			
}

function Drukuj(url, width, height, scrollbars) {
 var Win=window.open(url,"ToDo",'width=' + width + ',height=' + height + ',resizable=no,scrollbars=' + scrollbars + ',menubar=no' );
}

function checkKonkurs()
{
  var brakuje_danych=false;
  var formularz=document.forms[0];
  var napis="";
  if (formularz.imie.value == ""){
    napis += "- imię\n"
    brakuje_danych=true;
  }
	
  if (formularz.nazwisko.value == ""){
    napis += "- nazwisko\n"
    brakuje_danych=true;
  }
	
	var WzorMaila = /^[0-9a-zA-Z_.-]+@+[0-9a-zA-Z.-]+\.[a-zA-Z]{2,3}$/;
	if (WzorMaila.test(formularz.data.value)){}else 
	{
    napis += "- e-mail (np. imienazwisko@nnn.pl)\n"
    brakuje_danych=true;
  }
	
  if (!brakuje_danych)
    { 
			return true; 
		}
  else
    { 
			alert ("Proszę poprawnie wypełnić następujące pola:\n" + napis);
			return false;
		}
}

function show_confirm(url)
{
	var r=confirm("Czy na pewno usunąć?");
	if (r==true)
		{
		window.location=url;
		}
	else
		{
		
		}
}

function ask(url)
{
	var r=confirm("Wyłączenie pytania spowoduje usunięcie jego treści\noraz wszystkich odpowiedzi na to pytanie.\n\nCzy na pewno wyłączyć pytanie?");
	if (r==true)
		{
		window.location=url;
		}
	else
		{
		
		}
}

function confirmation(url)
{
	var r=confirm("Czy na pewno przejść do strony 'Produkty powiązane'? \n\n Wszystkie niezapisane dane z bieżącego formularza zostaną utracone. \n\n Aby kontynuować do strony 'Produkty powiązane' kliknij OK.");
	if (r==true)
		{
		window.location=url;
		}
	else
		{
		
		}
}

function confirmClear(url)
{
	var r=confirm("Czy na pewno wyczyścić listę uczestników, konkursu?\n\n Aby zresetować listę kliknij OK.");
	if (r==true)
		{
		window.location=url;
		}
	else
		{
		
		}
}

function recount(IDWysylki)
{
	var forma = document.getElementById('value'+IDWysylki);
	var kosztProduktow = document.getElementById('ZaProdukty');
	
	var SUMA = parseFloat(kosztProduktow.value) + parseFloat(forma.value);
	
	document.getElementById('totalValue').value=SUMA;
}

function openDIV(DIVid)
{
	var DIV = document.getElementById(DIVid);
	if (DIV.style.display=='none') {DIV.style.display='block';}
	else {DIV.style.display='none';}
}

function showNhide(show,hide1,hide2)
{
	var DIV1 = document.getElementById(show);
	var DIV2 = document.getElementById(hide1);
	var DIV3 = document.getElementById(hide2);
	
	DIV1.style.display='block'; 
	DIV2.style.display='none';
	DIV3.style.display='none';
}
