var gdir, obszar, showimage;
var maxZoom = 15;
function setshowimage(val) {
	showimage = val;
}

function showPrefferedHours(obj) {
	if(obj.checked) {
		$$('.open_nh').each(function(d){ d.style.display = 'none'; });
		$$('.open_sh').each(function(d){ d.style.display = ''; });
		$$('.cloudPreffHours').each(function(d){ d.style.display = ''; });
		createCookie('setChecked', 1, 1);
	}
	else {
		$$('.open_nh').each(function(d){ d.style.display = ''; });
		$$('.open_sh').each(function(d){ d.style.display = 'none'; });
		$$('.cloudPreffHours').each(function(d){ d.style.display = 'none'; });
		createCookie('setChecked', 0, 1);
	}
}

function createTable() {
	var div = document.createElement('div');
	var p = document.createElement('p');
	var tbody = document.createElement('tbody');
	var tr = document.createElement('tr');
	var td = document.createElement('td');
	
	p.className = 'prefferedHours';
	
	var type=$('s_type').options[$('s_type').selectedIndex].value;
	
	if(((document.myform.group[1].checked==true && (type==1||type==2||type==10)) || document.myform.group[0].checked==true) && show_recommended_hours==1){
		if(readCookie('setChecked')==1) p.innerHTML = '<input type="checkbox" onclick="showPrefferedHours(this)" checked id="showPrefferedHours" name="showPrefferedHours" value="1" /><label for="showPrefferedHours"><span>Zobacz polecane godziny</span> - to godziny, w których zostaniesz obsłużony najszybciej w wybranym oddziale bankowym</label>';
			else p.innerHTML = '<input type="checkbox" onclick="showPrefferedHours(this)" id="showPrefferedHours" name="showPrefferedHours" value="1" /><label for="showPrefferedHours"><span>Zobacz polecane godziny</span> - to godziny, w których zostaniesz obsłużony najszybciej w wybranym oddziale bankowym</label>';
	}
	div.appendChild(p);
	td.setAttribute('colspan', 5);
	td.setAttribute('style', 'border-bottom: 1px solid #fff');
	td.appendChild(div);
	tr.appendChild(td);
	tbody.appendChild(tr);
	tr = document.createElement('tr');
	td = document.createElement('td');
	td.setAttribute('rowSpan', 2);
	td.setAttribute('align', 'center');
	td.setAttribute('width', '125px');
	td.className = 'tablehead';
	td.innerHTML = 'Typ obiektu';
	tr.appendChild(td);
	td = document.createElement('td');
	td.setAttribute('rowSpan', 2);
	td.setAttribute('align', 'center');
	td.className = 'tablehead';
	td.innerHTML = 'Adres';
	tr.appendChild(td);
	td = document.createElement('td');
	td.setAttribute('align', 'center');
	td.setAttribute('colSpan', 2);
	td.className = 'tablehead';
	td.innerHTML = 'Godziny pracy';
	tr.appendChild(td);
	td = document.createElement('td');
	/*td.setAttribute('rowSpan', 2);
	td.setAttribute('align', 'center');
	td.setAttribute('width', '20%');
	td.className = 'tablehead';
	td.innerHTML = 'Miejsce,<br /> Uwagi';
	tr.appendChild(td);
	if (map != undefined) {
		td = document.createElement('td');
		td.setAttribute('rowSpan', 2);
		td.setAttribute('align', 'center');
		td.setAttribute('width', '7%');
		td.className = 'tablehead';
		td.innerHTML = 'Pokaż na mapie';
		tr.appendChild(td);
	}*/
	
	td = document.createElement('td');
	td.setAttribute('rowSpan', 2);
	td.setAttribute('align', 'center');
	td.setAttribute('style', 'border0; empty-cells: hide;');
	//td.className = '';
	td.innerHTML = '';
	tr.appendChild(td);	
	tbody.appendChild(tr);
	tr = document.createElement('tr');
	td = document.createElement('td');
	td.setAttribute('width', '10%');
	td.setAttribute('align', 'center');
	td.className = 'tablehead';
	td.innerHTML = '<span style="color: #fff !important">pn-pt</span>';
	tr.appendChild(td);
	td = document.createElement('td');
	td.setAttribute('width', '10%');
	td.setAttribute('align', 'center');
	td.className = 'tablehead';
	td.innerHTML = '<span style="color: #fff !important">sob.</span>';
	tr.appendChild(td);
	tbody.appendChild(tr);
	return tbody;
}
function createTableRow(tbody, i, countppage, page_i, allnum) {
	tr = document.createElement('tr');
	tr.onmouseover = function(){ this.setAttribute('class', 'rowhover'); }
	tr.onmouseout = function(){ this.removeAttribute('class'); }
	td = document.createElement('td');
	if (map != undefined) {
		td.onclick = function() {
			window.location = '#';
			myclick(i);
		};
	}
	td.style.cursor = 'pointer';
	
	td.setAttribute('align', 'left');
	var bgcolor = '#f3f3f3';
	if (i % 2 == 1) {
		td.style.backgroundColor = bgcolor;
	}
	actpage= Math.ceil((i+1) / countppage);
	pages = Math.ceil(allnum / countppage);
	if((i%countppage)==(countppage-1)||(allnum%countppage==(page_i+1)&&actpage==pages)) td.className = 'tabledata lastrow';
		else td.className = 'tabledata';
	if(departementList[i]["typ_nazwa"]=='Bankomat bezprowizyjny') td.setAttribute('width', '20%');
	td.innerHTML = departementList[i]["typ_nazwa"]
			+ ((departementList[i]["typ"] == 3) ? ', ' + departementList[i]["cat"]
					: '');
	tr.appendChild(td);
	td = document.createElement('td');
	td.style.cursor = 'pointer';
	if (map != undefined) {
		td.onclick = function() {
			window.location = '#';
			myclick(i);
		};
	}
	td.setAttribute('align', 'left');
	if (i % 2 == 1) {
		td.style.backgroundColor = bgcolor;
	}
	if((i%countppage)==(countppage-1)||(allnum%countppage==(page_i+1)&&actpage==pages)) td.className = 'tabledata lastrow';
		else td.className = 'tabledata';
	td.innerHTML = departementList[i]["adresshort"].replace('<br \/>', '');
	tr.appendChild(td);

	var open_sh_class1='';
	var open_nh_class1='';
	var open_sh_class2='';
	var open_nh_class2='';	

	if(departementList[i]["whpreff"]!='' && departementList[i]["whpreff"]!='zamknięte'){
		open_sh_class1=' open_sh';
		open_nh_class1=' open_nh';
	}
	
	if(departementList[i]["fhpreff"]!='' && departementList[i]["fhpreff"]!='zamknięte'){
		open_sh_class2=' open_sh';
		open_nh_class2=' open_nh';
	}
	
	// godziny od
		td = document.createElement('td');
		if(departementList[i]["wh"]=='inne'){
			td.setAttribute('colSpan', '2');
			td.setAttribute('class', 'tooltipactive');
			td.onmouseover = new Function('tooltip.show("'+departementList[i]["other_hours"]+'");');
			td.onmouseout = new Function("tooltip.hide();");
		}
		if(readCookie('setChecked')==1 && departementList[i]["whpreff"]!='') td.style.display='none';
		td.style.cursor = 'pointer';
		if (map != undefined) {
			td.onclick = function() {
				window.location = '#';
				myclick(i);
			};
		}	
		td.setAttribute('align', 'center');
		if (i % 2 == 1) {
			td.style.backgroundColor = bgcolor;
		}
		if((i%countppage)==(countppage-1)||(allnum%countppage==(page_i+1)&&actpage==pages)) td.className = 'tabledata lastrow'+open_nh_class1;
			else td.className = 'tabledata'+open_nh_class1;
		
		td.innerHTML = departementList[i]["wh"];
			
		tr.appendChild(td);

	//poczatek godziny preferowane od
	td = document.createElement('td');
	if(departementList[i]["whpreff"]=='inne'){
		td.setAttribute('colSpan', '2');
		td.setAttribute('class', 'tooltipactive');
		td.onmouseover = new Function('tooltip.show("Godziny polecane: <br/>'+departementList[i]["other_hours_preff"]+'");');
		td.onmouseout = new Function("tooltip.hide();");
	}
	else{
		if(departementList[i]["whpreff"]!='' && departementList[i]["whpreff"]!='zamknięte'){
			td.onmouseover = new Function('tooltip.show("Godziny polecane");');
			td.onmouseout = new Function("tooltip.hide();");
		}
	}
	td.style.cursor = 'pointer';
	if (map != undefined) {
		td.onclick = function() {
			window.location = '#';
			myclick(i);
		};
	}	
	td.setAttribute('align', 'center');
	if (i % 2 == 1) {
		td.style.backgroundColor = bgcolor;
	}
	
	if((i%countppage)==(countppage-1)||(allnum%countppage==(page_i+1)&&actpage==pages)) td.className = 'tabledata lastrow'+open_sh_class1;
		else td.className = 'tabledata'+open_sh_class1;
	
	if(readCookie('setChecked')==1 && departementList[i]["whpreff"]=='' || readCookie('setChecked')!=1) td.style.display='none';

	if(departementList[i]["whpreff"]!='zamknięte') td.innerHTML = '<span>'+departementList[i]["whpreff"]+'</span>';
		else td.innerHTML = '<span>'+departementList[i]["wh"]+'</span>';

	tr.appendChild(td);
	
	
	//koniec godziny preferowane od

	// godziny do

	if(departementList[i]["fh"]!='inne'){
		td = document.createElement('td');
		if(readCookie('setChecked')==1 && departementList[i]["whpreff"]!='') td.style.display='none';
		td.style.cursor = 'pointer';
		if (map != undefined) {
			td.onclick = function() {
				window.location = '#';
				myclick(i);
			};
		}	
		td.setAttribute('align', 'center');
		if (i % 2 == 1) {
			td.style.backgroundColor = bgcolor;
		}
		if((i%countppage)==(countppage-1)||(allnum%countppage==(page_i+1)&&actpage==pages)) td.className = 'tabledata lastrow'+open_nh_class2;
			else td.className = 'tabledata'+open_nh_class2;

		td.innerHTML = departementList[i]["fh"];

		tr.appendChild(td);
	}
	//koniec godziny
	
	

	
	
	//poczatek godziny preferowane do
	if(departementList[i]["fhpreff"]!='inne'){	
		td = document.createElement('td');
		td.style.cursor = 'pointer';
		if(departementList[i]["fhpreff"]!='' && departementList[i]["fhpreff"]!='zamknięte'){
			td.onmouseover = new Function('tooltip.show("Godziny polecane");');
			td.onmouseout = new Function("tooltip.hide();");
		}
		if (map != undefined) {
			td.onclick = function() {
				window.location = '#';
				myclick(i);
			};
		}	
		td.setAttribute('align', 'center');
		if (i % 2 == 1) {
			td.style.backgroundColor = bgcolor;
		}
		if((i%countppage)==(countppage-1)||(allnum%countppage==(page_i+1)&&actpage==pages)) td.className = 'tabledata lastrow'+open_sh_class2;
			else td.className = 'tabledata'+open_sh_class2;
		
		if(readCookie('setChecked')==1 && departementList[i]["whpreff"]=='' || readCookie('setChecked')!=1) td.style.display='none';
		
		
		if(departementList[i]["fhpreff"]!='zamknięte') td.innerHTML = '<span>'+departementList[i]["fhpreff"]+'</span>';
			else td.innerHTML = '<span>'+departementList[i]["fh"]+'</span>';

		tr.appendChild(td);		
	}
	//koniec godziny preferowane do
	
	
	td = document.createElement('td');
	td.setAttribute('align', 'center');
	td.innerHTML = departementList[i]["contactLink"];
	td.className = 'nohref';
	tr.appendChild(td);

	tbody.appendChild(tr);
}

