var ns6=document.getElementById&&!document.all;
var ie4=document.all;
var ns4=document.layers;
function okno(pole) {
 mywin=window.open(pole,'Note','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=5,height=5');
}
function pokaz(identyfikator) { 
if(ie4) 
document.all[identyfikator].style.visibility = "visible";
if(ns6) 
document.getElementById(identyfikator).style.visibility = "visible";
if(ns4)
document.layers[identyfikator].visibility = "show";
}

function ukryj(identyfikator) { 
if(ie4)
document.all[identyfikator].style.visibility = "hidden";
if(ns6)
document.getElementById(identyfikator).style.visibility = "hidden";
if(ns4)
document.layers[identyfikator].visibility = "hide";
}
function fotosy(w,h,id,fotka,path) {window.open('moduly/galeria/fotka.php?id='+id+'&fotka='+fotka+'&path='+path,fotka+''+id,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width='+w+',height='+h);}
function wypelnij(pole) {mywin=window.open('moduly/katalog/wybierz_kat.php?full=0&wybrana=&wybrana2=&wybrana3=&pole='+escape(pole),'Note','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=600,height=160');}
function wypelnij1(pole) {mywin=window.open('moduly/ogloszenia/wybierz_kat1.php?full=0&wybrana=&wybrana2=&wybrana3=&pole='+escape(pole),'Note','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=600,height=160');}
function wypelnij3(pole) {mywin=window.open('moduly/admin/wybierz_kat_gal.php?full=0&wybrana=&wybrana2=&wybrana3=&pole='+escape(pole),'Note','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=600,height=160');}
function wypelnij4(pole) {mywin=window.open('moduly/admin/wybierz_kat_vid.php?full=0&wybrana=&wybrana2=&wybrana3=&pole='+escape(pole),'Note','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=600,height=160');}


function calendar(pole) {mywin=window.open('calendar.php?pole='+escape(pole),'Note','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,copyhistory=0,width=180,height=200');}
function okno(pole) {
 mywin=window.open(pole,'Note','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=5,height=5');
}
function Trim(tekst) {
   var p=0;
   while ((p < tekst.length) && (tekst.charAt(p)==' '))   { p++; }
   if (p==tekst.length)   return "";
   var k = tekst.length -1;
   while ((k>=0) && (tekst.charAt(k)==' '))   {k--; }
   return tekst.substring (p, k+1);
}
function dlugosc(pole,len) { return (pole.length>=len); }

function test_nazwa(pole)
 {pole.value=Trim(pole.value);
  if ((pole.value.length < 3) || (pole.value.length > 100))
   {alert ("Podaj prawidłową nazwę/tytuł,  dopuszczalna liczba znaków - 100");
    pole.select();pole.focus();return true;
   }
  else
   return false;
 }
function test_cena(pole)
 {pole.value=Trim (pole.value);
  if (pole.value.length > 100)
   {alert ("Wprowadź prawidłowo cenę,  dopuszczalna liczba znaków - 100");
    pole.select();pole.focus();return true;
   }
  else
   return false;
 }
function test_kat(pole)
{
if((pole.value=="...kategoria główna...") || (pole.value=="...wybierz kategorię...") || (pole.value==""))
{
alert ("Wybierz Kategorię główną!");
    return true;
   }
  else return false;
}
function test_kat1(pole)
{
if((pole.value=="...kategoria główna...") || (pole.value=="...wybierz kategorię...") || (pole.value==""))
{
alert ("Wybierz Kategorię!");
    return true;
   }
  else return false;
}
function test_opis(pole) {
if((pole.value.length < 3) || (pole.value.length > 250)) {
alert ("Wprowadź prawidłowy opis, dopuszczalna liczba znaków - 250");
    pole.select();pole.focus();return true;
}
else return false;
}
function test_autor(pole) {
if((pole.value.length < 3) || (pole.value.length > 100)) {
alert ("Podaj autora, dopuszczalna liczba znaków - 100");
    pole.select();pole.focus();return true;
}
else return false;
}
function test_path(pole) {
if((pole.value.length < 3) || (pole.value.length > 100)) {
alert ("Wprowadź scieżkę, dopuszczalna liczba znaków - 100");
    pole.select();pole.focus();return true;
}
else return false;
}
function test_tresc(pole) {
if((pole.value.length < 3) || (pole.value.length > 250)) {
alert ("Podaj prawidłową treść ogłoszenia, dopuszczalna liczba znaków - 250");
    pole.select();pole.focus();return true;
}
else return false;
}
function test_tresc_email(pole) {
if((pole.value.length < 3) || (pole.value.length > 250)) {
alert ("Podaj prawidłowo treść wiadomości, dopuszczalna liczba znaków - 250");
    pole.select();pole.focus();return true;
}
else return false;
}
function test_email(pole)
 {pole.value=Trim(pole.value);
  if ((pole.value.length!="") && ((pole.value.indexOf('@',0)==-1) || (pole.value.indexOf('.',0)==-1) || (pole.value.indexOf('@',2)==-1)) || (pole.value.length==""))
   {alert ("Wprowadź właściwy adres e-mail!");
    pole.select();pole.focus();return true;
   }
  else
   return false;
 }
function test_url(pole)
{
pole.value=Trim(pole.value);
if ((pole.value.length>0) && ((pole.value.indexOf('http://',0)==-1) || (pole.value.indexOf('.',7)==-1)) || (pole.value.length==0))
   {alert ("WprowadĄ właściwy adres www, zaczynając od 'http://'");
    pole.select();pole.focus();return true;
   }
  else
   return false;
}
function test_kontakt(pole) {
if((pole.value.length < 3) || (pole.value.length > 100)) {
alert ("Podaj jakiś kontakt(np. nr telefonu), dopuszczalna liczba znaków - 100");
    pole.select();pole.focus();return true;
}
else return false;
}
function test_punkty(pole,punkty) 
{
  if(pole.value > (50 - punkty)) {
    if(punkty == 50) {
      alert('Na ten zakład postawiłeś już 50 punktów!');
      pole.value=0;
      return true;
    }
    else {
      nowy = 50 - punkty;
      alert('Na ten zakład może postawić jeszcze max '+nowy+' punktów.');
      pole.value=nowy;
      pole.select();
      pole.focus();
      return true;
    }
  }
  else return false;
}
function test_radio(pole){
  if(pole.value == "") {alert('Nie wybrano typu zakładu!');return true;}
  else return false;
}
function test_maxpkt(pole,pkt){
  if(parseInt(pole.value) > pkt) {alert('Nie masz tyle punktówna koncie!');pole.value=0;return true;}
  else return false;
}
function test_minpkt(pole,pkt){
  if(parseInt(pole.value) < 1) {alert('Obstawiamy od 1 w góre');pole.value=1;return true;}
  else return false;
}
function test_zaklad(form,id,punkty,pkt)
{
  pktid = 'pkt'+id;
  nacoid = 'naco'+id;
  wygranaid = 'wygrana'+id;
  radioid = 'radio'+id;
  if(test_punkty(form.elements[pktid],punkty) || test_radio(form.elements[nacoid]) || test_maxpkt(form.elements[pktid],pkt) || test_minpkt(form.elements[pktid])) return;else form.submit();
}
function test_all(form)
 {
  if (test_nazwa(form.nazwa) || test_url(form.url) || test_kat(form.kategoria1h) || test_opis(form.opis))
   return;
  else
   form.submit();
 }
function test_all1(form)
 {
  if (test_cena(form.cena) || test_nazwa(form.nazwa) || test_kontakt(form.url) || test_kat1(form.kategoria1h) || test_tresc(form.opis))
   return;
  else
   form.submit();
 }
function test_all3(form)
 {
  if (test_autor(form.autor) || test_nazwa(form.nazwa) || test_path(form.path) || test_kat1(form.kategoria1h) || test_opis(form.opis))
   return;
  else
   form.submit();
 }
function test_wiadomosc(form)
 {
  if (test_email(form.email) || test_tresc_email(form.tresc))
   return;
  else
   form.submit();
 }
function potwierdz(tekst,strona) {
  if(confirm(tekst)) self.location.href=strona;
}

function okno_fotka3(nazwa,w,h) {

if(!h && !w) {h=500;w=600;}
config='scrollbars=no,resizable=1,toolbar=no,location=no,directories=no,status=no,menubar=no,width='+w+',height='+h;
pop = window.open ("","pop",config);
pop.focus();
pop.document.write('<html><head><meta http-equiv="Content-type" content="text/html; charset=win-1250"><meta http-equiv="Content-Language" content="pl"><meta name="Description" content="KIBOL CUP"><title>Sportowe Kaszuby</title>');
pop.document.write('<scri'+'pt>function roz_pol() {obrazek = new Image;obrazek.src = "'+nazwa+'";w = obrazek.width;h = obrazek.height;w = w + 10;h = h + 20;window.resizeTo(0,0);window.resizeBy(w,h);x = (screen.width/2)-(w/2);y = (screen.height/2)-(h/2);window.moveTo(x,y);}</scri'+'pt>');
pop.document.write('</head>');
pop.document.write("<body onLoad='roz_pol();' topmargin=10 leftmargin=0>");
pop.document.write('<table align=center style="height: 100%;"><tr><td><img name="foto" src='+nazwa+' onClick="window.close();" alt="Zamknij okno" style="border:2px #c0c0c0 solid;"></tr></table>');
pop.document.write('</body>');
pop.document.write('</html>');
pop.document.close();


}


function okno_fotka(nazwa,szer,wys) {
config='scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,width=640,height=480';
pop = window.open ("","pop",config);
pop.focus();
pop.document.write('<html><head><META NAME="Description" CONTENT="www.KIBOL.pl"><meta http-equiv="Content-type" content="text/html; charset=iso-8859-2"><meta http-equiv="Content-Language" content="pl"><meta name="Description" content="Kibol.pl"><title>Kibol.pl</title>');
pop.document.write('</head>');
pop.document.write('<body  background="img/bg.jpg" topmargin=0 leftmargin=0>');
pop.document.write('<center><img name="foto" src='+nazwa+' onClick="window.close();" alt="Zamknij okno"></center>');
pop.document.write('</body>');
pop.document.write('</html>');
pop.document.close();
}
function okno_fotka2(nazwa,w,h) {
if(!h && !w) {h=380;w=440;}
config='scrollbars=no,resizable=1,toolbar=no,location=no,directories=no,status=no,menubar=no,width='+w+',height='+h;
pop = window.open ("","pop",config);
s = 600;
     w = 550;
     pop.resizeTo(s, w);
     x = (screen.width/2)-(s/2); 
     y = (screen.height/2)-(w/2);
     pop.moveTo(x,y);
     pop.focus();    
pop.focus();
pop.document.write('<html><head><meta http-equiv="Content-type" content="text/html; charset=iso-8859-2"><meta http-equiv="Content-Language" content="pl"><meta name="Description" content="Kibol.pl"><title>Kibol.pl</title>');
pop.document.write('</head>');
pop.document.write('<body  background="images/kibol_tlo.jpg" topmargin=10 leftmargin=0>');
pop.document.write('<center><img name="foto" src='+nazwa+' onClick="window.close();" alt="Zamknij okno" style="border:2px #c0c0c0 solid;"></center>');
pop.document.write('</body>');
pop.document.write('</html>');
pop.document.close();
}

function updownshadow(){
if (event.srcElement.effect=="popshadow"){
shadowobj=event.srcElement
if (event.type=="mousedown"){
shadowobj.filters[0].color=shadowobj.mousedowncolor
shadowobj.style.left=shadowobj.style.top=0
}
else if (event.type=="mouseout" && event.fromElement.effect=="popshadow" || event.type=="mouseup"){
shadowobj.filters[0].color=shadowobj.mouseupcolor
shadowobj.style.left=shadowobj.style.top=shadowobj.filters[0].OffX*(-1)
}
}
}

if (document.attachEvent){
document.attachEvent("onmousedown", updownshadow)
document.attachEvent("onmouseup", updownshadow)
document.attachEvent("onmouseout", updownshadow)
}


