function graj(xw, yw, p1, p2, p3, p4)
{
	mywin=window.open('graj.php?p1='+escape(p1)+'&p2='+escape(p2)+'&p3='+escape(p3)+'&p4='+escape(p4),'','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width='+escape(xw)+',height='+escape(yw)+',left=50,top=50');
}

function Ocen(podmiot, id)
{
	mywin=window.open('ocen.php?podmiot='+escape(podmiot)+'&id='+escape(id),'Note','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=300,height=300,left=50,top=50');
}


function kup(produkt, id, zalogowany) {
//	if (zalogowany) {
	//	window.location = "kup.php?produkt="+produkt+"&id="+id;
		window.location = "redirect.php?id_plyty="+id+"&partner=15";
//	} else {
//		window.location = "rejestracja.php";
//	}
}

/*
function Zmien () {
	inny = document.getElementById ("form_inny");
	
	ulica = document.getElementById ("form_ulica");
	nr_domu = document.getElementById ("form_nr_domu");
	nr_lokalu = document.getElementById ("form_nr_lokalu");
	kod_pocztowy = document.getElementById ("form_kod_pocztowy");
	miejscowosc = document.getElementById ("form_miejscowosc");
	if (inny.checked == true) {
		ulica.disabled = false;
		nr_domu.disabled = false;
		nr_lokalu.disabled = false;
		kod_pocztowy.disabled = false;
		miejscowosc.disabled = false;
	} else {
		ulica.disabled = true;
		nr_domu.disabled = true;
		nr_lokalu.disabled = true;
		kod_pocztowy.disabled = true;
		miejscowosc.disabled = true;
	}
}
*/
function WybierzRedakcje() {
	b = document.getElementById ("redakcja_id");
	inny = document.getElementById ("form_inny");
	id = document.getElementById ("form_id");
	ulica = document.getElementById ("form_ulica");
	nr_domu = document.getElementById ("form_nr_domu");
	nr_lokalu = document.getElementById ("form_nr_lokalu");
	kod_pocztowy = document.getElementById ("form_kod_pocztowy");
	miejscowosc = document.getElementById ("form_miejscowosc");
	nazwa = document.getElementById ("form_nazwa");
/*	if (b.value != 0) {
		inny.disabled = false;
		
	} else {
		inny.disabled = true;
		inny.checked = false;
	}
	if (inny.checked == true) {
		ulica.disabled = false;
		nr_domu.disabled = false;
		nr_lokalu.disabled = false;
		kod_pocztowy.disabled = false;
		miejscowosc.disabled = false;
	} else {
		ulica.disabled = true;
		nr_domu.disabled = true;
		nr_lokalu.disabled = true;
		kod_pocztowy.disabled = true;
		miejscowosc.disabled = true;
	}
*/	
	text = b.value;
	
	if (text != 0) {
		text = text.split ("|");
		red_id = text[0];
		red_ulica = text[1];
		red_nr_domu = text[2];
		red_nr_lokalu = text[3];
		red_kod_pocztowy = text[4];
		red_miejscowosc = text[5];
		red_nazwa = text[6];
	} else {
		red_id = "";
		red_ulica = "";
		red_nr_domu = "";
		red_nr_lokalu = "";
		red_kod_pocztowy = "";
		red_miejscowosc = "";
		red_nazwa = "";
	}
	
	
	id.value = red_id;
	ulica.value = red_ulica;
	nr_domu.value = red_nr_domu;
	nr_lokalu.value = red_nr_lokalu;
	kod_pocztowy.value = red_kod_pocztowy;
	miejscowosc.value = red_miejscowosc;
	nazwa.value = red_nazwa;
}

function Wydaj(what) {
      window.location = "index.php?t=give&uid=" + what;
  }
  
  function PokazTest(what) {
      window.location = "index.php?t=show&uid=" + what;
  }
  
  function PokazHistorie(what) {
      window.location = "index.php?t=devhist&uid=" + what;
  }


function wypelnij(pole)
{
mywin=window.open('wybierz_kat.php?pole='+escape(pole),'Note','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=400,height=130,left=150,top=150');
}

