var map
    var marker;
    var tmp;
    var northEast;
    var southWest;
    var serwis;
    var adres;
    var geocoder = new GClientGeocoder();
    var tmpArray2;
    var currentdata = [];
var tmp_tab_data = [];
	var aktualne_wyszukiwarki=[];
	var aktualne_klucze = []; 
	var aktualne_nazwy = [];
	var pierwszy_raz = 0;
	//var geocoder = null;
    var addressMarker;
    var boxy = [];
    var url = [];
    var image = [];
    var address_new;
	var pt_new;
    
    var ttt = 2;
    
    
function rozdzielczosc()
{
	
	
	
	
	var height;
	if(navigator.appName == "Netscape")
	{
		 height = window.innerHeight;
	}
	else if(navigator.appName == "Opera")
	{
 		height = window.innerHeight;
	}
	else if(navigator.appName == "Microsoft Internet Explorer")
	{
 		 height = document.body.offsetHeight;
	}
	
	
	var new_height = parseInt(height * 0.8);
//alert(height+' - '+new_height);
	document.getElementById('map').style.height=new_height+'px';
	var tmp = new_height-100;
	document.getElementById('dane_wpisy').style.height = tmp+'px';
	

}
function preperedata()
{
	splitted2 = [];
	splitted2 = datatable.split("|");
	tmp_tab_data = [];	
	//alert(splitted2.length);
	for(i=0;i<splitted2.length;i++)
	{
		tmp_tab_data[i] = splitted2[i].split("+");	
	}
//	alert(tmp_tab_data.length);
	//tmp_tab_data =1;
	//alert(tmp_tab_data);
	return tmp_tab_data;	
}
var time;
var gdir;
    function load() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        
        map.setCenter(new GLatLng(52.2319, 21.01), 16);
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());      
        map.addControl(new GScaleControl()); 
        //gdir = new GDirections(map);

		if(ttt == 1)
		{
		
		}
		else
		{
			GEvent.addListener(map, "moveend", moveendAction); 
		//gdir = new GDirections(map, document.getElementById("directions"));    
        }
      }
    }

	function moveendAction(overlay, point)
	{
		var bounds = map.getBounds();
		if(map.getBoundsZoomLevel(bounds) >= 12)
		{
			if(pierwszy_raz !=0)
			{
				markery = [];
				clearTimeout(time);
	
				time = setTimeout("getLocation3()", 4000);
	
				$('#info').html('Dane zostaną wczytane za <span id="sek"></span> sekundy!!')
				odliczaj(document.getElementById('sek'),4) 
				$('#info').show();
			}
			else
			{
				pierwszy_raz = 1;
			}
		}
		else
		{
				$('#info').html('Zbyt duże oddalenie. Dane nie są wczytywane!!');
				$('#info').show();	
		}
	}
	
	function odliczaj(o,sek){
	o.innerHTML=sek
	if(sek>0)setTimeout(function(){odliczaj(o,--sek)},1e3)
	}


    function findAddress(address) {
   
    var jest = 0;
    var wyszukiwarki_lista = '';
    if(domena != 1)
    {
    	for(i=0;i<=ilosc_wysz;i++)
    	{
    		//alert(('#wyszukiwarka_'+i).attr('value'));
			if($('#wyszukiwarka_'+i).attr('checked'))
			{
				wyszukiwarki_lista += i+',';
				jest = 1;
			}
	
	
		}
	}
    
    /* geocoder.getLatLng(
      address, function(point) {
        if (!point) {
          alert(address + " not found");
        } else {
        alert(point);
         map.setCenter(point, 15);
        var marker = new GMarker(point);
          map.addOverlay(marker);
       }
     }
   );*/
 
    
    
   
    if(jest == 1 || domena == 1)
    {
    
      geocoder.getLatLng( address, function(pt) {
         
			//map.removeOverlay(tmp);
			markery = [];
	
          if (!pt) {
            $('#status').css('color', '#CC5049');
            document.getElementById('status').innerHTML='Adres "'+address+'" nie został znaleziony!';
          } else {
            map.setCenter(pt, 16);
            $('#status').css('color', '#32A55E');
            document.getElementById('status').innerHTML='';
            $('#miejsce').html('Twój wybrany adres to: <b>'+address+'</b>');
            
            var waznosc=new Date(); //tworzymy nowy obiekt zawierający datę
			waznosc.setTime(waznosc.getTime()+1000*60*60*24*366); //ustawianie daty wygaśnięcia (na 7 dni)
		//alert(escape(address));
            document.cookie="wokolicy_cookie="+escape(address)+";expires=" + waznosc.toGMTString();
            document.cookie="wokolicy_wyszukiwarki_"+serwis+"_cookie="+wyszukiwarki_lista+";expires=" + waznosc.toGMTString();
            //var address_new = address;
		    //var pt_new = pt;
            //dodajMarker(address,pt);
            
            var bounds = map.getBounds();
			northEast = bounds.getNorthEast();
			southWest = bounds.getSouthWest();
		
			adres = address.split(' ').join('_');
			adres = adres.split(',').join('');
			adres = adres.replace(/ó/g, "o");
			adres = adres.replace(/Ó/g, "O");
			adres = adres.replace(/ż/g, "z");
			adres = adres.replace(/Ż/g, "Ż");
			adres = adres.replace(/ź/g, "z");
			adres = adres.replace(/Ź/g, "Ź");
			adres = adres.replace(/ć/g, "c");
			adres = adres.replace(/Ć/g, "C");
			adres = adres.replace(/ń/g, "n");
			adres = adres.replace(/Ń/g, "N");
			adres = adres.replace(/ł/g, "l");
			adres = adres.replace(/Ł/g, "L");
			adres = adres.replace(/ś/g, "s");
			adres = adres.replace(/Ś/g, "S");
			adres = adres.replace(/ą/g, "a");
			adres = adres.replace(/Ą/g, "A");
			adres = adres.replace(/ę/g, "e");
			adres = adres.replace(/Ę/g, "E");
			adres = adres.split('/').join('-');

			//window.location.replace(serwis+','+adres+',index.html');
			window.location.href=serwis+','+adres+',okolica.html'

            
          }
        }
      );
    }
    else
    {
		 $('#status2').css('color', '#CC5049');
        document.getElementById('status2').innerHTML='Musisz wybrać jakąś wyszukiwarkę!';
	}
    }  
    
    
 function findAddress12(address) {
   
    var jest = 1;
    var wyszukiwarki_lista = '';
    
    
    /* geocoder.getLatLng(
      address, function(point) {
        if (!point) {
          alert(address + " not found");
        } else {
        alert(point);
         map.setCenter(point, 15);
        var marker = new GMarker(point);
          map.addOverlay(marker);
       }
     }
   );*/
 
    
    
   
    if(jest == 1 || domena == 1)
    {
    
      geocoder.getLatLng( address, function(pt) {
         
			//map.removeOverlay(tmp);
			markery = [];
	
          if (!pt) {
            $('#status').css('color', '#CC5049');
            document.getElementById('status').innerHTML='Adres "'+address+'" nie został znaleziony!';
          } else {
            map.setCenter(pt, 16);
            $('#status').css('color', '#32A55E');
            document.getElementById('status').innerHTML='';
            $('#miejsce').html('Twój wybrany adres to: <b>'+address+'</b>');
            
            var waznosc=new Date(); //tworzymy nowy obiekt zawierający datę
			waznosc.setTime(waznosc.getTime()+1000*60*60*24*366); //ustawianie daty wygaśnięcia (na 7 dni)
		//alert(escape(address));
            document.cookie="wokolicy_cookie="+escape(address)+";expires=" + waznosc.toGMTString();
            document.cookie="wokolicy_wyszukiwarki_"+serwis+"_cookie="+wyszukiwarki_lista+";expires=" + waznosc.toGMTString();
            //var address_new = address;
		    //var pt_new = pt;
            //dodajMarker(address,pt);
            
            var bounds = map.getBounds();
			northEast = bounds.getNorthEast();
			southWest = bounds.getSouthWest();
		
			adres = address.split(' ').join('_');
			adres = adres.split(',').join('');
			adres = adres.replace(/ó/g, "o");
			adres = adres.replace(/Ó/g, "O");
			adres = adres.replace(/ż/g, "z");
			adres = adres.replace(/Ż/g, "Ż");
			adres = adres.replace(/ź/g, "z");
			adres = adres.replace(/Ź/g, "Ź");
			adres = adres.replace(/ć/g, "c");
			adres = adres.replace(/Ć/g, "C");
			adres = adres.replace(/ń/g, "n");
			adres = adres.replace(/Ń/g, "N");
			adres = adres.replace(/ł/g, "l");
			adres = adres.replace(/Ł/g, "L");
			adres = adres.replace(/ś/g, "s");
			adres = adres.replace(/Ś/g, "S");
			adres = adres.replace(/ą/g, "a");
			adres = adres.replace(/Ą/g, "A");
			adres = adres.replace(/ę/g, "e");
			adres = adres.replace(/Ę/g, "E");
			adres = adres.split('/').join('-');

			//window.location.replace(serwis+','+adres+',index.html');
			window.location.href=serwis+','+adres+',okolica.html'

            
          }
        }
      );
    }
    else
    {
		 $('#status2').css('color', '#CC5049');
        document.getElementById('status2').innerHTML='Musisz wybrać jakąś wyszukiwarkę!';
	}
    }  