function currentPage(countppage, count) {
	oldDiv = document.getElementById('pagination');
	newDiv = document.createElement(oldDiv.tagName);
	newDiv.id = oldDiv.id;
	newDiv.className = oldDiv.className;
	oldDiv.parentNode.replaceChild(newDiv, oldDiv); 
	var dots = 0;
	var dots2 = 0;
	pages = Math.ceil(count / countppage);
	if(pages>1) $('divpagination').style.display = "block" ;
	for (i = 0; i < pages; i++) {
		if(pages>10){
			if(i==0){
				td = document.createElement('td');
				td.innerHTML = '<a id="page-'+(i+1)+'" class="pag-active" onclick="changePage('+(i+1)+');">'+(i+1)+'</a>';
				$('pagination').appendChild(td);	
			}
			else if(i<5 && i>0){
				td = document.createElement('td');
				td.innerHTML = '<a id="page-'+(i+1)+'" onclick="changePage('+(i+1)+');">'+(i+1)+'</a>';
				$('pagination').appendChild(td);				
			}
			else if(i>=5 && (pages-i)<2){
				td = document.createElement('td');
				td.innerHTML = '<a id="page-'+(i+1)+'" onclick="changePage('+(i+1)+');">'+(i+1)+'</a>';
				$('pagination').appendChild(td);								
			}
			else{
				dots = 1;
			}
			if(dots==1 && dots2==0){
				td = document.createElement('td');
				td.innerHTML = '...';
				$('pagination').appendChild(td);
				dots2 = 1;
			}
		}
		else{
			if(i==0){
				td = document.createElement('td');
				td.innerHTML = '<a id="page-'+(i+1)+'" class="pag-active" onclick="changePage('+(i+1)+');">'+(i+1)+'</a>';
				$('pagination').appendChild(td);	
			}
			else{
				td = document.createElement('td');
				td.innerHTML = '<a id="page-'+(i+1)+'" onclick="changePage('+(i+1)+');">'+(i+1)+'</a>';
				$('pagination').appendChild(td);							
			}
		}
	}
	if(pages>1){
		td = document.createElement('td');
		td.innerHTML = '<a id="page-'+(i+1)+'" onclick="changePage(2);">&gt;</a>';			
		$('pagination').appendChild(td);
	}
}

