function winPop(url, name, w, h) {
	var l = screen.width / 2 - w / 2;
	var t = screen.height / 2 - h / 2;
	var Win = window.open(url, name, 'width=' + w + ', height=' + h + ', left=' + l + ', top=' + t);
	Win.resizeTo(w + 10, h + 30);
	Win.moveTo(l, t);
}


function winPop2(img)
{
  foto1= new Image();
  foto1.src=(img);
  check(img);
}

function check(img)
{
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
  }
  else{
    func="check('"+img+"')";
    interval=setTimeout(func,20);
  }
}

function viewFoto(img)
{
  w = foto1.width + 7; //- mozi
  h = foto1.height + 7;
  var l = screen.width / 2 - w / 2;
  var t = screen.height / 2 - h / 2;

  string="width="+w+",height="+h+",left="+l+",top="+t;
  //result=window.open(img,"",string);


  string="width="+w+",height="+h;+",toolbar=no,menubar=no, location=no, personalbar=no, status=no, resizable=no, scrollbars=no, copyhistory=no, left=" + l + ", top=" + t;
  handle=window.open(img,"",string);
  handle.document.write("<html><head><title>Netra Reklama - podglad</title><style>html,body{height:100%}body{margin:0px;padding:0;border:0;background-color:#FFFFFF;}.table{height:100%;width:100%} .ramka{border: solid 1px; border-color: #598901;  padding: 0px; margin:0px;}</style></head>");
  handle.document.write('<body><table cellpadding=0 cellspacing=0 border=0 class="table"><tr><td align=center><a href="javascript:self.close();" title="zamknij okno"><img src='+img+' class="ramka"></a></td></tr></table></body></html>');
  handle.moveTo(l, t);
}

function changeAction2(poczatek)
{
 var x=document.getElementById("form-menu");
 
 if(!poczatek) poczatek = 0;

 if(x.ilosc.value == 14) poczatek = 0;
 if(x.flaga_poczatek.value == 0 ) poczatek = 0;

 if(x.wartosc.value!='')
    {
    x.action=x.wartosc.value+','+poczatek+',search.html';
    x.submit();
    }

 else if(x.wartosc.value=='')
  {
   window.alert('Wpisz poszukiwane wyrażenie');
  }

}


function changeAction(strona,cat_id,poczatek)
{
 var x=document.getElementById("form-menu");

 if(x.flaga_poczatek.value == 0 ) poczatek = 0;

 //window.alert(x.id_grupy.value);

 if(x.ilosc.value == 14) poczatek = 0;


 if((strona !='main') && (x.id_grupy.value == '0') && (strona !='') )
  {
   //window.alert('Wybierz grupę lub użyj szukaj');
   x.wartosc.value ='';
   x.action='main.html';
   x.submit();
  }

 else
 {
 if(strona == 'oferta')
   {
    x.wartosc.value='';
    //x.action=x.id_grupy.value+','+cat_id+','+poczatek+',oferta.html';
    x.action=x.id_grupy.value+','+poczatek+',oferta.html';
   }

 else if(strona=='main')
   {
    x.wartosc.value='';
    if(x.id_grupy.value > 0 ) { x.action=x.id_grupy.value+','+cat_id+','+poczatek+',oferta.html';}

    else x.action='main.html';
   }

 else if(strona  == '')
   {
   x.wartosc.value='';
   if(x.id_grupy.value > 0 ) { x.action=x.id_grupy.value+','+cat_id+','+poczatek+',oferta.html'; }

   else x.action='main.html';
   }

 else
   {
    x.wartosc.value='';
    x.action=x.id_grupy.value+','+cat_id+','+poczatek+',oferta.html';
   }

 x.submit();
}
}


function czysc()
{
 var x=document.getElementById("form-menu");
 x.wartosc.value ='';
}


function checkEnter(e)
{
var characterCode

if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
changeAction2() //submit the form
return false
}
else{
return true
}

}

function set_poczatek()
{

 var x=document.getElementById("form-menu");
 x.flaga_poczatek.value = 0;
 //test(x.flaga_poczatek.value);

}

function test(i)
{
  window.alert(i);
}