function zmien_adres()
{
	$('#background').show();
	$('#area_text').show();
}


function hide_zmien_adres()
{
	$('#background').hide();
	$('#area_text').hide();
}

function zapisz_wyszukiwarki()
{
	var wyszukiwarki_lista_new;
	var jest_new = '';
	for(i=0;i<=ilosc_wysz;i++)
    {
    		
			if($('#wyszukiwarka_'+i).attr('checked'))
			{
				wyszukiwarki_lista_new += i+',';
				jest_new = 1;
			}
	
		
	}
	
	
	var waznosc=new Date(); //tworzymy nowy obiekt zawierający datę
	waznosc.setTime(waznosc.getTime()+1000*60*60*24*366); //ustawianie daty wygaśnięcia (na 7 dni)
		
	document.cookie="wokolicy_cookie_"+serwis+"_lista_wyszukiwarki_status="+jest_new+";expires=" + waznosc.toGMTString();
	document.cookie="wokolicy_cookie_"+serwis+"_lista_wyszukiwarki="+wyszukiwarki_lista_new+";expires=" + waznosc.toGMTString();
	

}

function wczytaj_wyszukiwarki()
{
	var status = getCookie("wokolicy_cookie_"+serwis+"_lista_wyszukiwarki_status");
	var wysz;
	var tab = [];
	if(status == 1)
	{
		
		wysz = getCookie("wokolicy_cookie_"+serwis+"_lista_wyszukiwarki");
	
		tab = wysz.split(",");
		//alert(tab);
		
		for(i=0;i<=ilosc_wysz;i++)
    	{
    		
			$('#wyszukiwarka_'+i).attr('checked', false);
			
	
		
		}
		
		for(i=0;i<(tab.length-1);i++)
		{
			tab[i] = tab[i].charAt(tab[i].length-1);
			$('#wyszukiwarka_'+tab[i]).attr('checked', true);
			//alert(parseInt(tab[i]));
		}
		
	}

}