function currentPageReloaded(countppage, count, page) {
	oldDiv = document.getElementById('pagination');
	newDiv = document.createElement(oldDiv.tagName);
	newDiv.id = oldDiv.id;
	newDiv.className = oldDiv.className;
	oldDiv.parentNode.replaceChild(newDiv, oldDiv); 
	var dots = 0;
	var dots2 = 0;
	var dots3 = 0;
	pages = Math.ceil(count / countppage);
	if(page>1){
		td = document.createElement('td');
		td.innerHTML = '<a id="page-'+(page-1)+'" onclick="changePage('+(page-1)+');">&lt;</a>';
		$('pagination').appendChild(td);
	}

	if(pages>10){
		if(page>=7){
			td = document.createElement('td');
			td.innerHTML = '<a id="page-'+(page-8)+'" onclick="changePage(1);">1</a>';
			$('pagination').appendChild(td)
		}
		if(page>=8){
			td = document.createElement('td');
			td.innerHTML = '...';
			$('pagination').appendChild(td);		
		}
	}
	for (i = 0; i < pages; i++) {
		td = document.createElement('td');		
		if(pages>10){
			if(i>=(page-6) && i<(page-1)){
				td.innerHTML = '<a id="page-'+(i+1)+'" onclick="changePage('+(i+1)+');">'+(i+1)+'</a>';
				$('pagination').appendChild(td);					
			}
			else if(i>(page-1) && i<=(page+4)){
				td.innerHTML = '<a id="page-'+(i+1)+'" onclick="changePage('+(i+1)+');">'+(i+1)+'</a>';
				$('pagination').appendChild(td);					

			}
			else if(i==(page-1)){
				td.innerHTML = '<a id="page-'+(i+1)+'" class="pag-active" onclick="changePage('+(i+1)+');">'+(i+1)+'</a>';
				$('pagination').appendChild(td);	
			}
		}
		else{
			if(i==(page-1)){

				td.innerHTML = '<a id="page-'+(i+1)+'" class="pag-active" onclick="changePage('+(i+1)+');">'+(i+1)+'</a>';
				$('pagination').appendChild(td);	
			}
			else{
				td.innerHTML = '<a id="page-'+(i+1)+'" onclick="changePage('+(i+1)+');">'+(i+1)+'</a>';
				$('pagination').appendChild(td);							
			}
		}
	}
	if(pages>10){
		if(page<=(pages-7)){
			td = document.createElement('td');
			td.innerHTML = '...';
			$('pagination').appendChild(td);		
		}	
		if(page<=(pages-6)){
			td = document.createElement('td');
			td.setAttribute("style","cursor: pointer;")
			td.innerHTML = '<a id="page-'+(page-8)+'" onclick="changePage('+pages+');">'+pages+'</a>';
			$('pagination').appendChild(td)
		}
	}
	if(page<pages){
		td = document.createElement('td');
		td.setAttribute("style","cursor: pointer;")
		td.innerHTML = '<a id="page-'+(page+1)+'" onclick="changePage('+(page+1)+');">&gt;</a>';
		$('pagination').appendChild(td);
	}

}