function blokuj(f) {
  if (f.wyslane) return false;
  f.wyslane=true;
  return true;
}

function write_it(status_text)
{
window.status=status_text;
}

function DeleteItem(what, what_zn) {
    if (confirm('Skasować rekord?')) {
      window.location = "index.php?action=dpli&zn="+what_zn+"&item=" + what;
    }
  }
  
  function ChangeAuth(what, head) {
    window.location = "zmien_auth.php?item=" + what + "&header=" +head;
  }

  function logout () {
	window.location = "logout.php";
  }
  
  
function DeleteUser(what) {
    if (confirm('Skasować rekord nr: ' + what + '?')) {
      window.location = "index.php?t=users&do=delete&uid=" + what;
    }
  }
  
  function DeleteRedaction(what) {
    if (confirm('Skasować redakcję nr: ' + what + '?')) {
      window.location = "index.php?t=listred&do=delete&uid=" + what;
    }
  }
  
  function DeleteDevice(what) {
    if (confirm('Skasować sprzęt nr: ' + what + '?')) {
      window.location = "index.php?t=listdev&do=delete&uid=" + what;
    }
  }
  
 function ShowUser(what) {
	 window.location = "index.php?t=showuser&uid=" + what;
 }
 
 function ShowRedaction(what) {
	 window.location = "index.php?t=showred&uid=" + what;
 }
 
 function ShowDevice(what) {
	 window.location = "index.php?t=showdev&uid=" + what;
 }
  
  function DeleteErrand(what) {
    if (confirm('Skasować zlecenie nr: ' + what + '?')) {
      window.location = "delete_errand.php?item=" + what;
    }
  }

function DeleteAdmin(what) {
    if (confirm('Skasować admina?')) {
      window.location = "index.php?action=chprivadmdel&item=" + what;
    }
  }

function DeleteOrder(cart_id_done, cond) {
    if (confirm('Skasować zamówienie: '+cart_id_done+' ?')) {
      window.location = "index.php?zn=ordershow&del=1&cart_id_del=" + cart_id_done + "&cond=" + cond;
    }
  }

function DeleteMail(what) {
    if (confirm('Skasować plik?')) {
      window.location = "index.php?zn=openmail&item=" + what;
    }
  }
  
  function AddHelp () {
	  window.location = "index.php?zn=add_help";
  }
  
  function Help(id) {
		mywin=window.open('./operconf/help.php?id='+escape(id),'Note','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=450,height=270,left=225,top=225');
		mywin.focus();
  }


function setCheckboxes(the_form, do_check)
{
    var elts      = (typeof(document.forms[the_form].elements['selected_db[]']) != 'undefined')
                  ? document.forms[the_form].elements['selected_db[]']
                  : (typeof(document.forms[the_form].elements['selected_tbl[]']) != 'undefined')
          ? document.forms[the_form].elements['selected_tbl[]']
          : document.forms[the_form].elements['selected_fld[]'];
    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;
        } // end for
    } else {
        elts.checked        = do_check;
    } // end if... else

    return true;
} // end of the 'setCheckboxes()' function


function changepage(formObject)	{
	URL = formObject.options[formObject.options.selectedIndex].value;
	if(URL != "empty") {
		window.location = URL;
		URL = "";
		}
}

function BodyInfo(id, xw, yw) {
	mywin=window.open('./body/body_info.php?id='+escape(id),'Note','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width='+escape(xw)+',height='+escape(yw)+',left=50,top=50');
	mywin.focus();
  }
  
 function Odswiez () {
	 setTimeout ("location.href='index.php?zn=list_errand';" , 2500);
 }

function ShowStat(cart_id_done, id_notes, orderdisc, xw, yw) {
	mywin=window.open('/stat/show_stat.php?id='+escape(cart_id_done)+'&id_notes='+escape(id_notes)+'&orderdisc='+escape(orderdisc),'Note','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width='+escape(xw)+',height='+escape(yw)+',left=100,top=50');
	mywin.focus();
  }
  