function utworz_cookie()
{
	var waznosc=new Date(); //tworzymy nowy obiekt zawierający datę
	waznosc.setTime(waznosc.getTime()+1000*60*60*24*366); //ustawianie daty wygaśnięcia (na 7 dni)
		
	document.cookie="wokolicy_cookie_"+serwis+"_waznosc=1;expires=" + waznosc.toGMTString();
}
    
    
     function findAddress2(address) {
    
      geocoder.getLatLng(
        address,
        
        function(pt) {
		//	map.removeOverlay(tmp);
			markery = [];
	
          
          	
          	var textCookie=getCookie("wokolicy_cookie_"+serwis+"_zoom_tmp");
          
          	if(textCookie == undefined || textCookie == '0' || textCookie == 0)
          	{
				
            	map.setCenter(pt, 16);
         	} 
			else  
			{
          
				var lat_tmp=getCookie("wokolicy_cookie_"+serwis+"_lat_tmp");
				var lng_tmp=getCookie("wokolicy_cookie_"+serwis+"_lng_tmp");
				var newGLatLngO = new GLatLng(lat_tmp, lng_tmp);
				var waznosc=new Date(); //tworzymy nowy obiekt zawierający datę
				waznosc.setTime(waznosc.getTime()+1000*60*60*24*366); //ustawianie daty wygaśnięcia (na 7 dni)
		
				map.setCenter(newGLatLngO , textCookie);  
				document.cookie="wokolicy_cookie_"+serwis+"_zoom_tmp=0;expires=" + waznosc.toGMTString();
				document.cookie="wokolicy_cookie_"+serwis+"_lat_tmp=0;expires=" + waznosc.toGMTString();
				document.cookie="wokolicy_cookie_"+serwis+"_lng_tmp=0;expires=" + waznosc.toGMTString();
			}
			
			
			
			//if(brak_adresu != 1)
			//{
		    	$('#miejsce').html('Twój wybrany adres to: <b>'+address+'</b>');
		    //}
		    address_new = address;
		    pt_new = pt;
            //dodajMarker(address,pt);
           
            var bounds = map.getBounds();
			northEast = bounds.getNorthEast();
			southWest = bounds.getSouthWest();
            getLocation2();
          
        }
      );
    }  
	
	
	function fade_out()
{
	clearTimeout(time);
	$('#box').fadeOut(1000);
}  
	
	   function dodajMarker(nazwa,wspolrzedne)  
   {  
     
     	ikona_url = 'templates/images/ludek.png';
	
	var tinyIcon = new GIcon();
tinyIcon.image = ikona_url;
tinyIcon.shadow = "";
tinyIcon.iconSize = new GSize(32, 32);
tinyIcon.shadowSize = new GSize(0, 0);
tinyIcon.iconAnchor = new GPoint(16, 16);
tinyIcon.infoWindowAnchor = new GPoint(16, 16);
var kolejnosc = 1000;
// Set up our GMarkerOptions object literal
markerOptions = { icon:tinyIcon, title: nazwa};//, zIndexProcess: kolejnosc};

	//var marker = new GMarker(punkt, markerOptions);// {icon: ikona,title: tytul});
     
     
     
       var marker = new GMarker(wspolrzedne,markerOptions);  
       marker.txt = '<div style="text-align:center;">Twój wybrany adres:<br /><span style="color:#FF9700">'+nazwa+'</span></div>';  
       
     // dodanie nasłuchu na kliknięcie, by otworzyć okienko informacyjne  
       GEvent.addListener(marker,'click',function()  
       {  
          marker.openInfoWindowHtml(marker.txt);  
       });  
        
       // dodanie markera na mapę  
       tmp = marker;
       map.addOverlay(marker);  
       
   }  

	function Checkboxes(owu,b){
	for(var o, t, i = 0, ch = document.getElementsByTagName('input'); t = ch[i++];){
		if(/^checkbox$/i.test(t.type)){
			o = document.createElement('img')
			o.src=t.checked?a:b
			o.ref=t
			t.className='none'
			o.onclick=function(){
				with(this){
					ref.checked=!ref.checked
					src=ref.checked?owu:b
				}
			}
			t.parentNode.insertBefore(o,t)
		}
	}
}

var markery = [];
var kategorie = [];