function addMarkers(placowki) {
	if (placowki == null)
		return false; /* $('nofound').style.display = 'none'; */
	var adres = placowki[0];
	var serwisy = placowki[1];
	var lat = placowki[2];
	var long1 = placowki[3];
	var sciezka = placowki[4];
	var wh = placowki[5];
	var fh = placowki[6];
	var nh = placowki[7];
	var typ = placowki[8];
	var uwagi = placowki[10];
	var place = placowki[9];
	var adresshort = placowki[11];
	var opis;
	var old_table = $('departementTable');
	var table = document.createElement('table');
	var col = document.createElement('col');
	col.setAttribute('width', '170px');
	table.appendChild(col);
	col = document.createElement('col');
	col.setAttribute('width', '350px');
	table.appendChild(col);
	col = document.createElement('col');
	col.setAttribute('width', '90px');
	table.appendChild(col);
	col = document.createElement('col');
	col.setAttribute('width', '90px');
	table.appendChild(col);
	col = document.createElement('col');
	col.setAttribute('width', '170px');
	table.appendChild(col);	
	table.id = "departementTable";
	table.style.width = '68%';
	table.setAttribute('style', 'table-layout: fixed;');
	table.setAttribute('border', 0);
	table.setAttribute('cellpadding', 0);
	table.setAttribute('cellspacing', 0);
	table.setAttribute('align', 'center');
	table.style.borderCollapse = 'collapse';
	var typ_nazwa = placowki[12];
	var cat = placowki[13];
	var other_hours = placowki[14];
	var open_status = placowki[15];
	var addressId = placowki[16];
	var departementNumber = placowki[17];
	var email = placowki[18];
	var tel1 = placowki[19];
	var tel2 = placowki[20];
	var whpreff = placowki[21];
	var fhpreff = placowki[22];
	var nhpreff = placowki[23];
	var other_hours_preff = placowki[24];
	var ca = placowki[25];
	var other_hours_preff_json = placowki[26];
	var other_hours_json = placowki[27];
	var kategorie = new Array();
	kategorie['bz'] = 'BZWBK';
	kategorie['e'] = 'Euronet';
	var tbody = createTable();
	if (typ_nazwa == undefined)
		typ_nazwa = new Array();
	departementList = new Array();
	var countppage = $('countppage').value;
	for (i = 0; i < lat.length; i++) {

		if ((cat[i] == 'e') && ((departementNumber[i]).indexOf("LUK") == -1) && ((departementNumber[i]).indexOf("LB") == -1)) {
			uwagi[i] += ((uwagi[i] != '') ? ', ' : '') + 'tylko dla klientów e-Konta PLUS';
		}
		adres[i] += '<span style="font-weight:normal">' + place[i]
				+ ((uwagi[i] != '' && place[i] != '') ? ',' : '')
				+ uwagi[i] + '</span>';
		departementList[i] = new Array();
		departementList[i]["adresshort"] = adresshort[i];
		departementList[i]["wh"] = wh[i];
		departementList[i]["whpreff"] = whpreff[i];
		departementList[i]["fh"] = fh[i];
		departementList[i]["fhpreff"] = fhpreff[i];		
		departementList[i]["place"] = place[i];
		departementList[i]["uwagi"] = uwagi[i];
		departementList[i]["addressId"] = addressId[i];
		departementList[i]["email"] = email[i];
		departementList[i]["tel1"] = tel1[i];
		departementList[i]["tel2"] = tel2[i];
		departementList[i]["ca"] = ca[i];
		departementList[i]["typ"] = typ[i];
		if (typ_nazwa[i] == undefined) {
			typ_nazwa[i] = $('s_type').options[$('s_type').selectedIndex].text;
		}
		departementList[i]["typ_nazwa"] = typ_nazwa[i];
		departementList[i]["cat"] = kategorie[cat[i]];
		departementList[i]["open_status"] = open_status[i];
		departementList[i]["other_hours"] = other_hours[i];
		departementList[i]["other_hours_json"] = other_hours_json[i].evalJSON();
		departementList[i]["other_hours_preff"] = other_hours_preff[i];
		departementList[i]["other_hours_preff_json"] = other_hours_preff_json[i].evalJSON();


		if((typ_nazwa[i]=='Centrum kredytowe'||typ_nazwa[i]=='Placówka Bankowa') && departementList[i]["email"]==1){
			if(typ_nazwa[i]=='Centrum kredytowe') t=2;
				else t=1;
			
			if(document.getElementById('type').checked==true){
				u=0;	
			}
			else{
				u=document.getElementById('s_services').options[document.getElementById('s_services').selectedIndex].value;
			}
			
			departementList[i]["contactLink"] = '<a class="contact_with" href="https://wniosek.lukasbank.pl/formularz_kontaktowy.asp?m=1&id='+departementList[i]["addressId"]+'&t='+t+'&u='+u+'" target="_blank">Umów się z Doradc±</a>';
		}
		else{
			departementList[i]["contactLink"] = '';
		}

		if (i < countppage)
			createTableRow(tbody, i, countppage, i, lat.length);
		opis = '';
		if ((wh[i] == fh[i]) && (fh[i] == nh[i]) && fh[i] == 0) {
			opis = '<div class="cloud_content" id="cloud_content"><div class="cloud_title"><span class="cloud_title1"><a href="index.php?search=Ids&p1='
					+ addressId[i]
					+ '">'
					+ typ_nazwa[i]
					+ ((typ[i] == 3) ? (', ' + kategorie[cat[i]]) : '')
					+ '</a></span><span class="cloud_title2">'
					+ adres[i]
					+ '</span></div><div class="openHours1"><span class="fontGray">godziny otwarcia</span><br />'
					+ wh[i];
		} else {
			opis = '<div class="cloud_content" id="cloud_content"><div class="cloud_title"><span class="cloud_title1"><a href="index.php?search=Ids&p1='
					+ addressId[i]
					+ '">'
					+ typ_nazwa[i]
					+ ((typ[i] == 3) ? (', ' + kategorie[cat[i]]) : '')
					+ '</a></span><span class="cloud_title2">'
					+ adres[i]
					+ '</span></div><div class="openHours2" style="height: 80px;"><span class="fontGray">godziny otwarcia</span>';
			if (open_status[i] < 2) {
				opis += '<table><tr><td style="font-weight:bold; text-align:left;">pn-pt:</td><td style="text-align: left;">'
						+ wh[i]
						+ '</td></tr><tr><td style="font-weight:bold; text-align:left;">sob:</td><td style="text-align: left;">'
						+ fh[i]
						+ '</td></tr><tr><td style="font-weight:bold; text-align:left;">nd:</td><td style="text-align:left;">'
						+ nh[i] + '</td></tr></table>';
			} else {
				opis += '<table>';
				
				if(departementList[i]["other_hours_json"]["other_d_1"]!='') opis += '<tr><td style="font-weight:bold; text-align:left;">'+departementList[i]["other_hours_json"]["other_d_1"]+':</td><td style="text-align: left;">'+ departementList[i]["other_hours_json"]["other_h_1"]+ '</td></tr>';
				if(departementList[i]["other_hours_json"]["other_d_2"]!='') opis += '<tr><td style="font-weight:bold; text-align:left;">'+departementList[i]["other_hours_json"]["other_d_2"]+':</td><td style="text-align: left;">'+ departementList[i]["other_hours_json"]["other_h_2"]+ '</td></tr>';
				if(departementList[i]["other_hours_json"]["other_d_3"]!='') opis += '<tr><td style="font-weight:bold; text-align:left;">'+departementList[i]["other_hours_json"]["other_d_3"]+':</td><td style="text-align: left;">'+ departementList[i]["other_hours_json"]["other_h_3"]+ '</td></tr>';
				
				opis += '</table>';
						
				//other_hours[i] = other_hours[i]
				//		.replace(/<b>/g,
				//				'<b style="margin-left: 3px; width: 70px; float: left; text-align: right;">');
				//opis += '<br/>' + other_hours[i];
			}
		}
		/*if (showimage == 1 && sciezka[i] != '' && isThere(sciezka[i])) {
			opis += '<span id="min" style="display: none" ><br/><a href="#" onclick="map.getInfoWindow().restore(); return false;">pomniejsz zdjęcie</a></span></div><div style="float:left; padding:10px 0px;">';
			index = sciezka[i].lastIndexOf('.');
			var path = new Array();
			path['filename'] = sciezka[i].substring(0, index);
			path['ext'] = sciezka[i].substring(index);
			opis += '<img id="image" width="130px" height="85px" src="'
					+ path['filename']
					+ '_small'
					+ path['ext']
					+ '" style="display:block" /><a id="max" style="display: inline" href="#" onclick="map.getInfoWindow().maximize(); hideDirection(); return false;">powiększ zdjęcie</a>';
		} else {
			opis += '</div><div style="float:left; padding:10px 0px;"><div id="image" style="display: block;width: 130px; height: 96px" >&nbsp;</div>';
		}*/
			
		var display='';
		if(readCookie('setChecked')==1) display='block';
			else display='none';
			
		opis += '</div><div style="float:left; margin: 15px 0 0 -2px;"><div id="image" class="cloudPreffHours" style="display: '+display+';width: 130px; height: 92px" >';
		
		if(show_recommended_hours==1){
			if(departementList[i]["whpreff"]=='inne'){
				/*opis += '<span class="fontGray" style="color: #408840">godziny polecane</span>';
				other_hours_preff[i] = other_hours_preff[i]
						.replace(/<b>/g,
								'<b style="color: #408840; margin-left: 3px; width: 70px; float: left; text-align: left;">');
				opis += '<br/>' + other_hours_preff[i];*/
				opis += '<span class="fontGray" style="color: #408840">godziny polecane</span>';
				opis += '<table style="color: #408840; width: 161px;">';
				if(departementList[i]["other_hours_preff_json"]["other_d_1_preff"]!='') opis += '<tr><td style="font-weight:bold; ">'+departementList[i]["other_hours_preff_json"]["other_d_1_preff"]+':</td><td style="text-align: left;">'+departementList[i]["other_hours_preff_json"]["other_h_1_preff"]+'</td></tr>';
				if(departementList[i]["other_hours_preff_json"]["other_d_2_preff"]!='') opis += '<tr><td style="font-weight:bold; ">'+departementList[i]["other_hours_preff_json"]["other_d_2_preff"]+':</td><td style="text-align: left;">'+departementList[i]["other_hours_preff_json"]["other_h_2_preff"]+'</td></tr>';
				if(departementList[i]["other_hours_preff_json"]["other_d_3_preff"]!='') opis += '<tr><td style="font-weight:bold; ">'+departementList[i]["other_hours_preff_json"]["other_d_3_preff"]+':</td><td style="text-align: left;">'+departementList[i]["other_hours_preff_json"]["other_h_3_preff"]+'</td></tr>';				
				opis += '</table>';
			} else {
				if(whpreff[i]!=''){
					opis += '<span class="fontGray" style="color: #408840">godziny polecane</span>';
					opis += '<table style="color: #408840; width: 161px;">';
					if(whpreff[i]!='zamknięte') opis += '<tr><td style="font-weight:bold; ">pn-pt:</td><td style="text-align: left;">'+whpreff[i]+'</td></tr>';
					if(fhpreff[i]!='zamknięte') opis += '<tr><td style="font-weight:bold;">sob:</td><td style="text-align: left;">'+fhpreff[i]+'</td></tr>';
					if(nhpreff[i]!='zamknięte') opis += '<tr><td style="font-weight:bold;">nd:</td><td style="text-align:left;">'+nhpreff[i]+'</td></tr>';
					opis += '</table>';
				}
			}
		}
		
		opis += '</div>';	

		opis += '</div>';
		opis += '<div style="width: 100%; clear: both; float: left; margin-top: -35px">';
		opis += '<span id="direction" style="display: inline; font-size: 11px">DojedĽ <a id="toDir" href="javascript:tohere('
				+ i
				+ ');">do</a> / <a id="fromDir" href="javascript:fromhere('
				+ i + ');">z</a> tego miejsca</span>';
		opis += '<br/><a id="back" href="javascript:hideDirection();" style="display: none; align: left; font-size: 10px">&lt;Cofnij</a>';
		adresshort[i] = adresshort[i].replace('<br />', '');
		opis += '<div id="direction_form" style="display: none; text-align: left; font-size: 10px; width: 205px">Opis<form onsubmit="return getDirection(this);" style="margin: 0 padding: 0"><input type="text" id="input_city"  style="width: 70px; font-size: 10px;" onfocus="clearInput(this);" title="Miasto"/>&nbsp;<input type="text" id="input_street"  style="width: 70px; font-size: 10px;" onfocus="clearInput(this);" title="Ulica nr"/><input type="hidden" id="hid" value="'
				+ typ_nazwa[i]
				+ ','
				+ adresshort[i]
				+ '@'
				+ lat[i]
				+ ','
				+ long1[i]
				+ '"/><input type="submit" value="OK" style="width: 26px; font-size: 10px;"/></form></div>';
		opis += '</div>';
		
		
		
		if(tel1[i]!=''||tel2[i]!=''){
			opis += '<div style="float: left; width: 360px;"><img style="margin-right: 5px;" align="left" id="image" width="26px" height="25px" src="./images/tel.gif">';
			if(tel1[i]!='') opis += 'Tel. Doradcy Hipotecznego: '+tel1[i]+'<br/>';
			if(tel2[i]!='') opis += 'Tel. Doradcy Klienta Biznesowego: '+tel2[i]+'<br/>';
			opis += '</div>';
		}
		
		if((typ_nazwa[i]=='Centrum kredytowe'||typ_nazwa[i]=='Placówka Bankowa') && departementList[i]["email"]==1){
			if(typ_nazwa[i]=='Centrum kredytowe') t=2;
				else t=1;
			
			if(document.getElementById('type').checked==true){
				u=0;	
			}
			else{
				u=document.getElementById('s_services').options[document.getElementById('s_services').selectedIndex].value;
			}
			
			opis += '<div style="float:left; padding:10px 0px;"><a target="blank" class="contactlink" href="https://wniosek.lukasbank.pl/formularz_kontaktowy.asp?m=1&id='+departementList[i]["addressId"]+'&t='+t+'&u='+u+'"><div class="contactbutton">Umów się z Doradc±</div></a></div>';
		}
		
		opis += '</div>';		
		if (serwisy[i] == '') {
			uslugi = '';
		} else {
			uslugi = '<div style="width:330px; height:275px; font-family:Verdana,Arial; text-align:left; font-size:10px; line-height:18px; color:black;"><span style="font-size: 11px; color: #5D5D5D; font-weight: bold; padding: 10px 10px 0 0;">Usługi dostępne w oddziale:</span><div style="height:275px; width:330px;"><ul class="services" style="list-style-image:url(./images/point.gif); font-size:10px;">' + serwisy[i] + '</ul></div></div>';
		}
		if (map != undefined) {
			icon = new GIcon();
			icon.iconSize = new GSize(20, 34);
			icon.iconAnchor = new GPoint(10, 34);
			icon.infoWindowAnchor = new GPoint(4, 6);				
			if (typ[i] != 3
					|| cat[i] == 'bz'
					|| (cat[i] == 'e' && (departementNumber[i]).indexOf("LUK") != -1 && (departementNumber[i]).indexOf("LB") != -1)) {

				if(ca[i]==1) {
					icon.image = "./images/lukas_marker_ca.png";
				}
				else if(typ[i] == 7) {
					icon.image = "./images/lukas_marker_sp.png";
					icon.iconSize = new GSize(32, 32);
					icon.iconAnchor = new GPoint(16, 32);
					icon.infoWindowAnchor = new GPoint(4, 6);										
				}				
				else{
					icon.image = "./images/lukas_marker_good.png";
				}
			
			} else {
				icon.image = "./images/lukas_marker_good2.png";
			} /*
				 * * icon.shadow = "/images/lukas_marker_cien2.png";
				 * icon.iconSize = * new GSize(25, 25); icon.shadowSize = new
				 * GSize(25, 20);
				 */
			punkt = new GLatLng(lat[i], long1[i]);
			map.addOverlay(createMarker(punkt, icon, opis, uslugi, i,
					adresshort[i]));
			obszar.extend(punkt);
		}
	}
	if (lat.length > 0) {
		if (map != undefined) {
			var nowyZoom = map.getBoundsZoomLevel(obszar);/* ustal zoom */
			if (nowyZoom > maxZoom)
				nowyZoom = maxZoom;
			var nowyPunkt = obszar.getCenter();
			map.setCenter(nowyPunkt, nowyZoom);
		}
		table.appendChild(tbody);
		$('tab1').replaceChild(table, old_table); /* $('tab1').innerHTML = "<textarea>"+$('tab1').innerHTML+"</textarea>"; */
		currentPage(countppage, i);
		$('tablefotter').style.display = "block";
		changeTab(1);
		$('tab2').innerHTML = '';
		var gemius_identifier = new String('cjJF1keSvZA3VMPbWGzqbmYkfcCBgAdh_L6f8g3Qgm3.k7');
		gemius_hit_int(gemius_identifier,0,0);
	}
	
}
function AJ() {
	var obj;
	if (window.XMLHttpRequest)
		obj = new XMLHttpRequest();
	else if (window.ActiveXObject) {
		try {
			obj = new ActiveXObject('MSXML2.XMLHTTP.3.0');
		} catch (er) {
			try {
				obj = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (er) {
				obj = false;
			}
		}
	}
	return obj;
}
function isThere(url) {
	var req = new AJ(); /* XMLHttpRequest object */
	try {
		req.open("HEAD", url, false);
		req.send(null);
		return req.status == 200 ? true : false;
	} catch (er) {
		return false;
	}
}
function clearInput(input) {
	if (input.title != input.value)
		return;
	input.value = '';
	input.style.fontSize = '10px';
	input.style.color = '';
}
function tohere(nr) {
	$('direction').style.display = 'none';
	$('back').style.display = 'inline';
	$('direction_form').innerHTML = $('direction_form').innerHTML.replace(
			/Opis/, 'Sk±d');
	$('input_city').name = 'from_city';
	$('input_city').value = $('input_city').title;
	$('input_city').style.fontSize = '9px';
	$('input_city').style.color = '#979797';
	$('input_street').name = 'from_street';
	$('input_street').value = $('input_street').title;
	$('input_street').style.fontSize = '9px';
	$('input_street').style.color = '#979797';
	$('hid').name = 'to';
	$('direction_form').style.display = 'block';
}
function fromhere(nr) {
	$('direction').style.display = 'none';
	$('back').style.display = 'inline';
	$('direction_form').innerHTML = $('direction_form').innerHTML.replace(
			/Opis/, 'Dok±d');
	$('input_city').name = 'to_city';
	$('input_city').value = $('input_city').title;
	$('input_city').style.fontSize = '9px';
	$('input_city').style.color = '#979797';
	$('input_street').name = 'to_street';
	$('input_street').value = $('input_street').title;
	$('input_street').style.fontSize = '9px';
	$('input_street').style.color = '#979797';
	$('hid').name = 'from';
	$('direction_form').style.display = 'block';
}
function hideDirection() {
	$('direction').style.display = 'inline';
	$('back').style.display = 'none';
	$('direction_form').style.display = 'none';
	$('direction_form').innerHTML = $('direction_form').innerHTML.replace(
			/Sk±d/, 'Opis');
	$('direction_form').innerHTML = $('direction_form').innerHTML.replace(
			/Dok±d/, 'Opis');
}
function getDirection(formularz) {
	for ( var i = 0; i < formularz.childNodes.length; i++) {
		switch (formularz.childNodes[i].name) {
		case 'from':
			var from = formularz.childNodes[i].value;
			break;
		case 'to':
			var to = formularz.childNodes[i].value;
			break;
		case 'from_city':
			var from = formularz.childNodes[i].value;
			if (formularz.childNodes[i + 2].value != ''
					&& formularz.childNodes[i + 2].value != formularz.childNodes[i + 2].title) {
				from += ' , ' + formularz.childNodes[i + 2].value;
			}
			if (/^[A-Za-z0-9ˇĘĆŻ¬ŁÓŃ¦±ęćżĽłóń¶.,-]*$/.exec(from.replace(/ /g,
					'')) === null) {
				formularz.childNodes[i].value = '';
				formularz.childNodes[i + 2].value = '';
				return false;
			}
			break;
		case 'to_city':
			var to = formularz.childNodes[i].value;
			/*
																 * * +' street: *
																 * '+formularz.childNodes[i+2].value;
																 */
			if (formularz.childNodes[i + 2].value != ''
					&& formularz.childNodes[i + 2].value != formularz.childNodes[i + 2].title) {
				to += ' , ' + formularz.childNodes[i + 2].value;
			}
			if (/^[A-Za-z0-9ˇĘĆŻ¬ŁÓŃ¦±ęćżĽłóń¶.,-]*$/.exec(to
					.replace(/ /g, '')) === null) {
				formularz.childNodes[i].value = '';
				formularz.childNodes[i + 2].value = '';
				return false;
			}
			break;
		}
	}
	gdir.load("from: " + from + " to: " + to, {
		locale: 'pl_PL'
	});
	return false;
}
function onGDirectionsLoad() {
	$('tabTitle2').style.display = 'inline';
	changeTab(2);
}
function handleErrors() {
	$('tabTitle2').style.display = 'none';
	changeTab(1);
	showWindow(WINDOW_GEOCODE);
}
function search_radius() {
	if (map == undefined)
		return;
	var form = $('myform');
	var radius_val = $('radius').value;
	var miasto_val = form.miasto.value;
	var wojewodztwo_val = form.wojewodztwo.value;
	if (radius_val > 0) {
		var geoc = new GClientGeocoder();
		if ($('state').checked) {
			tmp = 'province: ' + wojewodztwo_val;
		} else {
			tmp = 'city: ' + miasto_val;
		}
		geoc.getLatLng('PL, ' + tmp, getLatLng);/* getLatLng */
	}
}
function getLatLng(response) {
	var lat;
	var lng;
	if (response == null) {
		showWindow(WINDOW_GEOCODE);
		return;
	} else {
		lat = response.lat();
		lng = response.lng();
	}
	var radius = 0;
	if ($('radius') != null) {
		radius = $('radius').value;
	}
	search_click($('myform'), radius, lat, lng);
}
function getStreets(city_val) {
	city_val = city_val.substr(0, city_val.search(/,/));
	var myAjax = new Ajax.Request(
			'getdata.php',
			{
				method : 'post',
				parameters : {
					city : city_val
				},
				onSuccess : function(transport) {
					var result = new Array();
					result = transport.responseText.evalJSON();
					html = '';
					aktualnaPodpowiedz = new Array();
					if (result != null) {
						for ( var i = 0; i < result.length; i++) {
							result[i] = city_val + ',' + result[i]; /*
																	 * *
																	 * if(!result[i].search(re)) { *
																	 * aktualnaPodpowiedz.push(result[i]); *
																	 * if( *
																	 * result[i].toLowerCase() == *
																	 * cos.toLowerCase() ) *
																	 * continue;
																	 */
							html += '<div id="' + result[i] + '" ';
							html += 'style="cursor:pointer; margin-left:5px; margin-bottom:2px;" ';
							html += 'onclick="$(\'miasto\').value=\'' + result[i] + '\'; if(document.forms[\'myform\'].onsubmit())document.forms[\'myform\'].submit(); $(\'podpowiedz\').style.visibility = \'hidden\';"';
							html += 'onmouseover="document.getElementById(\'' + result[i] + '\').style.background=\'#FFFF00\'"';
							html += 'onmouseout="$(\'' + result[i]
									+ '\').style.background=\'#FFB623\'"> '
									+ result[i] + '</div>'; /* } */
						}
						html = "<span style=\"margin-left:5px; font-weight:bold;\">Wybierz miasto:</span>"
								+ html;
						$("podpowiedz").innerHTML = html;
					}
				},
				onFailure : function() {
					alert('W tej chwili wyszukanie ulic jest niemożliwe. Proszę spróbować ponownie.');
				}
			});
}
function fill_form_and_search(miastoData, wojewodztwoData, groupData,
		s_servicesData, s_typeData, searchData, formDataJS) {
	if (miastoData != 'false') {
		document.myform.miasto.value = miastoData;
	}
	if (wojewodztwoData != 'false') {
		document.myform.wojewodztwo.value = wojewodztwoData;
	}
	if (groupData == 'Services') {
		document.myform.group[0].checked = true;
	} else {
		document.myform.group[1].checked = true;
	}
	if (!(s_servicesData == undefined)) {
		document.myform.s_services.value = s_servicesData;
	}
	if (!(s_typeData == undefined))
		document.myform.s_type.value = s_typeData;
	if (searchData == 'State')
		document.myform.search[0].checked = true;
	else
		document.myform.search[1].checked = true; /*
													 * *
													 * document.myform.search.value = *
													 * searchData; search_click( *
													 * formDataJS );
													 */
}
function search_click(form, radius_val, lat_val, lng_val) {
	
	createCookie('setChecked', 0, 1);
	$('miasto').setValue($('miasto').getValue().strip());
	$('tt2').style.display='none';
	if ($('city').checked && !$('miasto').getValue()) {
		showWindow(WINDOW_ALERT_CITY);
		return false;
	}
	var filter = /^[A-Za-zˇĘĆŻ¬ŁÓŃ¦±ęćżĽłóń¶., -]+$/ ;
	if($('city').checked && !filter.test($('miasto').getValue()))
	{
	    showWindow(WINDOW_ALERT);
	    return false;
	}
	if (map != undefined
			&& (lat_val == undefined || lat_val == 0 || lng_val == undefined || lng_val == 0)) {
		var form = $('myform');
		var miasto_val = form.miasto.value;
		var ulica_val = form.ulica.value;
		var wojewodztwo_val = form.wojewodztwo.value;
		var geoc = new GClientGeocoder();
		if (radius_val == undefined && $('radius') != null) {
			$('radius').value = 0;
		}
		if ($('state').checked) {
			tmp = 'province: ' + wojewodztwo_val;
		} else {
			tmp = 'city: '
					+ miasto_val
					+ ' '
					+ ((lat_val == undefined && lng_val == undefined) ? ulica_val
							: '');
		}
		geoc.getLatLng('PL, ' + tmp, getLatLng);
		return false;
	}
	hideWindow();
	$('podpowiedz').style.display = 'none';
	if (radius_val == undefined)
		radius_val = 0;
	if (lat_val == undefined)
		lat_val = 0;
	if (lng_val == undefined)
		lng_val = 0;
	if (form['ids'] || (form['formFromUrl'] == 'true')) {
		var s_type_val = form['s_type'];
		var s_services_val = form['s_services'];
		var group_val = form['group'];
		var search_val = form['search'];
		if (((form['miasto'] != undefined) && (form['miasto'] != ''))&& (/^[A-Za-zˇĘĆŻ¬ŁÓŃ¦±ęćżĽłóń¶.,-]*$/.exec(form['miasto'].replace(/ /g, '')) === null)) {
			form['miasto'] = '';
			showWindow(WINDOW_ALERT);
			return false;
		}
		var wojewodztwo_val = form['wojewodztwo'];
		var idList_val = form['ids'];
		var miasto_val = form['miasto'];
	} else {
		var s_type_val = form.s_type.value;
		var s_services_val = form.s_services.value;
		var group_val = ((form.group[0].checked) ? form.group[0].value
				: form.group[1].value);
		var search_val = ((form.search[0].checked) ? form.search[0].value
				: form.search[1].value);
		if ((form.miasto.value != undefined)
				&& /^[A-Za-zˇĘĆŻ¬ŁÓŃ¦±ęćżĽłóń¶.,-]*$/.exec(form.miasto.value
						.replace(/ /g, '')) === null) {
			form.miasto.value = '';
			showWindow(WINDOW_ALERT);
			return false;
		}
		var wojewodztwo_val = form.wojewodztwo.value;
		var miasto_val = form.miasto.value;
	}
	$('loading').style.display = 'block';
	$('s_services').style.visibility = 'hidden';
	$('s_type').style.visibility = 'hidden';
	$('wojewodztwo').style.visibility = 'hidden';
	if (form.ulica.value != '') {
		miasto_val = '';
	}
	var myAjax = new Ajax.Request(
			'getdata.php',
			{
				method : 'post',
				parameters : {
					group : group_val,
					search : search_val,
					s_type : s_type_val,
					s_services : s_services_val,
					miasto : miasto_val,
					wojewodztwo : wojewodztwo_val,
					radius : radius_val,
					lat : lat_val,
					lng : lng_val,
					ids : idList_val
				},
				onSuccess : function(transport) {
					try {
						var placowki = transport.responseText.evalJSON(); /* alert(transport.responseText); */
					} catch (e) {
						showWindow(WINDOW_ERROR);
						$('loading').style.display = 'none';
						$('s_services').style.visibility = 'visible';
						$('s_type').style.visibility = 'visible';
						$('wojewodztwo').style.visibility = 'visible';
						return;
					}
					if (placowki != null) {
						$('background1').style.height = ($('content').clientHeight + 20) + 'px';
						showWindow(WINDOW_LOAD);
					}
					window
							.setTimeout(function() {
								var tmp = 0;
								$('tablefotter').style.display = "none";
								$('departementTable').style.display = "none";
								$('table_place').style.display = "none";
								if (map != undefined) {
									map.clearOverlays();
									obszar = new GLatLngBounds();
								}
								if (placowki != null) { /* legend */
									if (($('services').checked && $('s_services').options[$('s_services').selectedIndex].value == 2)
											|| ($('type').checked && $('s_type').options[$('s_type').selectedIndex].value == 3)) {
										$('legend').style.display = 'block';
									} else {
										$('legend').style.display = 'none';
									}
									$('table_place').style.display = "block";
									
									if(radius_val!=0&&$('city').checked){
										if ($('state').checked) {
											place_val = 'woj. '+wojewodztwo_val;
										}
										else {
											place_val = miasto_val;
										}
										$('background1').className = 'layer-background layer_on';
										$('near_legend').style.display = "block";
										$('near_legend').innerHTML = "Nie znaleziono obiektów w miejscu wyszukiwania (<strong>"+place_val+"</strong>).<br/>Najbliższe obiekty znalezione w okolicy miejsca wyszukania.";
									}
									else{
										$('near_legend').style.display = "none";
										$('background1').className = 'layer-background layer_off';
									}
									
									$('tabTitle2').style.display = "none";
									if (radius_val > 0 && map != undefined) {
										punkt = new GLatLng(lat_val, lng_val);
										var marker = new GMarker(punkt);
										map.addOverlay(marker);
										obszar.extend(punkt);
									}
									addMarkers(placowki);
								} else if (map != undefined
										&& (($('city').checked && $('miasto').value != '') || !$('city').checked)) {
									var geoc = new GClientGeocoder();
									if ($('state').checked) {
										tmp = 'province: ' + $('wojewodztwo').value;
									} else {
										tmp = 'city: ' + $('miasto').value;
									}
									geoc
											.getLocations(
													'PL, ' + tmp,
													function(result) {
														var content = '';
														if (result.Status.code == G_GEO_SUCCESS
																&& result.Placemark[0].AddressDetails.Country.CountryNameCode == 'PL') {
															if ($('services').checked) {
																content += 'oferuj±ce usługę<br/>' + $('s_services').options[$('s_services').options.selectedIndex].text;
															} else {
																content += 'typu<br/>' + $('s_type').options[$('s_type').options.selectedIndex].text;
															}
															$('user_choice').innerHTML = content;
															var lat_val = result.Placemark[0].Point.coordinates[1];
															var lng_val = result.Placemark[0].Point.coordinates[0];
															var punkt = new GLatLng(
																	lat_val,
																	lng_val);
															var marker = new GMarker(
																	punkt);
															map
																	.addOverlay(marker);
															obszar
																	.extend(punkt);
															var nowyZoom = map
																	.getBoundsZoomLevel(obszar);/*
																								 * *
																								 * ustal *
																								 * zoom
																								 */
															if (nowyZoom > maxZoom)
																nowyZoom = maxZoom;
															var nowyPunkt = obszar
																	.getCenter();
															map.setCenter(
																	nowyPunkt,
																	nowyZoom);
															showWindow(WINDOW_DIALOG);
														} else {
															showWindow(WINDOW_ALERT);
														}
													}); /*
														 * *
														 * $('nofound').style.display = *
														 * 'inline'; *
														 * $('table_place').style.display = *
														 * "none";
														 */
								} else {
									showWindow(WINDOW_ALERT_CITY);
									tmp = 1;
								}
								if (tmp != 1)
									hideWindow();
								/*$('telephones').style.display = 'none';
								if($('services').checked){
									var select = $('s_services');
									var pos = select.selectedIndex;
									if(servicesTel[pos].tel1 != '' || servicesTel[pos].tel2 != ''){
										$('service_name').innerHTML = select.options[pos].text;
										if(servicesTel[pos].tel1 != ''){
											$('service_tel1').innerHTML = servicesTel[pos].tel1;
											$('service_tel1').style.display = 'inline';
										} else {
											$('service_tel1').style.display = 'none';
										}
										if(servicesTel[pos].tel2 != ''){
											$('service_tel2').innerHTML = servicesTel[pos].tel2;
											$('service_tel2').style.display = 'inline';
										} else {
											$('service_tel2').style.display = 'none';
										}
										$('telephones').style.display = 'block';
										content_height += 50;
									}
								}*/
							});
					$('loading').style.display = 'none';
					$('s_services').style.visibility = 'visible';
					$('s_type').style.visibility = 'visible';
					$('wojewodztwo').style.visibility = 'visible';
				},
				onFailure : function() {
					alert('Bł±d, spróbuj ponownie...');
					$('loading').style.display = 'none';
					$('s_services').style.display = 'inline';
					$('s_type').style.display = 'inline';
					$('wojewodztwo').style.display = 'inline';
				}
			});
	return false; /*
					 * * s_type: s_type_value, s_services: s_services_val,
					 * miasto: * miasto_val, wojewodztwo: wojewodztwo_val
					 */
}
function createMarker(point, icon, html1, html2, nr, adres) {
	var marker = new GMarker(point, {
		title : adres.replace(/<br \/>/, ''),
		icon : icon
	});
	GEvent
			.addListener(
					marker,
					"click",
					function() {
						var point = marker.getPoint();
						var bounds = map.getBounds();
						var southWest = bounds.getSouthWest();
						var size = bounds.toSpan();
						var center = map.getCenter();
						var xDisLat = center.lat()
								+ (point.lat() - (southWest.lat() + (size.lat() / 12)));
						var yDisLng = center.lng()
								+ (point.lng() - (southWest.lng() + ((size
										.lng() / 16) * 6)));
						var tab1 = document.createElement("div");
						var tab2 = document.createElement("div");
						var tab3 = document.createElement("div");
						tab3.style.width = "390px";
						tab3.style.height = "250px"; /*
														 * * html1 += '<a *
														 * href="#" *
														 * onclick="map.showMapBlowup(point);">Lupa</a>';
														 */
						tab1.innerHTML = html1;
						tab2.innerHTML = html2;
						if (html2 == '')
							var infoTabs = [ new GInfoWindowTab("Opis", tab1),
									new GInfoWindowTab("Minimapa", tab3) ];
						else
							var infoTabs = [ new GInfoWindowTab("Opis", tab1),
									new GInfoWindowTab("Usługi", tab2),
									new GInfoWindowTab("Minimapa", tab3) ];
						var map2 = new GMap2(tab3, {
							size : new GSize(360, 270)
						});
						map2.addControl(new GSmallZoomControl());
						map2.setCenter(point, 15);
						var mark2 = new GMarker(point, {
							icon : icon,
							title : adres.replace(/<br \/>/, '')
						});
						map2.addOverlay(mark2);
						tab3.firstChild.nextSibling.style.display = 'none';
						tab3.firstChild.nextSibling.nextSibling.style.display = 'none';
						map.setCenter(new GLatLng(xDisLat, yDisLng));
						if (html1.search("img") != -1) {
							html1 = html1.replace(
									/id="direction" style="display: inline/,
									"id=\"direction\" style=\"display: none");
							var maxHtml1 = html1;
							maxHtml1 = maxHtml1
									.replace(
											/<div id="cloud_content" style="width:290px; height:185px;/,
											"<div style=\"width:auto; height:auto;");
							maxHtml1 = maxHtml1
									.replace(
											/<img id="image" width="130px" height="85px"/,
											"<img width=\"371px\" height=\"290px\"");
							maxHtml1 = maxHtml1.replace(/_small/, "");
							maxHtml1 = maxHtml1.replace(
									/id="max" style="display: inline"/,
									"id=\"max\" style=\"display: none\"");
							maxHtml1 = maxHtml1.replace(
									/id="min" style="display: none"/,
									"id=\"min\" style=\"display: inline\"");
							var maxTab1 = document.createElement("div");
							maxTab1.innerHTML = maxHtml1;
							marker.openInfoWindowTabs(infoTabs, {
								maxContent : maxTab1
							});
						} else
							marker.openInfoWindowTabs(infoTabs);
					});
	GEvent.addListener(marker, "infowindowbeforeclose", function() {
		hideDirection();
	});
	gmarkers[nr] = marker;
	return marker;
}
function changePage(page) {
	page = parseInt(page);
	var old_table = $('departementTable');
	var table = document.createElement('table');
	table.id = "departementTable";
	var col = document.createElement('col');
	col.setAttribute('width', '170px');
	table.appendChild(col);
	col = document.createElement('col');
	col.setAttribute('width', '350px');
	table.appendChild(col);
	col = document.createElement('col');
	col.setAttribute('width', '90px');
	table.appendChild(col);
	col = document.createElement('col');
	col.setAttribute('width', '90px');
	table.appendChild(col);
	col = document.createElement('col');
	col.setAttribute('width', '170px');
	table.appendChild(col);	
	table.setAttribute('style', 'table-layout: fixed;');	
	table.style.width = '68%';
	table.setAttribute('border', 0);
	table.setAttribute('cellpadding', 0);
	table.setAttribute('cellspacing', 0);
	table.setAttribute('align', 'center');
	table.style.borderCollapse = 'collapse';
	var tbody = createTable(departementList[0]["typ_nazwa"]);
	var countppage = parseInt($('countppage').value);
	for (i = 0; i < countppage; i++) {
		if (departementList.length == (page - 1) * countppage + i)
			break;
		createTableRow(tbody, (page - 1) * countppage + i, countppage, i, departementList.length);
	}
	pages = Math.ceil(departementList.length / countppage);
	currentPageReloaded(countppage, departementList.length, page);
	table.appendChild(tbody);
	$('tab1').replaceChild(table, old_table);
}
function changePPage(count) {
	changePage(1);
	currentPage(count, departementList.length);
}
function onlyNum(evt, param) {
	var keynum;
	var keychar;
	var numcheck;
	if (window.event) { /* IE */
		keynum = evt.keyCode;
	} else if (evt.which) { /* Netscape/Firefox/Opera */
		keynum = evt.which;
	}
	keychar = String.fromCharCode(keynum);
	if (keynum == 13) {
		search_radius();
		return true;
	}
	if (keynum == undefined)
		return true;
	if (param == undefined)
		numcheck = /[0-9\b\n]/;
	else
		numcheck = /[0-9.\b\n]/;
	return numcheck.test(keychar);
}
function changeTab(nr) {
	var currentTab = $('tab' + nr);
	var otherTab = $('tab' + (3 - nr));
	currentTab.style.display = 'block';
	otherTab.style.display = 'none';
	$('tabTitle' + nr).className = 'tab-head-act';
	$('tabTitle' + (3 - nr)).className = 'tab-head';
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
