function openwin( src,name,width,height )
{
   window.open( src,name,'location=no,resizable=no,width='+width+',height='+height+',top=30,left=5,scrollbars=yes' );
}

function show(id)
{
   window.open( 'inc/sklep/wiecej_fotek.php?id=' + id, 'wiecej_fotek', 'location=no,resizable=no,width=900,height=750,left=40,top=100,scrollbars=yes' );
}

function test(id)
{
   window.open( 'inc/sklep/test.php?id_prod=' + id, 'test', 'location=no,resizable=no,width=430,height=450,left=40,top=100,scrollbars=yes' );
}

function szukajstr( str )
{
    if ( str.length > 0 && str != "Suchbegriff eingeben" )
      parent.location.href='index.php?&szukaj='+str+'&miasto=&kod=&ulica=';
    else
      alert( 'Podaj zwrot do wyszukania!' );
}


//mapa

    var map = null;
    var geocoder = null;

    function load() {
      if (GBrowserIsCompatible()) {

        //var map = new GMap(document.getElementById("map"));
        //map.addControl(new GMapTypeControl());
        //map.centerAndZoom(new GPoint(-122.141944, 37.441944), 4);

        map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        geocoder = new GClientGeocoder();
      }
    }

    function showAddress(address,komunikat) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {

              alert( "Nieodnaleziono: " + address);
              //document.getElementById("mapa").style.visiblity="hidden";

            } else {
              map.setCenter(point, 13);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              marker.openInfoWindowHtml( komunikat );
            }
          }
        );
      }
    }


// -------------------------------------------------------------------------------------------------------------- podpiwiedzi
      function wpisz( wal )
      {
          document.getElementById( "test" ).value = wal;
          parent.location.href="http://dabrowa24.pl/index.php?szukaj="+wal+"&miasto=&kod=&ulica=";
      }

      function wyniki(tab)
      {
          var tresc = "";
          var the_result = null;
          var explode;
          var wysokosc = ((tab.length*20)+100) + "px";
          var x = 0;
          for ( var i=0 ; i<tab.length ; i++ )
          {
             if ( x==1 ) x=0; else x=1;

             the_result = tab[i];
             if ( the_result != null )
             {
                 explode = the_result.split("\t");
                 tresc += "<tr onclick='wpisz( \""+explode[0]+"\");' class=wiersz_wyn_"+x+"><td height='20' align=left>&nbsp;&nbsp;" + explode[0] + "</td><td align=right><b>" + explode[1] + "</b> <font color=green>firm spełniających</font>&nbsp;&nbsp;</td></tr>";
             }
          }

          //document.getElementById( "results" ).style.height = ((tab.length+1)+parseInt((tab.length+1)/5)+1) + "em";
          document.getElementById( "results" ).style.height = wysokosc;
          document.getElementById( "results" ).innerHTML = "<table width=100% height='"+wysokosc+"' border=0 cellpadding=0 cellspacing=0>" + tresc + "</table>";
      }

      function getSlowaFromFile( plik, napis )
      {
          var request = null;
          var xml_responde = null;
          if ( window.XMLHttpRequest )
             request = new XMLHttpRequest();
          else
             request = new ActiveXobject( "Microsoft.XMLHTTP" );

          if ( request )
          {
              request.open( "GET", "firmy.php?napis="+napis );
              request.onreadystatechange = function() {
                  if ( request.readyState == 4 )
                  {
                      xml_responde = request.responseXML;
                      document.getElementById( "results" ).style.visibility="visible";
                      wyniki( findSlowo( xml_responde, napis ) );
                      //document.getElementById( "results" ).innerHTML = findSlowo( xml_responde, napis );
                  }
                  else
                    document.getElementById( "results" ).innerHTML="WYSZUKIWANIE....";
              }
              request.send(null);
          }
          else
            alert( "Twoja przeglądarka nieobsługuje AJAX-a" );
      }

      function findSlowo( xml_doc, napis )
      {
          var translation = "brak spełniających!";
          var this_word = "";
          var this_element = null;
          var the_translation = "brak spełniających!";
          var these_translation = new Array();
          var wszystkie_elementy = xml_doc.getElementsByTagName("slowo");
          var wszystkie_elementy_ilosc = xml_doc.getElementsByTagName("ilosc");
          var reg_exp = new RegExp("^" + napis );
          var found = false;
          var i=0;

          //alert( "test" + wszystkie_elementy.length );
          while ( (i<wszystkie_elementy.length) && (found==false) )
          {
              this_word = wszystkie_elementy[i].firstChild.nodeValue;
              //alert( this_word );

              if ( reg_exp.test(this_word) )
              {
                  //the_translation = 5 ; //wszystkie_elementy[i].nextSibling.firstChild.nodeValue;
                    the_translation = wszystkie_elementy_ilosc[i].firstChild.nodeValue;
                  found = true;
              }
              i++;
          }

          if ( found == true )
          {
             these_translation.push( this_word + "\t" + the_translation );

             // 000000000000000000000000000000000000000 strona 369
             for ( var count = i ; count < (i+10) ; count++ )
             {
                 if ( count < wszystkie_elementy.length )
                 {
                     this_word = wszystkie_elementy[count].firstChild.nodeValue;
                     if ( reg_exp.test(this_word) )
                     {
                         //the_translation = 5; //wszystkie_elementy[count].nextSibling.firstChild.nodeValue;
                         the_translation = wszystkie_elementy_ilosc[i].firstChild.nodeValue;
                         these_translation.push( this_word + "\t" + the_translation );
                     }
                 }
             }
             return these_translation;
          }

      }

      function obsluga( wartosc )
      {
          if (wartosc != '')
             getSlowaFromFile( 'asd', wartosc );
          else
             document.getElementById( "results" ).style.visibility="hidden";
      }


  function show_message( myEvent )
  {
     var x = myEvent.pageX;
     var y = myEvent.pageY;


     var warstwa = document.getElementById( "message" );
     warstwa.style.visibility="visible";
     warstwa.style.border="solid 1px #9B9893";
     warstwa.style.width="200px;";
     //warstwa.style.height="50px;";
      //warstwa.style.backgroundcolor="gray";
     warstwa.style.top=y+15;
     warstwa.style.left=x;

     warstwa.innerHTML = "Wprowadź zwrot, który chcesz odnaleść w naszym serwisie.";
  }

  function hide_message()
  {
     var warstwa = document.getElementById( "message" );
     warstwa.style.visibility="hidden";
  }