function dodajMarker2(lat,lon,opis,tytul,kategoria,ikona_url, obrazek_maly, id, id_wpisu, poz)
{
	

	
	if(ikona_url == 'http://maps.google.com/mapfiles/kml/pal3/icon56.png' || ikona_url == 'http://studentnews.pl/maps_project/templates/images/6.png')
	{
	
	}
	else
	{
		ikona_url = '../'+ikona_url;	
	}
	var punkt = new GLatLng(lat,lon);

	
	//alert(ikona_url);
	var tinyIcon = new GIcon();
tinyIcon.image = ikona_url;
tinyIcon.shadow = "";
tinyIcon.iconSize = new GSize(32, 32);
tinyIcon.shadowSize = new GSize(0, 0);
tinyIcon.iconAnchor = new GPoint(16, 16);
tinyIcon.infoWindowAnchor = new GPoint(16, 16);
pozycja = poz;
// Set up our GMarkerOptions object literal
markerOptions = { icon:tinyIcon, title: tytul};
	//alert(punkt+" - "+markerOptions);
	//alert(punkt);
	var marker = new GMarker(punkt, markerOptions);// {icon: ikona,title: tytul});
	//alert(marker);
	//alert(kategoria);
	// przypisujemy markerowi ID kategorii
	var dane_wysz= [];
	dane_wysz = kategoria.split("_");
	//alert(dane_wysz);
	marker.kategoria = kategoria;
	marker.tytul = tytul;
	marker.opis = opis;
	marker.obrazek_maly = obrazek_maly;
	marker.id_wp = id_wpisu;
	marker.poz = poz;
	marker.s = aktualne_wyszukiwarki[dane_wysz[1]];
	marker.id_wysz = aktualne_klucze[dane_wysz[1]];
	markery.push(marker);
	
	map.addOverlay(marker);
	
	if(kategorie[kategoria]!=1)
	{
		kategorie[kategoria]=1;
	}
	
		GEvent.addListener(marker,'click',function()
			{
						//alert(markery[i].tytul)
					  marker.openInfoWindowHtml("<div style='text-align:center;vertical-align:middle;float:left;'>"+marker.obrazek_maly+"</div><div style='float:left'><div style='padding-left:4px;font-weight:bold;font-size:10px;font-family: Tahoma;width:250px;'><a onClick='zapisz_pozycje();' href='"+marker.id_wysz+","+marker.s+","+marker.id_wp+",wiadomosc,"+serwis+",okolica.html'>"+html_entity_decode(marker.tytul)+"</a></div>"+'<div style="padding-left:4px;font-weight:normal;font-size:10px;font-family: Tahoma;width:250px;height:50px; overflow:auto;">'+html_entity_decode(marker.opis)+'</div></div><div style="clear:both;width:360px;text-align:right;margin-top:10px;font-family: Tahoma;padding-top:5px;color:#750707;font-weight:bold;font-size:10px;border-top:1px solid #750707;"></div>');

		
			});


	
}

var tablica_p = []; 
function dodaj()
{
		currentdata = [];
				currentdata = preperedata();
				//alert(currentdata);
			//	alert(currentdata.length);
			
				//alert(data);
				// ------
				
							boxy = [];
                  			url = [];
                  			image = [];
                  			tabliczka = [];
                  			tabliczka33 = [];
    		  				
	    					k = 0;
	    					ilosc_wpisow = [];
	    					//alert(currentdata.length);
	    					for (var i = 0; i < currentdata.length; i++)    
   	                		{
   	                		
   	             				//alert(ilosc_wpisow[currentdata[i][3]]);
			
								if(currentdata[i][0])
								{//alert(currentdata[i][9]);
									if(currentdata[i][7] == 4)
				                    {
					      				tmp4 = '';
					    			}	
									else
									{
					    				tmp4 = currentdata[i][7];
					  				}
									if(currentdata[i][6] && currentdata[i][8])
									{
										if(currentdata[i][7] == 5)
										{
											img="<img style='border:none;width:100px;' src='../../../img/wo/obrazek_maly_"+currentdata[i][9]+"."+currentdata[i][8]+"' />"
										}
										else if(currentdata[i][7] == 6)
										{
												img="<img style='border:none;width:100px;' src='../../../img/uczelnie/obrazek_maly_"+currentdata[i][9]+"."+currentdata[i][8]+"' />"
									
										}
										else
										{
											img="<img style='border:none;width:100px;' src='../../../img/exp_wo"+tmp4+"/obrazek_maly_"+currentdata[i][9]+"."+currentdata[i][8]+"' />"
										}
									}
									else
									{
										img = '';
									}
									if(parseFloat(currentdata[i][1]))
									{
									
										//if(tabliczka33[currentdata[i][9]] !=1)
										//	{
									//alert('wysz_'+currentdata[i][3]);
										dodajMarker2(parseFloat(currentdata[i][1]),parseFloat(currentdata[i][0]),currentdata[i][10], currentdata[i][2], 'wysz_'+currentdata[i][3], currentdata[i][4], img, i ,currentdata[i][9], currentdata[i][6]);
										
										if(ilosc_wpisow[currentdata[i][3]])
										{
										//alert("jest");
											ilosc_wpisow[currentdata[i][3]]++;
										}
									//else if(ilosc_wpisow[currentdata[i][3]] == undefined)
									//{
										//alert("undef");
									//	ilosc_wpisow[currentdata[i][3]]=2;
									//}
										else
										{
										//alert('nie ma');
											ilosc_wpisow[currentdata[i][3]]=1;	
										}
										
										//tabliczka33[currentdata[i][9]] = 1;
										//}
									}
									
									//alert(currentdata[i][6]+" - "+currentdata[i][2]+" - "+currentdata[i][5]+" - "+currentdata[i][8]+" - "+currentdata[i][7] );
									
									if(currentdata[i][6] > 0 )
									{
										//alert(currentdata[i][6]);
											if(tabliczka[currentdata[i][9]] !=1)
											{
						  							if(currentdata[i][7] == 4)
				                    				{
					      							tmp4 = '';
					    							}	
													else
													{
					    							tmp4 = currentdata[i][7];
					  								}
									  
													  if(currentdata[i][7] == 5)
									  				  {
														image[k]="<img style='border:none;width:100px;' src='../../../img/wo/obrazek_maly_"+currentdata[i][9]+"."+currentdata[i][8]+"' />";
		    					
									  				  }
									  				  else if(currentdata[i][7] == 6)
													{
														image[k]="<img style='border:none;width:100px;' src='../../../img/uczelnie/obrazek_maly_"+currentdata[i][9]+"."+currentdata[i][8]+"' />"
									
													}
									  					else
									  					{
									  					image[k]="<img style='border:none;width:100px;' src='../../../img/exp_wo"+tmp4+"/obrazek_maly_"+currentdata[i][9]+"."+currentdata[i][8]+"' />";
		    								//alert(image[k]);
									  					}	  
								//alert(image[k]);
						    		tabliczka[currentdata[i][9]] = 1;
									tablica_p[k] = currentdata[i][9];
									boxy[k]=currentdata[i][2];
		    						url[k]=currentdata[i][5];
		    						k++;
		    								}
		  							}
					
								}
				
			
							
   
                         	}
                         	
                         
                         	
                         	var boxy_tekst = '';
                         	var tab_image = '';
                         	var tab_wpisy = '';
                        	wpisy();
						 	resizeWindow();	
						 	//alert(address_new+'_'+pt_new)
						 	
				
	
}




function resizeWindow()
{
	var width;
	if(navigator.appName == "Netscape")
	{
		 width = window.innerWidth;
	}
	else if(navigator.appName == "Opera")
	{
 		 width = window.innerWidth;
	}
	else if(navigator.appName == "Microsoft Internet Explorer")
	{
 		 width = document.body.offsetWidth;
	}
	
	
	var tmpwidth = width-365;
	ttwidth = Math.floor(width/120);	
	var ilosc_wierszy =ttwidth;
	var wpisy = '';
                         	var tab_image = '';
                         	var tab_wpisy = '';

								tab_image = '';
      	        				tab_wpisy = '';
											p=1;
											k=0;
											var tab_tmp_boxy = [];
											var tab_tmp_image = [];
											var tab_tmp_url = [];
											var tab_tmp_p = [];
											var x=0;
											for(j=0; j<boxy.length; j++)
											{
												wartosc = Math.floor(Math.random() * boxy.length) + 1;
                           						wartosc = j;
                           						//alert(image[wartosc]+" - "+boxy[wartosc]);
												if(boxy[wartosc] != undefined && image[wartosc] != undefined )
												{
      												tab_tmp_boxy[x] = boxy[j];
      												tab_tmp_image[x] = image[j];
      												tab_tmp_url[x] = url[j];
      												tab_tmp_p[x] = tablica_p[j];
      												x++;
									 	 		}  
											
											}
										
											for(y=1;y<=ilosc_wierszy;y++)
											{
										
											for(j=(y-1)*ttwidth;j<y*ttwidth;j++)
											{
											
												wartosc = Math.floor(Math.random() * boxy.length) + 1;
                           						wartosc = j;
                           						
												   if(tab_tmp_image[wartosc] == undefined)
												   {
												   		tab_tmp_image[wartosc] = '';
												   		tab_tmp_boxy[wartosc] = '';
												   		tab_tmp_url[wartosc] = '';
												   		tab_tmp_p[wartosc] = '';
												   }
												   	tab_image += '<td style="width:106px;padding-left:14px;"><a href="http://studentnews.pl/st_new.php?typ=wokolicy&id1='+tab_tmp_p[wartosc]+'&p=1&u='+tab_tmp_url[wartosc]+'" target="_blank">'+tab_tmp_image[wartosc]+'</a></td>';
      	        									tab_wpisy += '<td style="width:106px;padding-left:14px;">'+"<a id='link_boxy' style='font-family:Tahoma;font-size:10px;text-decoration:none;' target='_blank' href='http://studentnews.pl/st_new.php?typ=wokolicy&id1="+tablica_p[wartosc]+"&p=1&u="+tab_tmp_url[wartosc]+"'>"+tab_tmp_boxy[wartosc]+'</a></td>'
				  											
											}
											wpisy += '<table style="text-align:center;font-size:11px;clear:both;"><tr >'+tab_image+'</tr><tr <tr style="vertical-align:top">'+tab_wpisy+'</tr></table>';
												tab_image = '';
														tab_wpisy = '';	
								
										}

			 				//if(tab_image != undefined)
			 				//{
			 						$('#box').html(wpisy);
							//}
							
}



function schowaj()
{

	if($('#dane_wpisy').css('opacity') == 0)
	{
		
		$('#dane_wpisy').animate(
		{ 
        width: "300px",
        opacity: '0.9'
      	}, 1500 );	
      	
      	$('#button').animate(
		{ 
        right: '306px'
    	
      	}, 1500 );
      	
      	$('#button').html("<img onClick='schowaj()' src='templates/images/zwiniete.png'/>");
      	
	}
	else
	{
		
		$('#dane_wpisy').animate(
		{ 
        width: "0px",
    	opacity: '0.0'
    	
      	}, 1500 );
      	
      	$('#button').animate(
		{ 
        right: '0px'
    	
      	}, 1500 );
      	
      	$('#button').html("<img onClick='schowaj()' src='templates/images/rozwiniete3.png'/>");

	}
}

function otworzMarker(id)  
{  
        if(markery.length-1<id)  
            return;  
        //markery[id].openInfoWindowHtml(+);  
        //	markery[id].openInfoWindowHtml("<div style='text-align:center;vertical-align:middle;float:left;'>"+markery[id].obrazek_maly+"</div><div style='padding-left:4px;font-weight:bold;font-size:10px;font-family: Verdana;width:400px;float:left;'>"+markery[id].tytul+"</div>"+'<div style="clear:both;padding-left:4px;font-weight:normal;font-size:10px;font-family: Verdana;width:400px;float:left;height:100px; overflow:auto;">'+html_entity_decode(markery[id].opis)+'</div><div style="clear:both;width:510px;text-align:right;margin-top:10px;font-family: Verdana;padding-top:5px;color:#750707;font-weight:bold;font-size:10px;border-top:1px solid #750707;"><form action="#" onSubmit="return trasa(this);return false;" class="mapa_form_gtrasa">Pokaż dojazd z <input type="hidden" name="marker" id="marker_id" value="'+id+'"><input type="text" style="border:1px solid #750707;font-size:12px;background-color:white; color:#750707;" id="marker_text" name="t" size="20"> <input style="font-size:12px;border:1px solid #750707;background-color:white; color:#750707;" type="submit" value="Pokaż"></form></div>');
	
        markery[id].openInfoWindowHtml("<div style='text-align:center;vertical-align:middle;float:left;'>"+markery[id].obrazek_maly+"</div><div style='float:left'><div style='padding-left:4px;font-weight:bold;font-size:10px;font-family: Tahoma;width:250px;'><a onClick='zapisz_pozycje();' href='"+markery[id].id_wysz+","+markery[id].s+","+markery[id].id_wp+",wiadomosc,"+serwis+",okolica.html'>"+html_entity_decode(markery[id].tytul)+"</a></div>"+'<div style="padding-left:4px;font-weight:normal;font-size:10px;font-family: Tahoma;width:250px;height:50px; overflow:auto;">'+html_entity_decode(markery[id].opis)+'</div></div><div style="clear:both;width:360px;text-align:right;margin-top:10px;font-family: Tahoma;padding-top:5px;color:#750707;font-weight:bold;font-size:10px;border-top:1px solid #750707;"></div>');

} 

function ukryjPokazKategorie(kategoria,pokaz, checkbox)
{
	for(var i=0; i<markery.length; i++)
	{
		if(markery[i].kategoria==kategoria)
		{
		  
			if(pokaz==true)
				markery[i].show();
			else
				markery[i].hide();
		}
	}
}

function zapisz_pozycje()
{
	 var bounds = map.getBounds();
			center_tmp = bounds.getCenter();
			zoom_tmp = map.getBoundsZoomLevel(bounds);
			var lat_tmp = center_tmp.lat();
			var lng_tmp = center_tmp.lng();
			
			
			var waznosc=new Date(); 
			waznosc.setTime(waznosc.getTime()+1000*60*60*24*366); //ustawianie daty wygaśnięcia (na 7 dni)
	
            document.cookie="wokolicy_cookie_"+serwis+"_lat_tmp="+lat_tmp+";expires=" + waznosc.toGMTString();
            document.cookie="wokolicy_cookie_"+serwis+"_lng_tmp="+lng_tmp+";expires=" + waznosc.toGMTString();
			document.cookie="wokolicy_cookie_"+serwis+"_zoom_tmp="+zoom_tmp+";expires=" + waznosc.toGMTString();
			
			
		
			
			
			

}


function getCookie(Name)
  {
  var search = Name + "=";

  // jeżeli są jakiekolwiek ciasteczka
  if (document.cookie.length > 0)
    {
    // określenie początku ciasteczka o zadanej nazwie
    offset = document.cookie.indexOf(search);

    // jeżeli ciasteczko istnieje
    if (offset != -1)
      {
      //określenie początku wartości ciasteczka
      offset += search.length;

      //określenie końca ciasteczka
      end = document.cookie.indexOf(";", offset)
      if (end == -1) end = document.cookie.length

        //zwrócenie wartości ciasteczka
        return unescape(document.cookie.substring(offset, end))
      }
    }
  }



function wpisy()
{

var html = '<ol style="list-style-image:url(templates/images/right4.gif)">';
var html2 = '';
var liczba_wpisow_kat = 0;
var liczba_tablica = [];
for(i=0;i<ilosc_wysz;i++)
{
	liczba_wpisow_kat = 0;

	for(k=0; k<markery.length; k++)   
    {   
       											
        if(markery[k].kategoria == "wysz_"+i+"_"+aktualne_wyszukiwarki[i])
       	{											
            								 
        	liczba_wpisow_kat++;
		} 
   			 									
			 
	}
	
	
	if(aktualne_nazwy[i] != undefined)
	{
		if(liczba_wpisow_kat > 0){
			html+= '<h4 style="font-size:12px;color:#D55B01;">'+aktualne_nazwy[i]+' ('+liczba_wpisow_kat+')</h4>';
		}else{
			html2+= '<h4 style="font-size:12px;color:#D55B01;">'+aktualne_nazwy[i]+' ('+liczba_wpisow_kat+')</h4>';	
		}
	}
	
	if(liczba_wpisow_kat > 0){
	for(k=0; k<markery.length; k++)   
    {   
       											
        if(markery[k].kategoria == "wysz_"+i+"_"+aktualne_wyszukiwarki[i])
       	{											
            									
			if(markery[k].poz > 0)
        	{
        		html+='<li style="list-style-image:url(templates/images/gwiazdka.png)"><a href="#" onclick="otworzMarker('+k+'); return false;"><strong>'+html_entity_decode(markery[k].tytul)+'</strong></a></li>'; 
			}
			else
			{
        		html+='<li><a href="#" onclick="otworzMarker('+k+'); return false;">'+html_entity_decode(markery[k].tytul)+'</a></li>';   
    		}  
        	liczba_wpisow_kat++;
		} 
   			 									
			 
	}
	}
}

											html += html2;
	      									html += '</ol><br /><br />';
											  //alert(html);
											  $('#dane_wpisy').html(html); 
}

function getLocation2()
{

 
  
      //aktualne_wyszukiwarki[0]=144;
      //aktualne_wyszukiwarki[1]=5;
      //aktualne_klucze[0] = 4;
      //aktualne_klucze[1] = 2;

var ilimit = 100000000000;
var zoom2 = 16;
//alert(northEast);
  
  if(tmpArray2)
  {
  
  }
  else
  {
  	tmpArray2 = 0;
  }
  //alert(tmpArray2);
  //alert(aktualne_wyszukiwarki); 
//	alert(aktualne_klucze);

  $('#tlo').css('display', "block");
   $.ajax({
   type: "POST", 
   url: "../ajaxindex.php?action=setLong&Cid=0",
   data: "AktWysz="+aktualne_wyszukiwarki+"&AktKey="+aktualne_klucze+"&southWest="+southWest+"&northEast="+northEast+"&cechy="+tmpArray2+"&limit="+ilimit+'&zoom='+zoom2,
   success: function(data){
			//alert(data);
			
			
			
			var tmpsplit = new Array();
			var splitted1 = new Array();
			datatable = new Array();
			tmpsplit = data.split('*');
	
		
			datatable = tmpsplit[1];
		
			splitted = new Array;
		
				splitted = tmpsplit[0].split(':');
	
				splitted3 = tmpsplit[2].split(":");
			
    		dodaj();
    		dodajMarker(address_new,pt_new);
    	
   }
 });


  
  
}


var center;
var zoom3;
function getLocation3()
{

var bounds = map.getBounds();
northEast = bounds.getNorthEast();
southWest = bounds.getSouthWest();
zoom3 = map.getBoundsZoomLevel(bounds);
center = bounds.getCenter();

var ilimit = 100000000000;
var zoom2 = 16;
//alert(northEast);
  
  if(tmpArray2)
  {
  
  }
  else
  {
  	tmpArray2 = 0;
  }

  $('#tlo').css('display', "block");
   $.ajax({
   type: "POST", 
   url: "../ajaxindex.php?action=setLong&Cid=0",
   data: "AktWysz="+aktualne_wyszukiwarki+"&AktKey="+aktualne_klucze+"&southWest="+southWest+"&northEast="+northEast+"&cechy="+tmpArray2+"&limit="+ilimit+'&zoom='+zoom2,
   success: function(data){
			//alert(data);
			
			
			
			var tmpsplit = new Array();
			var splitted1 = new Array();
			datatable = new Array();
			tmpsplit = data.split('*');
	
		
			datatable = tmpsplit[1];
		
			splitted = new Array;
		
			splitted = tmpsplit[0].split(':');
	
			splitted3 = tmpsplit[2].split(":");
    		load2();
			dodaj();
			dodajMarker(address_new,pt_new);
			
    	
   }
 });  
}

function load2() {
	$('#info').hide();
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
     
        map.setCenter(center, zoom3);
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());      
        map.addControl(new GScaleControl()); 
		GEvent.addListener(map, "moveend", moveendAction);     
        
      }
    }


function get_html_translation_table(table, quote_style) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: noname
    // %          note: It has been decided that we're not going to add global
    // %          note: dependencies to php.js. Meaning the constants are not
    // %          note: real constants, but strings instead. integers are also supported if someone
    // %          note: chooses to create the constants themselves.
    // %          note: Table from http://www.the-art-of-web.com/html/character-codes/
    // *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
    // *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
    
    var entities = {}, histogram = {}, decimal = 0, symbol = '';
    var constMappingTable = {}, constMappingQuoteStyle = {};
    var useTable = {}, useQuoteStyle = {};
    
    useTable      = (table ? table.toUpperCase() : 'HTML_SPECIALCHARS');
    useQuoteStyle = (quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT');
    
    // Translate arguments
    constMappingTable[0]      = 'HTML_SPECIALCHARS';
    constMappingTable[1]      = 'HTML_ENTITIES';
    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
    constMappingQuoteStyle[2] = 'ENT_COMPAT';
    constMappingQuoteStyle[3] = 'ENT_QUOTES';
    
    // Map numbers to strings for compatibilty with PHP constants
    if (!isNaN(useTable)) {
        useTable = constMappingTable[useTable];
    }
    if (!isNaN(useQuoteStyle)) {
        useQuoteStyle = constMappingQuoteStyle[useQuoteStyle];
    }
    
    if (useTable == 'HTML_SPECIALCHARS') {
        // ascii decimals for better compatibility
        entities['38'] = '&amp;';
        entities['60'] = '&lt;';
        entities['62'] = '&gt;';
    } else if (useTable == 'HTML_ENTITIES') {
        // ascii decimals for better compatibility
      entities['38'] = '&amp;';
      entities['60'] = '&lt;';
      entities['62'] = '&gt;';
      entities['160'] = '&nbsp;';
      entities['161'] = '&iexcl;';
      entities['162'] = '&cent;';
      entities['163'] = '&pound;';
      entities['164'] = '&curren;';
      entities['165'] = '&yen;';
      entities['166'] = '&brvbar;';
      entities['167'] = '&sect;';
      entities['168'] = '&uml;';
      entities['169'] = '&copy;';
      entities['170'] = '&ordf;';
      entities['171'] = '&laquo;';
      entities['172'] = '&not;';
      entities['173'] = '&shy;';
      entities['174'] = '&reg;';
      entities['175'] = '&macr;';
      entities['176'] = '&deg;';
      entities['177'] = '&plusmn;';
      entities['178'] = '&sup2;';
      entities['179'] = '&sup3;';
      entities['180'] = '&acute;';
      entities['181'] = '&micro;';
      entities['182'] = '&para;';
      entities['183'] = '&middot;';
      entities['184'] = '&cedil;';
      entities['185'] = '&sup1;';
      entities['186'] = '&ordm;';
      entities['187'] = '&raquo;';
      entities['188'] = '&frac14;';
      entities['189'] = '&frac12;';
      entities['190'] = '&frac34;';
      entities['191'] = '&iquest;';
      entities['192'] = '&Agrave;';
      entities['193'] = '&Aacute;';
      entities['194'] = '&Acirc;';
      entities['195'] = '&Atilde;';
      entities['196'] = '&Auml;';
      entities['197'] = '&Aring;';
      entities['198'] = '&AElig;';
      entities['199'] = '&Ccedil;';
      entities['200'] = '&Egrave;';
      entities['201'] = '&Eacute;';
      entities['202'] = '&Ecirc;';
      entities['203'] = '&Euml;';
      entities['204'] = '&Igrave;';
      entities['205'] = '&Iacute;';
      entities['206'] = '&Icirc;';
      entities['207'] = '&Iuml;';
      entities['208'] = '&ETH;';
      entities['209'] = '&Ntilde;';
      entities['210'] = '&Ograve;';
      entities['211'] = '&Oacute;';
      entities['212'] = '&Ocirc;';
      entities['213'] = '&Otilde;';
      entities['214'] = '&Ouml;';
      entities['215'] = '&times;';
      entities['216'] = '&Oslash;';
      entities['217'] = '&Ugrave;';
      entities['218'] = '&Uacute;';
      entities['219'] = '&Ucirc;';
      entities['220'] = '&Uuml;';
      entities['221'] = '&Yacute;';
      entities['222'] = '&THORN;';
      entities['223'] = '&szlig;';
      entities['224'] = '&agrave;';
      entities['225'] = '&aacute;';
      entities['226'] = '&acirc;';
      entities['227'] = '&atilde;';
      entities['228'] = '&auml;';
      entities['229'] = '&aring;';
      entities['230'] = '&aelig;';
      entities['231'] = '&ccedil;';
      entities['232'] = '&egrave;';
      entities['233'] = '&eacute;';
      entities['234'] = '&ecirc;';
      entities['235'] = '&euml;';
      entities['236'] = '&igrave;';
      entities['237'] = '&iacute;';
      entities['238'] = '&icirc;';
      entities['239'] = '&iuml;';
      entities['240'] = '&eth;';
      entities['241'] = '&ntilde;';
      entities['242'] = '&ograve;';
      entities['243'] = '&oacute;';
      entities['244'] = '&ocirc;';
      entities['245'] = '&otilde;';
      entities['246'] = '&ouml;';
      entities['247'] = '&divide;';
      entities['248'] = '&oslash;';
      entities['249'] = '&ugrave;';
      entities['250'] = '&uacute;';
      entities['251'] = '&ucirc;';
      entities['252'] = '&uuml;';
      entities['253'] = '&yacute;';
      entities['254'] = '&thorn;';
      entities['255'] = '&yuml;';
    } else {
        throw Error("Table: "+useTable+' not supported');
        return false;
    }
    
    if (useQuoteStyle != 'ENT_NOQUOTES') {
        entities['34'] = '&quot;';
    }
    
    if (useQuoteStyle == 'ENT_QUOTES') {
        entities['39'] = '&#039;';
    }
    
    // ascii decimals to real symbols
    for (decimal in entities) {
        symbol = String.fromCharCode(decimal)
        histogram[symbol] = entities[decimal];
    }
    
    return histogram;
}

function html_entity_decode( string, quote_style ) {
    // http://kevin.vanzonneveld.net
    // +   original by: john (http://www.jd-tech.net)
    // +      input by: ger
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +   improved by: marc andreu
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: get_html_translation_table
    // *     example 1: html_entity_decode('Kevin &amp; van Zonneveld');
    // *     returns 1: 'Kevin & van Zonneveld'
 
    var histogram = {}, symbol = '', tmp_str = '', i = 0;
    tmp_str = string.toString();
    
    if (false === (histogram = get_html_translation_table('HTML_ENTITIES', quote_style))) {
        return false;
    }
    
    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(entity).join(symbol);
    }
    
    return tmp_str;
}
