var siteUrl = 'http://www.lf24.pl/';

var Hash = (function () {
var
window = this,
documentMode = document.documentMode,
history = window.history,
location = window.location,
callback, hash,
iframe,

getHash = function () {
    var index = location.href.indexOf('#');
    return (index == -1 ? '' : location.href.substr(index + 1));
},
poll = function () {
    var curHash = getHash();
    if (curHash != hash) {
        hash = curHash;
        callback(curHash, false);
    }
},
setIframe = function (newHash) {
    try {
        var doc = iframe.contentWindow.document;
        doc.open();
        doc.write('<html><body>' + newHash + '</body></html>');
        doc.close();
        hash = newHash;
    } catch (e) {
        setTimeout(function () { setIframe(newHash); }, 10);
    }
},
setUpIframe = function () {
    try {
        iframe.contentWindow.document;
    } catch (e) {
        setTimeout(setUpIframe, 10);
        return;
    }
    setIframe(hash);
    var data = hash;
    setInterval(function () {
        var curData, curHash;
        try {
            curData = iframe.contentWindow.document.body.innerText;
            if (curData != data) {
                data = curData;
                location.hash = hash = curData;
                callback(curData, true);
            } else {
                curHash = getHash();
                if (curHash != hash) setIframe(curHash);
            }
        } catch (e) {
        }
    }, 50);
};
return {
    init: function (cb, ifr) {
        if (callback) return;
        callback = cb;
        hash = getHash();
        cb(hash, true);
        if (window.ActiveXObject) {
            if (!documentMode || documentMode < 8) {
                iframe = ifr;
                setUpIframe();
            } else  {
                window.attachEvent('onhashchange', poll);
            }
        } else {
            if (history.navigationMode) history.navigationMode = 'compatible';
            setInterval(poll, 50);
        }
    },
    go: function (newHash) {
        if (newHash == hash) return;
        if (iframe) {
            setIframe(newHash);
        } else {
            location.hash = hash = newHash;
            callback(newHash, false);
        }
    }
};
})();

/* user START */
	var User = {
		resolutionX: screen.width,
		isIE6: false /*@cc_on || @_jscript_version < 5.7 @*/,
		isIE7: false /*@cc_on || @_jscript_version == 5.7 @*/,
		isIE8: false /*@cc_on || @_jscript_version > 5.7 @*/,
		isIE: false
	}
if(User.isIE6 || User.isIE7 || User.isIE8) User.isIE = true;
/* user END */

if(User.isIE8) {
  window.onhashchange = function() {
    historyChange(window.location.hash,null);
  }
} 

/* config START */
	var Config = {
		opisSkroconyWordLimit: 250,
		keywordLimit: 5,
		resolution: {
			a: 1280,
			b: 1500,
			c: 1680
		},
		cennikPakietow: {
			widoczny: 0,
			starter: 99,
			zloty: 199,
			platynowy: 399,
			diamentowy: 599
		},
		nazwyPakietow: {
			widoczny: 'Widoczny',
			starter: 'Starter',
			zloty: 'Złoty',
			platynowy: 'Platynowy',
			diamentowy: 'Diamentowy'
		},
		pakietKeywordLimit: {
			widoczny: 1,
			starter: 5,
			zloty: 10,
			platynowy: 20,
			diamentowy: 1000000
		},
		selectedPackage: 'starter',
		baseUrl: {
		    logo:siteUrl+'logo/',
		    foto: siteUrl+'prezentacje_firm/',
		    outWebsite: siteUrl+'out.php?id=',
			site: siteUrl,
			css: siteUrl+'css/',
			captcha: siteUrl,
		    searchUrl: siteUrl,
			images: siteUrl+'images/'
		},
		ajaxUrl: {
			baseUrl: siteUrl,
		    pobierzWgIdfi: siteUrl+'wyszukiwarka/getCompanyByIdfi.php?idfi=',
			sendMsgToCompany: siteUrl+'sendMsgToCompany.php',
			stat: siteUrl+'stat.php?id='
		},
		wyswietlanie: {
		    msgBox: {
		      nazwaFirmyLimit: 80
		    },
		    nazwaFirmyLimit: 70
		    
		},
		wyszukiwarka: {
		    wynikowNaStrone: 10
		}
	}
/* config END */

/* LF24 */
var Url = {
	encode : function (string) {
		return escape(this._utf8_encode(string)).replace('+','%2B');
	},
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
		for (var n = 0; n < string.length; n++) {
			var c = string.charCodeAt(n);
			if (c < 128) {
				if(c!=43) utftext += String.fromCharCode(c);
				else utftext+='+';
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
		}
		return utftext;
	},
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = 0; var c1 = 0; var c2 = 0;
		while ( i < utftext.length ) {
			c = utftext.charCodeAt(i);
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
		}
		return string;
	}
}
var Str = {
    CutTooLong: function(str,typ) {
	switch(typ) {
	    case 'serp': var limit = Config.wyswietlanie.nazwaFirmyLimit; break;
	    case 'msgbox': var limit = Config.wyswietlanie.msgBox.nazwaFirmyLimit; break;
	    default: var limit = Config.wyswietlanie.nazwaFirmyLimit; break;
	}
	if(str.length>limit) return ( str.substr(0,limit-6)+' (...)' );
	else return str;
    }
}
/* LF24 END*/

/* forms common START */
	function styleForm(formElement) {
		formElement.className="formErrorField";
	}

	function makeMeWhite(data) {
		data.style.backgroundColor = '#FFFFFF';
	}
/* form common END */


/* AJAX START */
	function getXMLHttpRequestObject() {
		try {
			return new XMLHttpRequest();
		} catch(e) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				return false;
			}
		}
	}
	
	var XMLHttpRequestObject  = getXMLHttpRequestObject();
/* AJAX END */

/* print START */
	var PrintCheckbox = {
		options: {
			print_przedmiotDzialalnosci: true,
			print_opisFirmy: true,
			print_galeriaZdjec: true,
			print_mapaDojazdu: true,
			print_kodQR: true
		},
		OptionsReset: function() {
			this.options.print_przedmiotDzialalnosci = true;
			this.options.print_opisFirmy = true;
			this.options.print_galeriaZdjec = true;
			this.options.print_mapaDojazdu = true;
			this.options.print_kodQR = true;
			var t = document.getElementsByClassName('drukujOpcjeNieaktywne');
			for(var i=0; i<t.length; i++) {
				document.getElementById(t[i].id).className = "drukujOpcje";
			}
		},
		Init: function() {
			this.OptionsReset(); //wywalić po wprowadzeniu cookie
			var t = document.getElementsByClassName('drukujOpcje');
			for(var i=0; i<t.length; i++) {
				if(this.options[t[i].id.replace(/_[0-9]/,'')] == false) {
					document.getElementById(t[i].id).firstChild.className = "checkboxUnChecked";
				}
			}
		},
		ChangeMe: function(data) {
			var id = data.id.replace(/_[0-9]/,'');
			var display = '';
			for(var i=1; i<=3; i++) {
				if(document.getElementById(id+'_'+i).firstChild.className == 'checkboxChecked') {
					this.options[id] = false;
					document.getElementById(id+'_'+i).firstChild.className = "checkboxUnChecked";
					display = 'none';
				} else {
					this.options[id] = true;
					document.getElementById(id+'_'+i).firstChild.className = "checkboxChecked";
					display = 'block';
				}
			}
			document.getElementById(id+'_module').style.display = display;
		},
		ShowHideModules: function() {
			document.getElementById('JS_wydruk_przedmiot_dzialanosci').innerHTML = LF24.Wizytowka.currentData.oferta;
			if(LF24.Wizytowka.currentData.oferta!='' && this.options['print_przedmiotDzialalnosci']==true) {
				document.getElementById('print_przedmiotDzialalnosci_module').style.display = 'block';
			} else {
				document.getElementById('print_przedmiotDzialalnosci_module').style.display = 'none';
			}
			
			document.getElementById('JS_wydruk_opis_firmy').innerHTML = LF24.Wizytowka.currentData.opis;
			if(LF24.Wizytowka.currentData.opis!='' && this.options['print_opisFirmy']==true) {
				document.getElementById('print_opisFirmy_module').style.display = 'block';
			} else {
				document.getElementById('print_opisFirmy_module').style.display = 'none';
			}
			if(LF24.Wizytowka.currentData.fotki!=null && LF24.Wizytowka.currentData.podpisy!=null  && LF24.Wizytowka.currentData.fotki.length>0 && LF24.Wizytowka.currentData.fotki.length==LF24.Wizytowka.currentData.podpisy.length) {
				document.getElementById('print_galeriaZdjec_module').style.display = 'block';
			} else {
				document.getElementById('print_galeriaZdjec_module').style.display = 'none';
			}
			((this.options['print_mapaDojazdu']==false || mapIsOK==false)?(document.getElementById('print_mapaDojazdu_module').style.display='none'):(document.getElementById('print_mapaDojazdu_module').style.display='block'));
			((this.options['print_kodQR']==false)?(document.getElementById('print_kodQR_module').style.display='none'):(document.getElementById('print_kodQR_module').style.display='block'));
		},
		Print: function(node) {
			if(User.isIE6 || User.isIE7) {
				window.print();
			} else {
				if(document.getElementById(node).innerHTML=='') node = 'printPreview';
				LF24.Wizytowka._renderujWyruk();
				marker.closeInfoWindow();
				map.removeControl(overview);
				document.getElementById('map_canvas_2').innerHTML = document.getElementById('map_canvas').innerHTML;
			
				var content=document.getElementById(node).innerHTML;
				var pwin = window.open('','print_content','width=500,height=500');
				pwin.document.open();
				var html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="pl" xml:lang="pl"><head><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/><link rel="stylesheet" href="'+Config.baseUrl.css+'style.css" type="text/css" /><link rel="stylesheet" href="'+Config.baseUrl.css+'dodajFirme.css" type="text/css" /><link rel="stylesheet" href="'+Config.baseUrl.css+'katalogFirm.css" type="text/css" /><link rel="stylesheet" href="'+Config.baseUrl.css+'msgBox_style.css" type="text/css" /></head><body onload="window.print()"><table id="msgBox"><tr><td>'+content+'</td></tr></table></body></html>';
				pwin.document.write(html);
				pwin.document.close();
				setTimeout(function(){pwin.close();},1000);
			}
		},
		EnableDisableCheckbox: function(checkbox,OnOff) {
			for(var i=1; i<=3; i++) {
				if(OnOff == 'Off') {
					document.getElementById(checkbox+'_'+i).className = "drukujOpcjeNieaktywne";
					document.getElementById(checkbox+'_'+i).onclick = PrintCheckbox.ZmienOnClick.Puste;
					document.getElementById(checkbox+'_'+i).firstChild.className = "checkboxDisabled";
				} else {
					document.getElementById(checkbox+'_'+i).className = "drukujOpcje";
					document.getElementById(checkbox+'_'+i).onclick = PrintCheckbox.ZmienOnClick.ChangeMe;
					if(this.options[checkbox]==true){	
						document.getElementById(checkbox+'_'+i).firstChild.className = "checkboxChecked";
					} else {
						document.getElementById(checkbox+'_'+i).firstChild.className = "checkboxUnChecked";
					}
				}
			}
		},
		ZmienOnClick: {
			Puste: function() {
				'';
			},
			ChangeMe: function() {
				PrintCheckbox.ChangeMe(this);
			}
		}
	}
/* print END */

/* msgBox START */
	var MsgBox = {
		title: 'LF24: Informacja',
		buttons: 'OK',
		width: '',
		observers: null,
		buttonAction: {
			OK: 'MsgBox.Close()',
			Cancel: 'MsgBox.Close()',
			Retry: 'MsgBox.Close()',
			Print: 'MsgBox.Close()',
			Save: 'MsgBox.Close()',
			Send: 'MsgBox.Close()',
			Reset: 'MsgBox.Close()',
			Remove: 'MsgBox.Close()',
			Help: 'MsgBox.Close()',
			Contact: 'MsgBox.Close()',
			Refresh: 'qrForm.RefreshImage()',
			Close: 'MsgBox.Close()'
		},
		buttonLabel: {
			OK: 'OK',
			Cancel: 'Anuluj',
			Retry: 'Ponów próbę',
			Print: 'Drukuj',
			Save: 'Zapisz',
			Send: 'Wyślij',
			Reset: 'Resetuj',
			Remove: 'Usuń',
			Help: 'Pomoc',
			Contact: 'Kontakt',
			Refresh: 'Odśwież',
			Close: 'Zamknij'
		},
		buttonStyle: {
			OK: 'b'
		},
		Show: function(msg,title,buttons) {
			var top = document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;
			if(title=='') title = this.title;
			if(buttons==null) buttons = this.buttons;
			this.AddButtons(buttons);
			document.getElementById('msg_box_naglowek').innerHTML = Str.CutTooLong(title,'msgbox');
			document.getElementById('msgBox_body_text_div').innerHTML = msg;
			
			//document.body.style.position = 'absolute';
			document.getElementById('msgBox_dimness').style.display = 'block';
			document.getElementById('msgBox_container').style.display = 'block';
			if(User.isIE6 || User.isIE7){
				var html = document.getElementsByTagName('html')[0];
				html.style.overflow = 'hidden';			
				scroll(0,0);
			} else document.body.style.overflow = 'hidden';
		},
		Close: function() {
			document.getElementById('div_msgbox_buttons').innerHTML = '';
			document.getElementById('msgBox_container').style.display = 'none';
			document.getElementById('msgBox_dimness').style.display = 'none';
			document.getElementById('msg_box_naglowek').innerHTML = '';
			document.getElementById('msgBox_drukujOpcje').style.display='none';
			
			//document.body.style.position = 'static';
			//document.body.style.height = 'auto';
			//document.body.style.width = 'auto';
			if(User.isIE6 || User.isIE7){
				var html = document.getElementsByTagName('html')[0];
				html.style.overflow = 'auto';
			} else document.body.style.overflow = 'auto';
		},
		Hide: function() {
			document.getElementById('msgBox_container').style.display = 'none';
			document.getElementById('div_msgbox_buttons').innerHTML = '';
			document.getElementById('msg_box_naglowek').innerHTML = '';
		},
		ShowWait: function() {
			document.getElementById('msgBox_table').style.marginLeft = '-100%';
		},
		HideWait: function() {
			document.getElementById('msgBox_table').style.marginLeft = '0%';
		},
		ShowWaitOnly: function(title) {
			document.getElementById('msgBox_dimness').style.display = 'block';
			document.getElementById('msgBox_container').style.display = 'block';
			document.getElementById('msg_box_naglowek').innerHTML = title;
			this.ShowWait();
		},
		ShowQR: function(title,company,tel,address,www) {
			if(title=='') title = 'LF24.pl - kod QR';
			this.Show(qrForm.html(company,tel,address,www),title,'Refresh,Close');
		},
		ShowPrintPreview: function() {
			this.Show(document.getElementById('printPreview').innerHTML,'Podgląd wydruku');
			LF24.Wizytowka._renderujWyruk();
			document.getElementById('msgBox_drukujOpcje').style.display='block';
			PrintCheckbox.ShowHideModules();
			marker.closeInfoWindow();
			map.removeControl(overview);
			document.getElementById('map_canvas_2').innerHTML = document.getElementById('map_canvas').innerHTML;
		},
		AddButtons: function(buttons) {
			buttons = buttons.split(',');
			//var area = document.getElementById('msgBox_buttons');
			var div = document.getElementById('div_msgbox_buttons');
			var tbHTML = '<table style="margin-left:auto; margin-right:auto;" ><tr id="msgBox_buttons">';
			for(i=0; i<buttons.length; i++) {
				tbHTML += this.CreateButtonHTML(buttons[i],this.buttonAction[buttons[i]]);
				if((i+1)!=buttons.length) tbHTML += '<td><span class="tab"></span></td>';
			}
			tbHTML+='</tr></table>';
			div.innerHTML = tbHTML;
		},
		CreateButtonHTML: function(label,action) {
			var id = label;
			label = this.buttonLabel[label];
			if(this.buttonStyle[id]) label = '<'+this.buttonStyle[id]+'>'+label+'</'+this.buttonStyle[id]+'>';
			if(!action) action = 'MsgBox.Close()';
			if(this.observers!=null && this.observers[id]!=undefined) action+='; '+this.observers[id];
			return '<td><table class="buttonRed" style="margin-left: auto; margin-right: auto;" onclick="'+action+'"><tr><td class="buttonRed_poczatek"></td><td class="buttonRed_srodek"><span class="tab"></span>'+label+'<span class="tab"></td><td class="buttonRed_koniec"></td></tr></table></td>';
		},
		Create: function() { return this; },
		onBtnClick: function(btn,code) {
		    
		    if(this.observers==null) this.observers = new Array();
		    this.observers[btn] = code;
		}
	}
/* msgBox END */

/* directions START */
var Directions = {
	startLocation: '',
	companyDetails: {},
	CheckStartLocation: function(idfi) {
		MsgBox.buttonAction.SaveDirections = 'Directions.SaveLocation(); Directions.ShowDirections();';
		MsgBox.buttonLabel.SaveDirections = 'Wyznacz trasę dojazdu';
		MsgBox.buttonStyle.SaveDirections = 'b';
		MsgBox.Show(this._GetForm(),'Podaj swoją lokalizację','SaveDirections');
		this._AssignCompanyDetails(idfi);
	},
	SaveLocation: function() {
		this.startLocation = document.getElementById('directions').value;
		Cookie.SetCookie('LF24_directions',this.startLocation,7);
		MsgBox.Close();
	},
	ShowDirections: function() {
		var target = this.companyDetails.ulica.replace(/\/.+?$/,'').replace(/^plut\./,'').replace(/m\..+?$/,'').replace(/lok\..+?$/,'').replace(/pok\..+?$/,'').replace(/p\..+?$/,'')+', '+this.companyDetails.kod_pocztowy+' '+this.companyDetails.miejscowosc;
		window.open(Config.baseUrl.site+'out.php?map=1&from='+this.startLocation+'&to='+target,'', 'menubar=no, toolbar=no, location=no, scrollbars=yes, resizable=yes, status=no, width=1100, height=600');
	},
	_GetForm: function() {
		if(this.startLocation=='') this.startLocation = Cookie.GetCookie('LF24_directions');
		var form = '<table class="contentTable">\
						<tr>\
							<td class="msgBox_form_subheader" colspan="3"><span>Wyznaczanie trasy dojazdu</span></td>\
						</tr>\
						<tr>\
							<td class="contentTable_first">Twoja lokalizacja (np. Gliwice, ul. Łużycka 16):</td>\
							<td colspan="2" class="contentTable_second"><input onblur="unHighlight(this,\'#ffffff\')" onfocus="highlight(this,\'#f9f0a8\')" onmouseout="unHighlight_border(this)" onmouseover="highlight_border(this)" onkeydown="makeMeWhite(this)" type="text" name="directions" id="directions" value="'+this.startLocation+'" /></td>\
						</tr>\
					</table>\
		';
		return form;
	},
	_AssignCompanyDetails: function(idfi) {
		if(idfi!=undefined){
			var dane = LF24.Wyszukiwarka.pobierzFirmeWgIdfi(idfi);
		} else {
			var dane = LF24.Wizytowka.currentData;
		}
		this.companyDetails.ulica = dane.ulica;
		this.companyDetails.miejscowosc = dane.miejscowosc;
		this.companyDetails.kod_pocztowy = dane.kod_pocztowy;
		if(dane.ulica==undefined) {
			this.companyDetails.ulica = document.getElementById('klient_ulica').innerHTML;
			this.companyDetails.miejscowosc = document.getElementById('klient_miejscowosc').innerHTML;
			this.companyDetails.kod_pocztowy = document.getElementById('klient_kod_pocztowy').innerHTML;
		}
	}
}
/* directions END */

/* cookie START */
var Cookie = {
	SetCookie: function(name,value,expireSec) {
		var expire = new Date();
		expire.setDate(expire.getDate()+expireSec);
		document.cookie=name+ "=" +escape(value)+";expires="+expire.toGMTString();
	},
	GetCookie: function(name) {
		if (document.cookie.length>0) {
			c_start=document.cookie.indexOf(name + "=");
			if (c_start!=-1) {
			c_start = c_start + name.length+1;
			c_end = document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
			}
		}
		return "";
	}
}
/* cookie END */

/* qr START */
var qrForm = {
	html: function(company,tel,address,www) {
		return '\
<!-- qrForm -->\
<table id="qr_table"><tbody><tr>\
<td>\
	<form id="formGetQRCode">\
	<table class="contentTable"><tbody>\
	<tr><td colspan="3" class="msgBox_form_subheader""><span>Dane do kodu QR</span> (poniższe pola moża edytować)</td></tr>\
	<tr><td class="contentTable_first">Nazwa firmy:</td><td class="contentTable_second"><textarea rows="3" name="qr_nazwa_firmy" id="qr_nazwa_firmy" onblur="unHighlight(this,\'#ffffff\')" onfocus="highlight(this,\'#f9f0a8\')" onmouseout="unHighlight_border(this)" onmouseover="highlight_border(this)" onkeydown="makeMeWhite(this)">'+company+'</textarea></td><td class="contentTable_third"></td></tr>\
	<tr><td class="contentTable_first">Telefon:</td><td class="contentTable_second"><input name="qr_telefon" id="qr_telefon" value="'+tel+'" type="text" onblur="unHighlight(this,\'#ffffff\')" onfocus="highlight(this,\'#f9f0a8\')" onmouseout="unHighlight_border(this)" onmouseover="highlight_border(this)" onkeydown="makeMeWhite(this)" /></td><td class="contentTable_third"></td></tr>\
	<tr><td class="contentTable_first">Adres:</td><td class="contentTable_second"><textarea rows="1" name="qr_adres" id="qr_adres" type="text" onblur="unHighlight(this,\'#ffffff\')" onfocus="highlight(this,\'#f9f0a8\')" onmouseout="unHighlight_border(this)" onmouseover="highlight_border(this)" onkeydown="makeMeWhite(this)">'+address+'</textarea></td><td class="contentTable_third"></td></tr>\
	<tr><td class="contentTable_first">WWW:</td><td class="contentTable_second"><input name="qr_www" id="qr_www" value="'+www+'" type="text" onblur="unHighlight(this,\'#ffffff\')" onfocus="highlight(this,\'#f9f0a8\')" onmouseout="unHighlight_border(this)" onmouseover="highlight_border(this)" onkeydown="makeMeWhite(this)" /></td><td class="contentTable_third"></td></tr>\
	</tbody></table>\
	<p>Po edycji proszę kliknąć przycisk <b>"Odśwież"</b>, aby pobrać nowy kod QR.</p>\
	</form>\
	</td>\
<td>\
	<img src="http://chart.apis.google.com/chart?cht=qr&chs=350x350&chl=MECARD%3AN%3A'+Url.encode(company)+'%3BTEL%3A'+Url.encode(tel)+'%3BURL%3A'+Url.encode(www)+'%3BADR%3A'+Url.encode(address)+'%3BNOTE%3ALF24.pl%3B%3B" id="qr_image" />\
	</td></tr></tbody></table>\
<!-- koniec qrForm -->';
	},
	RefreshImage: function () {
		var img = document.getElementById('qr_image');
		img.src = 'http://chart.apis.google.com/chart?cht=qr&chs=350x350&chl=MECARD%3AN%3A'+Url.encode(document.getElementById('qr_nazwa_firmy').value)+'%3BTEL%3A'+Url.encode(document.getElementById('qr_telefon').value)+'%3BURL%3A'+Url.encode(document.getElementById('qr_www').value)+'%3BADR%3A'+Url.encode(document.getElementById('qr_adres').value)+'%3BNOTE%3ALF24.pl%3B%3B';
	}
}
/* qr END */

/* TopFrame START */
var TopFrame = {
	DoSearch: function() {
		var co = document.getElementById('topFrame_slowoKluczowe').value;
		var gdzie = document.getElementById('topFrame_lokalizacja').value;
		return Config.baseUrl.searchUrl+'#!p=wyszukiwarka&co='+Url.encode(co)+'&gdzie='+Url.encode(gdzie);
	}
}
/* TopFrame END */

/* form add company START */
	var displayTipText = true;
	var formAddCompanyEmailOK = true;
	var termsRegulaminSerwisu = true;
	var termsInformacjeHandlowe = true;
	var formNewInvoiceAddress = false;

	function validateCompanyForm() {
		var form = document.forms['formAddCompany'];
		var isOK = false;
		var errorMsg = '';
		var kod_pattern = /^[0-9]{2}-[0-9]{3}$/;
		var rok_pattern = /^[0-9]{4}$/;
		var email_pattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;

		if(form.nazwaFirmy.value == '') {
			errorMsg += '<p class="msgBox_content_lista">nazwa firmy</p>';
			styleForm(form.nazwaFirmy);
		}
		if(form.osobaKontaktowa.value == '') {
			errorMsg += '<p class="msgBox_content_lista">osoba kontaktowa</p>';
			styleForm(form.osobaKontaktowa);
		}
		if((!email_pattern.test(form.emailKontaktowy.value))) {
			errorMsg += '<p class="msgBox_content_lista">kontaktowy adres email</p>';
			styleForm(form.emailKontaktowy);
		}
		if(form.opisSkrocony.value == 0) {
			errorMsg += '<p class="msgBox_content_lista">przedmiot działalności</p>';
			styleForm(form.opisSkrocony);
		}
		if(form.formaPrawna.value == 0) {
			errorMsg += '<p class="msgBox_content_lista">forma prawna</p>';
			styleForm(form.formaPrawna);
		}
		if(form.nip.value=='' || !checkNIP(form.nip)) {
			errorMsg += '<p class="msgBox_content_lista">NIP</p>';
			styleForm(form.nip);
		}
		if(form.regon.value=='' || !checkREGON(form.regon)) {
			errorMsg += '<p class="msgBox_content_lista">REGON</p>';
			styleForm(form.regon);
		}
		if((form.krs.value.length != 0) && (form.krs.value.length != 10)) {
			errorMsg += '<p class="msgBox_content_lista">numer KRS musi zawierać 10 cyfr</p>';
			styleForm(form.krs);
		}
		if(!rok_pattern.test(form.rokZalozenia.value)) {
			errorMsg += '<p class="msgBox_content_lista">rok założenia</p>';
			styleForm(form.rokZalozenia);
		}
		if(!kod_pattern.test(form.kodPocztowy.value)) {
			errorMsg += '<p class="msgBox_content_lista">kod pocztowy</p>';
			styleForm(form.kodPocztowy);
		}
		if(form.miejscowosc.value == '') {
			errorMsg += '<p class="msgBox_content_lista">miejscowość</p>';
			styleForm(form.miejscowosc);
		}
		if(form.wojewodztwo.value == 0) {
			errorMsg += '<p class="msgBox_content_lista">województwo</p>';
			styleForm(form.wojewodztwo);
		}
		if(form.ulica.value == '') {
			errorMsg += '<p class="msgBox_content_lista">ulica</p>';
			styleForm(form.ulica);
		}
		if(form.numerBudynku.value == '') {
			errorMsg += '<p class="msgBox_content_lista">numer budynku</p>';
			styleForm(form.numerBudynku);
		}
		if(form.telefon.value == '') {
			errorMsg += '<p class="msgBox_content_lista">numer telefonu</p>';
			styleForm(form.telefon);
		}
		if(form.email.value!='' && !email_pattern.test(form.email.value)) {
			errorMsg += '<p class="msgBox_content_lista">email jest niepoprawny</p>';
			styleForm(form.email);
		}
		if(!formAddCompanyEmailOK && email_pattern.test(form.email.value)) {
			errorMsg += '<p class="msgBox_content_lista">podany adres E-mail istnieje w bazie danych</p>';
			styleForm(form.email);
		}
		if((form.kategoria1.value == 0) && (form.kategorie.value == '')) {
			errorMsg += '<p class="msgBox_content_lista">kategoria</p>';
			styleForm(form.kategoria1);
		}
		if((form.kategoria2.value == 0) && (form.kategorie.value == '')) {
			errorMsg += '<p class="msgBox_content_lista">podkategoria</p>';
			styleForm(form.kategoria2);
		}
		if((form.slowaKluczowe.value == '') && (form.slowa_kluczowe.value == '')) {
			errorMsg += '<p class="msgBox_content_lista">słowa kluczowe</p>';
			styleForm(form.slowaKluczowe);
		}
		if(form.input_zgoda_akceptacjaRegulaminu.value == 'false') {
			errorMsg += '<p class="msgBox_content_lista">akceptacja regulaminu jest obowiązkowa</p>';
		}
		if(form.faktura_inneDaneWysylki.value == 'true') {
			if(form.faktura_nazwa.value == '') {
				errorMsg += '<p class="msgBox_content_lista">nazwę do wysyłki faktury</p>';
				styleForm(form.faktura_nazwa);
			}
			if(form.faktura_kodPocztowy.value == '') {
				errorMsg += '<p class="msgBox_content_lista">kod pocztowy do wysyłki faktury</p>';
				styleForm(form.faktura_kodPocztowy);
			}
			if(form.faktura_miejscowosc.value == '') {
				errorMsg += '<p class="msgBox_content_lista">miejscowość do wysyłki faktury</p>';
				styleForm(form.faktura_miejscowosc);
			}
			if(form.faktura_ulica.value == '') {
				errorMsg += '<p class="msgBox_content_lista">ulicę do wysyłki faktury</p>';
				styleForm(form.faktura_ulica);
			}
			if(form.faktura_numerBudynku.value == '') {
				errorMsg += '<p class="msgBox_content_lista">numer budynku do wysyłki faktury</p>';
				styleForm(form.faktura_numerBudynku);
			}
		}
		if(errorMsg == '') isOK = true;
		if(errorMsg != '') errorMsg = '<p class="msgBox_content_h">Niepoprawnie wypełnione pola:</p>' + errorMsg;
		if(!isOK) MsgBox.Show(errorMsg,'LF24: Proszę poprawić błędy w formularzu','OK');
		if(isOK) MsgBox.ShowWaitOnly('Trwa zapisywanie danych...');
		return isOK;
	}

	function highlight(data,color) {
		data.parentNode.parentNode.style.backgroundColor=color;
		highlight_border(data);
		if(data.className == "formErrorField"){
			if(data.type!=undefined && data.type=="text") data.className = "input_text";
			else data.className="";
		}
	}
		
	function unHighlight(data,color) {
		data.parentNode.parentNode.style.backgroundColor=color;	
		unHighlight_border(data);
	}	
		
	function highlight_border(data) {
		data.style.borderBottom='1px solid #c7e2f1';
		data.style.borderLeft='1px solid #c5daed';
		data.style.borderRight='1px solid #c5daed';
		data.style.borderTop='1px solid #5794bf';
	}
		
	function unHighlight_border(data) {
		data.style.borderBottom='1px solid #e3e9ef';
		data.style.borderLeft='1px solid #e2e3ea';
		data.style.borderRight='1px solid #dbdfe6';
		data.style.borderTop='1px solid #abadb3';
	}
	
	function getHelpText(tipId) {
		      var helpText = '';
		      switch(tipId) {
			      case 'kodPocztowy':
				      helpText = '<p>Kod pocztowy:</p>Proszę podać kod pocztowy w formacie xx-xxx, np. 41-800';
				      break;
			      case 'ulica':
				      helpText = '<p>Ulica:</p>Proszę podać nazwę ulicy z rodzajnikiem, np.<br />ul. Tadeusza Kościuszki<br />pl. Piastów';
				      break;
			      case 'telefon':
				      helpText = '<p>Numer telefonu:</p>Proszę podać numer telefonu w formacie 48xxxxxxxxx,<br />np. 48123456789';
				      break;
			      case 'email':
				      helpText = '<p>Adres e-mail:</p>Podany adres email <b>nie będzie</b> widoczny dla użytkowników serwisu.<br />Do kontaktu z Państwem będzie służył formularz kontaktowy.';
				      break;
			      case 'slowaKluczowe':
				      helpText = '<p>Słowa kluczowe:</p>Słowa kluczowe będą brane pod uwagę podczas wyszukiwania.<br />Proszę wpisywać je w podstawowej formie (mianowniku), np.<i><br />telefon<br />zestaw komputerowy<br />internet</i>';
				      break;
			      case 'opisFirmy':
				      helpText = '<p>Opis firmy:</p>Proszę podać szczegółowy opis Państwa firmy.<br />Wprowadzone informacje będą miały wpływ na skuteczność wyszukiwania Państwa firmy w serwisie LF24.pl';
				      break;
			      case 'opisSkrocony':
				      helpText = '<p>Przedmiot działalności:</p>Podany przez Państwa przedmiot działalności będzie wyświetlany w wynikach wyszukiwania.<br /><br />Limit znaków: '+Config.opisSkroconyWordLimit+'.';
				      break;
			      case 'slowoKluczowePremium':
				      helpText = '<p>Słowa kluczowe PREMIUM:</p>Słowo kluczowe PREMIUM <b>gwarantuje</b> wysoką pozycję w wynikach wyszukiwania.<br />Przykłady:<br /><i>cegły</i><br /><i>telefony komórkowe</i>';
				      break;
		      }
		      return helpText;
	}
	
	function displayTipInMsgBox(tipId) {
	    if((User.isIE6 || User.isIE7))  {
		  var helpText = getHelpText(tipId);
		  alert(helpText);
	    }
	}
	
	/*function displayTipInMsgBox(event,data) {
	    
	    
	  
	}*/

	function displayFormTipText(event,data) {
		if(! (User.isIE6 || User.isIE7)) {
		      var formTip = document.getElementById('formTip');
		      H = formTip.offsetHeight;
		      W = formTip.offsetWidth;
		      var left = event.clientX+40;
		      var top = event.clientY+10;
		      var helpText = getHelpText(data.className);
		      if(displayTipText) {
			      formTip.innerHTML = helpText;
			      formTip.style.left = left+'px';
			      formTip.style.top = top+'px';
			      formTip.style.display = 'block';
			      //formTip.style.visibility = 'visible';
		      }
		} else {
			var inputElement = document.getElementById(data.className);
			if(inputElement.disableTip==undefined || inputElement.disableTip == false) {
			    var cleft = event.clientX+40;
			    var ctop = event.clientY+10;
			    ctop+= document.documentElement.scrollTop;
			    var tip = document.getElementById('formTip');
			    //alert(tip.style.top);
			    tip.style.position = 'absolute';
			    tip.style.top = (ctop)+'px';
			    tip.style.left = (cleft)+'px';
			    //tip.style.width = "300px";
			    //tip.style.height = "200px";
			    //tip.style.zIndex = 1000;
			    tip.style.display = 'block';
			    var nc = document.getElementById('newcontent');
			    nc.innerHTML = getHelpText(data.className);
			    
			    if(inputElement.disabled == false && data.className!='opisFirmy') inputElement.focus();
			    inputElement.onkeydown = function() { inputElement.disableTip = true; }
			    inputElement.onkeyup = function() { inputElement.disableTip = false; }
			}
		}
		
	}

	function noDisplayFormTipText() {
		document.getElementById('formTip').style.display='none';
	}
if (User.isIE6 || User.isIE7) document.onkeydown = "alert('baba')";

	function checkNIP(data) {
		var isOK = true;
		var nip = data.value;
		var nip_pattern = /^[0-9]{10}$/;
		nip = nip.replace(/ /g,'');
		nip = nip.replace(/-/g,'');
		nip = nip.replace(/[^0-9]/g,'');
		if((nip.length != 10) || !nip_pattern.test(nip)) {
			isOK = false;
		} else {
			var checksum = nip.charAt(0)*6+nip.charAt(1)*5+nip.charAt(2)*7+nip.charAt(3)*2+nip.charAt(4)*3+nip.charAt(5)*4+nip.charAt(6)*5+nip.charAt(7)*6+nip.charAt(8)*7;
			if(!((checksum%11)%10 == nip.charAt(9))) isOK = false;
		}
		if(data.value == '') isOK = false;
		//if(error) msgBox('Podany numer NIP jest niepoprawny!');
		if(!isOK) styleForm(document.getElementById('nip'));
		return isOK;
	}

	function checkREGON(data) {
		var isOK = true;
		var regon = data.value;
		var regon_pattern9 = /^[0-9]{9}$/;
		regon = regon.replace(/ /g,'');
		regon = regon.replace(/-/g,'');
		regon = regon.replace(/[^0-9]/g,'');
		if((regon.length != 9) || !regon_pattern9.test(regon)) {
			isOK = false;
		} else {
			var checksum = regon.charAt(0)*8+regon.charAt(1)*9+regon.charAt(2)*2+regon.charAt(3)*3+regon.charAt(4)*4+regon.charAt(5)*5+regon.charAt(6)*6+regon.charAt(7)*7;
			if(!((checksum%11)%10 == regon.charAt(8))) isOK = false;
		}
		if(data.value == '') isOK = false;
		//if(error) msgBox('Podany numer REGON jest niepoprawnyy!');
		if(!isOK) styleForm(document.getElementById('regon'));
		return isOK;
	}

	function checkKodPocztowy(data) {
		var error = false;
		var kod = data.value;
		kod = kod.replace(/ /g,'');
		var kod_pattern = /^[0-9]{2}-[0-9]{3}$/;
		//if(!kod_pattern.test(kod) && (data.value != '')) msgBox('Podany kod pocztowy jest niepoprawny!\nProszę podać kod pocztowy w formacie xx-xxx, np. 41-800');
		if(!kod_pattern.test(kod) && (data.value != '')) styleForm(document.getElementById('kodPocztowy'));
	}

	function checkKRS(data) {
		var KRS = data.value;
		//if((KRS.length != 0) && (KRS.length != 10)) msgBox('Numer KRS musi zawierać 10 cyfr, np. 0000012345');
		if((KRS.length != 0) && (KRS.length != 10)) styleForm(document.getElementById('krs'));
	}

	function checkUlica(data) {
		var ulica = data.value;
		//if((KRS.length != 0) && (KRS.length != 10)) msgBox('Numer KRS musi zawierać 10 cyfr, np. 0000012345');
		if((ulica.length < 3)) styleForm(document.getElementById('ulica'));
	}

	function checkNumerBudynku(data) {
		var numerBudynku = data.value;
		//if((KRS.length != 0) && (KRS.length != 10)) msgBox('Numer KRS musi zawierać 10 cyfr, np. 0000012345');
		if((numerBudynku ==  '')) styleForm(document.getElementById('numerBudynku'));
	}

	function checkEmail(data) {
		var email_pattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		if(!email_pattern.test(data.value) && (data.value.length != 0)) styleForm(document.getElementById(data.id));
		//getAjaxData(data);
	}

	function checkYear(data) {
		var error = false;
		var year = data.value;
		if(year.length != 4) error = true;
		//if(error) msgBox('Proszę wprowadzić rok w formacie xxxx, np. 2003');
		if(error) styleForm(document.getElementById('rokZalozenia'));
	}

	function makeGG(data) {
		data.style.background = '#FFFFFF url("ht'+'tp'+'://'+'status.gadu-gadu.pl/users/status.asp?id='+data.value+'") no-repeat scroll 293px 0px';
	}

	function makeSkype(data) {
		data.style.background = '#FFFFFF url("http://mystatus.skype.com/smallicon/'+data.value+'") no-repeat scroll 295px 1px';
	}

	function removeMiejscowoscTip(data) {
		if(data.value.length >= 3) noDisplayMiejscowoscTipText();
	}

	function addCategory() {	
		var wybrane_kategorie = document.getElementById('wybrane_kategorie');
		var nazwaKategorii = document.getElementById('kategoria1');
		nazwaKategorii = nazwaKategorii[nazwaKategorii.selectedIndex].text;
		var nazwaPodkategorii = document.getElementById('kategoria2');
		nazwaPodkategorii = nazwaPodkategorii[nazwaPodkategorii.selectedIndex].text;
		var idPodkategorii = document.getElementById('kategoria2');
		idPodkategorii = idPodkategorii[idPodkategorii.selectedIndex].value;
		if(isCurrentCategorySelected(idPodkategorii,nazwaPodkategorii)) {
			var inputWybraneKategorie = document.getElementById('kategorie');
			inputWybraneKategorie.value += idPodkategorii+';';
			wybrane_kategorie.innerHTML += '<ul id="wybrane_kategorie_'+idPodkategorii+'"><li><button class="wybrane_kategorie_strzalka" disabled="disabled"></button></li><li class="wybrane_kategorie_nazwa"><span class="wybrane_kategorie_kategoria">'+nazwaKategorii+'</span><img class="wybrane_kategorie_strzalka" src="images/wybrane_kategorie_strzalka.png" /><span class="wybrane_kategorie_podkategoria">'+nazwaPodkategorii+'</span></li><li><button type="button" class="wybrane_kategorie_usun_but" onmousedown="removeCategory('+idPodkategorii+');"></button></li></ul>';
		}
	}

	function isCurrentCategorySelected(idPodkategorii,nazwaPodkategorii) {
		var inputWybraneKategorie = document.getElementById('kategorie').value;
		var wybraneKategorie = inputWybraneKategorie.split(';');
		var ret = true;
		if(wybraneKategorie.length > 1) {
			for(i=0; i<wybraneKategorie.length; i++) {
				if(wybraneKategorie[i] == idPodkategorii) ret = false;
			}
		}
		if(idPodkategorii == 0) ret = false
		if(!ret && (idPodkategorii != 0)) MsgBox.Show('Podkategoria "'+nazwaPodkategorii+'" została już dodana.','','OK');
		if(!ret && (idPodkategorii == 0)) MsgBox.Show('Proszę wybrać podkategorię.','','OK');
		return ret;
	}

	function removeCategory(idPodkategorii) {
		var inputWybraneKategorie = document.getElementById('kategorie');
		wybraneKategorie = inputWybraneKategorie.value.split(';');
		inputWybraneKategorie.value = '';
		if(wybraneKategorie.length >= 1) {
			for(i=0; i<wybraneKategorie.length; i++) {
				if((wybraneKategorie[i] != idPodkategorii) && (wybraneKategorie[i] != '')) {
					inputWybraneKategorie.value += wybraneKategorie[i]+';';
				} else if((wybraneKategorie[i] == idPodkategorii) && (wybraneKategorie[i] != '')) {
					var html = document.getElementById('wybrane_kategorie_'+idPodkategorii);
					html.parentNode.removeChild(html);
				}
			}
		}
	}

	function addKeyword() {
		// var slowoKluczowe = document.getElementById('slowaKluczowe');
		// var wybraneSlowaKluczowe = document.getElementById('wybrane_slowa_kluczowe');
		// if(isKeywordAdded(slowoKluczowe.value)) {
			// var inputSlowaKluczowe = document.getElementById('slowa_kluczowe');
			// inputSlowaKluczowe.value += slowoKluczowe.value+';';
			// alert(slowoKluczowe.value.replace(/[;\"\']/g,' '));
			// wybraneSlowaKluczowe.innerHTML += '<ul id="wybrane_kategorie_'+slowoKluczowe.value+'"><li><button class="wybrane_kategorie_strzalka" disabled="disabled"></button></li><li class="wybrane_kategorie_nazwa"><span class="wybrane_kategorie_kategoria">'+slowoKluczowe.value+'</span></li><li><button type="button" class="wybrane_kategorie_usun_but" onmousedown="removeKeyword(\''+slowoKluczowe.value+'\');"></button></li></ul>';
		// }
		// slowoKluczowe.value='';
		var slowoKluczowe = document.getElementById('slowaKluczowe');
		var wybraneSlowaKluczowe = document.getElementById('wybrane_slowa_kluczowe');
		var slowoKluczoweValue = slowoKluczowe.value.replace(/[;\"\']/g,' ');
		if(isKeywordAdded(slowoKluczowe.value)) {
			var inputSlowaKluczowe = document.getElementById('slowa_kluczowe');
			inputSlowaKluczowe.value += slowoKluczoweValue+';';
			wybraneSlowaKluczowe.innerHTML += '<ul id="wybrane_kategorie_'+slowoKluczoweValue+'"><li><button class="wybrane_kategorie_strzalka" disabled="disabled"></button></li><li class="wybrane_kategorie_nazwa"><span class="wybrane_kategorie_kategoria">'+slowoKluczoweValue+'</span></li><li><button type="button" class="wybrane_kategorie_usun_but" onmousedown="removeKeyword(\''+slowoKluczoweValue+'\');"></button></li></ul>';
		}
		slowoKluczowe.value='';
	}

	function isKeywordAdded(keyword) {
		var inputSlowaKluczowe = document.getElementById('slowa_kluczowe').value;
		var wybraneSlowakluczowe = inputSlowaKluczowe.split(';');
		var ret = true;
		if(wybraneSlowakluczowe.length > 1) {
			for(i=0; i<wybraneSlowakluczowe.length; i++) {
				if(wybraneSlowakluczowe[i] == keyword) ret = false;
			}
		}
		if(wybraneSlowakluczowe.length > Config.pakietKeywordLimit[Config.selectedPackage]) {
			ret = false;
			var limitExceeded = true;
			MsgBox.Show('W wybranym przez Państwa pakiecie można dodać maksymalnie '+Config.pakietKeywordLimit[Config.selectedPackage]+' słów kluczowych','','OK');
		}
		if(keyword == '') ret = false
		if(!ret && (keyword != '') && !limitExceeded) MsgBox.Show('Słowo kluczowe "'+keyword+'" zostało już dodane','','OK');
		if(!ret && (keyword == '')) MsgBox.Show('Proszę wpisac słowo kluczowe.','','OK');
		return ret;
	}

	function removeKeyword(slowoKluczowe) {
		var inputWybraneSlowaKluczowe = document.getElementById('slowa_kluczowe');
		var wybraneSlowaKluczowe = inputWybraneSlowaKluczowe.value.split(';');
		inputWybraneSlowaKluczowe.value = '';
		if(wybraneSlowaKluczowe.length >= 1) {
			for(i=0; i<wybraneSlowaKluczowe.length; i++) {
				if((wybraneSlowaKluczowe[i] != slowoKluczowe) && (wybraneSlowaKluczowe[i] != '')) {
					inputWybraneSlowaKluczowe.value += wybraneSlowaKluczowe[i]+';';
				} else if((wybraneSlowaKluczowe[i] == slowoKluczowe) && (wybraneSlowaKluczowe[i] != '')) {
					var html = document.getElementById('wybrane_kategorie_'+slowoKluczowe);
					html.parentNode.removeChild(html);
				}
			}
		}
		checkKeywordList();
	}

	function submitMe() {
		if(document.formAddCompany.onsubmit()) {
			document.formAddCompany.submit();
		}
	}

	function setMiejscowoscWojewodztwo(miejscowosc,wojewodztwo) {
		document.getElementById('miejscowosc').value = miejscowosc;
		document.getElementById('wojewodztwo').value = wojewodztwo;
		noDisplayMiejscowoscTipText();
	}

	function noDisplayMiejscowoscTipText() {
			document.getElementById('miejscowoscTip_kontener').style.display = 'none';
			displayTipText = true;
	}

	function textCounter(field) {
		var maxlimit = Config.opisSkroconyWordLimit;
		if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit);
	}

	function getAjaxData(data) {
		if(XMLHttpRequestObject) {
			var serviceUrl = Config.ajaxUrl.baseUrl;
			var errorMsg = '';
			switch(data.name) {
				case 'kodPocztowy':
					var baseLink = serviceUrl+'getKodPocztowy.php?';
					var link = 'kod='+data.value;
					var miejscowosc = document.getElementById('miejscowosc');
					var wojewodztwo = document.getElementById('wojewodztwo');
					break;
				case 'kategoria1':
					var baseLink = serviceUrl+'getCategories.php?';
					var link = 'k='+data.value;
					var kategoria = document.getElementById('kategoria1');
					var podkategoria = document.getElementById('kategoria2');
					for(j=podkategoria.length-1;j>=0;j--) podkategoria.options[j] = null;
					podkategoria.options[0] = new Option('Wczytuję dane, proszę czekać...',0);
					podkategoria.disabled = true;
					break;
				case 'email':
					var baseLink = serviceUrl+'checkEmail.php?';
					var link = 'e='+data.value;
					var email = document.getElementById('email');
					break;
			}
			XMLHttpRequestObject.open("GET",baseLink+link);
			XMLHttpRequestObject.onreadystatechange = function() {
				if((XMLHttpRequestObject.readyState == 4) && (XMLHttpRequestObject.status == 200)) {
					if(XMLHttpRequestObject.responseText != 0) {
						switch(data.name) {
							case 'kodPocztowy':
								var dane = XMLHttpRequestObject.responseText.split(';');
								if(dane[0] == 1) {
									setMiejscowoscWojewodztwo(dane[1],dane[2])
								} else if(dane[0]>1) {
									var html = '<div class="miejscowoscTip_naglowek"><button type="button" lass="miejscowoscTip_zamknij" onclick="noDisplayMiejscowoscTipText()">zamknij [x]</button></div><div class="miejscowoscTip"><p>Proszę wybrać miejscowość z listy lub wpisać ją powyżej:</p>';
									var ptr = 1;
									for(i=0; i<dane[0]; i++) {
										html += '<button type="button" onclick="setMiejscowoscWojewodztwo(\''+dane[ptr]+'\',\''+dane[ptr+1]+'\')">'+dane[ptr]+'</button>';
										ptr += 2;
									}
									html += '</div><div class="miejscowoscTip_stopka"><p>Bazę kodów pocztowych dostarcza<br /><button type="button" onclick="window.open(\'http://www.BazaKodowPocztowych.pl\',\'_blank\');" >Baza Kódow Pocztowych .pl</button></p></div>';
									var miejscowoscTip = document.getElementById('miejscowoscTip_kontener');
									miejscowoscTip.innerHTML = html;
									miejscowoscTip.style.left = miejscowosc.offsetLeft+'px';
									miejscowoscTip.style.top = miejscowosc.offsetTop+25+'px';
									miejscowoscTip.style.display = 'block';
									displayTipText = false;
									noDisplayFormTipText();
								}
								break;
							case 'kategoria1':
								var dane = XMLHttpRequestObject.responseText.split(';');
								var ptr = 1;
								podkategoria.options[0] = new Option("Proszę wybrać...",0);
								for(i=0; i<dane[0]; i++) {
									podkategoria.options[podkategoria.options.length] = new Option(dane[ptr+1],dane[ptr]);
									ptr+=2;
								}
								podkategoria.disabled = false;
								break;
							case 'email':
								var dane = XMLHttpRequestObject.responseText;
								if(dane == '0;') {
									formAddCompanyEmailOK = true;
								} else {
									formAddCompanyEmailOK = false;
								}
								break;
						}
					}
				}
				//if(((XMLHttpRequestObject.readyState == 2)) && ((XMLHttpRequestObject.status == 400) || (XMLHttpRequestObject.status == 403) || (XMLHttpRequestObject.status == 404) || (XMLHttpRequestObject.status == 500)) ) {
					//alert('Wystąpił błąd transmisji ('+XMLHttpRequestObject.status+')');
			}
			XMLHttpRequestObject.send(null);
		}
	}

	function selectPackage(data) {
		var pakiet = data.id.replace('pakiet_', '');
		var selectedPackage = document.getElementById('selectedPackage');
		if(pakiet==selectedPackage.value) return;
		document.getElementById('wybranyPakiet').innerHTML = Config.nazwyPakietow[pakiet];
		document.getElementById('cenaPakietu').innerHTML = Config.cennikPakietow[pakiet];
		document.getElementById(data.id).className = 'buttonGrey_wybrany';
		//document.getElementById(data.id+'_select').innerHTML = 'Wybrano';
		var pakiet_ = 'pakiet_'+selectedPackage.value;
		document.getElementById(pakiet_).className = 'buttonGrey';
		//document.getElementById(pakiet_+'_select').innerHTML = 'Wybierz';
		selectedPackage.value = pakiet;
		var slowoKluczowePremium = document.getElementById('slowoKluczowePremium');
		if (pakiet=='diamentowy') {
			slowoKluczowePremium.disabled = false;
			slowoKluczowePremium.className = "input_text";
		} else {
			slowoKluczowePremium.disabled = true;
			slowoKluczowePremium.className = "input_text_disabled";
		}
		Config.selectedPackage = pakiet;
		checkKeywordList();
	}
	
	function checkKeywordList() {
		var listaSlow = document.getElementById('wybrane_slowa_kluczowe').childNodes;
		for(i=1; i<listaSlow.length; i++) {
			if(document.getElementById(listaSlow[i].id)!=null) document.getElementById(listaSlow[i].id).style.background="";
		}
		for(i=1; i<listaSlow.length; i++) {
			if(document.getElementById(listaSlow[i].id)==null) continue;
			if((i-1)>=Config.pakietKeywordLimit[Config.selectedPackage]) document.getElementById(listaSlow[i].id).style.background="grey";
		}
	}
	
	function termsChange(data) {
		if(data.id=='zgoda_akceptacjaRegulaminu') {
			if(termsRegulaminSerwisu==true) {
				data.firstChild.className = 'checkboxUnChecked';
				termsRegulaminSerwisu = false;
				document.getElementById('input_zgoda_akceptacjaRegulaminu').value = 'false';
			} else {
				data.firstChild.className = 'checkboxChecked';
				termsRegulaminSerwisu = true; 
				document.getElementById('input_zgoda_akceptacjaRegulaminu').value = 'true';
			}
		} else { 
			if(termsInformacjeHandlowe==true) {
				data.firstChild.className = 'checkboxUnChecked';
				termsInformacjeHandlowe = false;
				document.getElementById('input_zgoda_informacjeHandlowe').value = 'false';
			} else {
				data.firstChild.className = 'checkboxChecked';
				termsInformacjeHandlowe = true; 
				document.getElementById('input_zgoda_informacjeHandlowe').value = 'true';
			}
		}		
	}
	
	function invoiceAddress(data) {
		if(data.id == 'faktura_inneDaneWysylki_checkbox') {
			if(formNewInvoiceAddress == false) {
				data.firstChild.className = 'checkboxChecked';
				formNewInvoiceAddress = true;
				document.getElementById('faktura_inneDaneWysylki').value = 'true';
				document.getElementById('faktura_inneDaneWysylki_div').style.display = 'block';
				var form = document.forms['formAddCompany'];
				form.faktura_nazwa.value = form.nazwaFirmy.value;
				form.faktura_kodPocztowy.value = form.kodPocztowy.value;
				form.faktura_miejscowosc.value = form.miejscowosc.value;
				form.faktura_ulica.value = form.ulica.value;
				form.faktura_numerBudynku.value = form.numerBudynku.value;
				form.faktura_numerLokalu.value = form.numerLokalu.value;
				form.faktura_wojewodztwo.value = form.wojewodztwo.value;
			} else {
				data.firstChild.className = 'checkboxUnChecked';
				formNewInvoiceAddress = false;
				document.getElementById('faktura_inneDaneWysylki').value = 'false';
				document.getElementById('faktura_inneDaneWysylki_div').style.display = 'none';
			}
		}
	}
	
	
/* form add company END */

/* nawigacja START */
	if(!window.Node){
	  var Node = {ELEMENT_NODE : 1, TEXT_NODE : 3};
	}

	function checkNode(node, filter){
	  return (filter == null || node.nodeType == Node[filter] || node.nodeName.toUpperCase() == filter.toUpperCase());
	}

	function getChildren(node, filter){
	  var result = new Array();
	  if(node!=null) {
		  var children = node.childNodes;
		  for(var i = 0; i < children.length; i++){
			if(checkNode(children[i], filter)) result[result.length] = children[i];
		  }
		}
	  return result;
	}

	function getChildrenByElement(node){
	  return getChildren(node, "ELEMENT_NODE");
	}

	function getFirstChild(node, filter){
	  var child;
	  var children = node.childNodes;
	  for(var i = 0; i < children.length; i++){
		child = children[i];
		if(checkNode(child, filter)) return child;
	  }
	  return null;
	}

	function getFirstChildByText(node){
	  return getFirstChild(node, "TEXT_NODE");
	}

	function getNextSibling(node, filter){
	  for(var sibling = node.nextSibling; sibling != null; sibling = sibling.nextSibling){
		if(checkNode(sibling, filter)) return sibling;
	  }
	  return null;
	}
	
	function getNextSiblingByElement(node){
			return getNextSibling(node, "ELEMENT_NODE");
	}

	var activeMenu = null;

	function showMenu() {
	  if(activeMenu){
		activeMenu.className = "";
		getNextSiblingByElement(activeMenu).style.display = "none";
	  }
	  if(this == activeMenu){
		activeMenu = null;
	  } else {
		this.className = "active";
		getNextSiblingByElement(this).style.display = "block";
		activeMenu = this;
		getAjaxDataNav('k'+this.parentNode.id);
	  }
	  return false;
	}

	function hideMenu() {
	  if(activeMenu){
		activeMenu.className = "";
		getNextSiblingByElement(activeMenu).style.display = "none";
	  }
	  if(this == activeMenu){
		activeMenu = null;
	  }
	  return false;
	}

	function initMenu(){
	  var menus, menu, text, a, i;
	  menus = getChildrenByElement(document.getElementById("main_lewaKolumna_navigation3"));
	  for(i = 0; i < menus.length-1; i++){
		menu = menus[i];
		text = getFirstChildByText(menu);
		a = document.createElement("a");
		menu.replaceChild(a, text);
		a.appendChild(text);
		a.href = "#";
		a.onclick = showMenu;
		a.onfocus = function(){this.blur()};
	  }
	}

	//if(document.createElement) window.onload = initMenu;

	function getAjaxDataNav(kategoria) {
		if(XMLHttpRequestObject) {
			var serviceUrl = '';
			var errorMsg = '';
			if(kategoria[0] == 'k') {
				var baseLink = serviceUrl+'getCompaniesByCategoryId.php?';
				var link = 'k='+kategoria;
			} else {
				var baseLink = serviceUrl+'getCompaniesBySubCategoryId.php?';
				var link = 'k='+kategoria;
			}
			XMLHttpRequestObject.open("GET",baseLink+link);
			XMLHttpRequestObject.onreadystatechange = function() {
				if((XMLHttpRequestObject.readyState == 4) && (XMLHttpRequestObject.status == 200)) {
					if(XMLHttpRequestObject.responseText != 0) {
						if(kategoria[0] == 'k') {
							var dane = XMLHttpRequestObject.responseText.split(';');
							var tekst='';
							for(i=1; i<=dane[0]; i++) {
								tekst += dane[i]+"\n";
							}
							alert('Firmy należące do kategorii:\n'+tekst);
						} else {
							var dane = XMLHttpRequestObject.responseText.split(';');
							var tekst='';
							for(i=1; i<=dane[0]; i++) {
								tekst += dane[i]+"\n";
							}
							alert('Firmy należące do podkategorii:\n'+tekst);
						}
					}
				}
				if(((XMLHttpRequestObject.status == 400) || (XMLHttpRequestObject.status == 403) || (XMLHttpRequestObject.status == 404) || (XMLHttpRequestObject.status == 500)) && ((XMLHttpRequestObject.readyState == 2))) {
					alert('Wystąpił błąd transmisji ('+XMLHttpRequestObject.status+')');
				}
			}
			XMLHttpRequestObject.send(null);
		}
	}
/* nawigacja END */

/* msg to company START */
	var MsgToCompany = {
		msgToCompanyIsOK: false,
		SendMsgToCompany: function() {
			if(XMLHttpRequestObject && this.msgToCompanyIsOK) {
				MsgBox.ShowWait();
				//var baseLink ='sendMsgToCompany.php';
				var baseLink = Config.ajaxUrl.sendMsgToCompany;
				XMLHttpRequestObject.open("POST",baseLink);
				XMLHttpRequestObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				XMLHttpRequestObject.onreadystatechange = function() {
					if((XMLHttpRequestObject.readyState == 4) && (XMLHttpRequestObject.status == 200)) {
						if(XMLHttpRequestObject.responseText != 0) {
							var dane = XMLHttpRequestObject.responseText;
							if(dane == 'OK') {
								MsgBox.HideWait();
								MsgBox.Hide();
								MsgBox.Show('Wiadomość została wysłana. Dziękujemy.','Wiadomość wysłano','OK');
							} else {
								MsgBox.HideWait();
								var pole = document.getElementById('formSendMsgToCompanyError');
								document.getElementById('captcha').src=Config.baseUrl.captcha+'captcha.php?qwerty='+Math.random();
								pole.innerHTML = dane;
							}
						}
					} //else if((XMLHttpRequestObject.readyState == 2) && ((XMLHttpRequestObject.status == 400) || (XMLHttpRequestObject.status == 403) || (XMLHttpRequestObject.status == 404) || (XMLHttpRequestObject.status == 500))) alert('Wystąpił błąd transmisji ('+XMLHttpRequestObject.status+')');
				}
				var form = document.forms['formSendMsgToCompany'];
				var from = form.from.value;
				var email = form.email.value;
				var telefon = form.telefon.value;
				var temat = form.temat.value;
				var msg = form.msg.value;
				var idf = form.idfi.value;
				var code = form.code.value;
				var str = 'from='+escape(from)+'&email='+escape(email)+'&telefon='+escape(telefon)+'&temat='+escape(temat)+'&msg='+escape(msg)+'&idfi='+escape(idf)+'&code='+escape(code)+'&formSend=1';
				XMLHttpRequestObject.send(str);
			}
		},
		ValidateMsgToCompany: function() {
			this.msgToCompanyIsOK = false;
			var form = document.forms['formSendMsgToCompany'];
			var errorMsg = '';
			var email_pattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;

			if(form.from.value == '') {
				errorMsg += '- nazwę nadawcy\n';
				styleForm(form.from);
			}
			if(!email_pattern.test(form.email.value)) {
				errorMsg += '- POPRAWNY adres e-mail\n';
				styleForm(form.email);
			}
			if(form.temat.value == '') {
				errorMsg += '- temat\n';
				styleForm(form.temat);
			}
			if(form.msg.value == '') {
				errorMsg += '- treść wiadomości\n';
				styleForm(form.msg);
			}
			if(form.code.value == '') {
				errorMsg += '- kod\n';
				styleForm(form.code);
			}
			
			if(errorMsg == '') this.msgToCompanyIsOK = true;
			if(errorMsg != '') errorMsg = 'Proszę podać: \n' + errorMsg;
			//if(!this.msgToCompanyIsOK) alert(errorMsg);
			return this.msgToCompanyIsOK;
		},
		PrepareMsgToCompany: function(idfi,company) {
			MsgBox.buttonAction.MsgToCompanySend = 'MsgToCompany.ValidateMsgToCompany(); MsgToCompany.SendMsgToCompany();';
			MsgBox.buttonLabel.MsgToCompanySend = 'Wyślij wiadomość';
			MsgBox.buttonStyle.MsgToCompanySend = 'b';
			MsgBox.Show(this.GetFormHTML(idfi),'Wyślij wiadomość do firmy "'+company+'"','MsgToCompanySend');

		},
		GetFormHTML: function(idfi) {
			
			html = '<form action="sendMsgToCompany.php" method="post" id="formSendMsgToCompany" name="formSendMsgToCompany" onsubmit="return validateMsgToCompany()"><table class="contentTable">\
					<tr>\
						<td colspan="3" class="msgBox_form_subheader"><span>Dane nadawcy</span></td>\
					</tr>\
					<tr>\
						<td class="contentTable_first">Imię i nazwisko / Nazwa firmy:<sup>*</sup></td>\
						<td class="contentTable_second"><input type="text" name="from" onkeydown="makeMeWhite(this)" onmouseover="highlight_border(this)" onmouseout="unHighlight_border(this)" onfocus="highlight(this,\'#f9f0a8\')" onblur="unHighlight(this,\'#ffffff\')" /></td>\
						<td class="contentTable_third"></td>\
					</tr>\
					<tr>\
						<td class="contentTable_first">Adres e-mail:<sup>*</sup> </td>\
						<td class="contentTable_second"><input type="text" name="email" onkeydown="makeMeWhite(this)" onmouseover="highlight_border(this)" onmouseout="unHighlight_border(this)" onfocus="highlight(this,\'#f9f0a8\')" onblur="unHighlight(this,\'#ffffff\')" /></td>\
						<td class="contentTable_third"></td>\
					</tr>\
					<tr>\
						<td class="contentTable_first">Telefon:</td>\
						<td class="contentTable_second"><input type="text" name="telefon" onkeydown="makeMeWhite(this)" onmouseover="highlight_border(this)" onmouseout="unHighlight_border(this)" onfocus="highlight(this,\'#f9f0a8\')" onblur="unHighlight(this,\'#ffffff\')" /></td>\
						<td class="contentTable_third"></td>\
					</tr>\
					<tr>\
						<td colspan="3" class="msgBox_form_subheader"><span>Wiadomość</span></td>\
					</tr>\
					<tr>\
						<td class="contentTable_first">Temat:<sup>*</sup></td>\
						<td class="contentTable_second" colspan="2"><input type="text" name="temat" onkeydown="makeMeWhite(this)" onmouseover="highlight_border(this)" onmouseout="unHighlight_border(this)" onfocus="highlight(this,\'#f9f0a8\')" onblur="unHighlight(this,\'#ffffff\')" /></td>\
					</tr>\
					<tr>\
						<td class="contentTable_first">Treść:<sup>*</sup></td>\
						<td class="contentTable_second" colspan="2"><textarea name="msg" rows="4" onkeydown="makeMeWhite(this)" onkeydown="makeMeWhite(this)" onmouseover="highlight_border(this)" onmouseout="unHighlight_border(this)" onfocus="highlight(this,\'#f9f0a8\')" onblur="unHighlight(this,\'#ffffff\')"></textarea></td>\
					</tr>\
					<tr>\
						<td colspan="3" class="msgBox_form_subheader"><span>Proszę przepisać kod z obrazka<sup>*</sup></span></td>\
					</tr>\
					<tr>\
						<td></td>\
						<td><div><img id="captcha" src="'+Config.baseUrl.captcha+'captcha.php?qwerty='+Math.random()+'" width="150" height="60" /></div>\
						<input type="text" name="code" onkeydown="makeMeWhite(this)" onmouseover="highlight_border(this)" onmouseout="unHighlight_border(this)" onfocus="highlight(this,\'#f9f0a8\')" onblur="unHighlight(this,\'#ffffff\')" />\
						</td>\
						<td></td>\
					</tr>\
				</table>\
				<input type="hidden" name="formSend" value="1" />\
				<input type="hidden" name="idfi" value="'+idfi+'" />\
				<p id="formSendMsgToCompanyError"></p>\
				<p class="polaObowiazkowe"><sup>*</sup> - pole obowiązkowe</p>\
			</form>';
			return html;
		}
	}
/* msg to company END */

/* page scroll START */
    scrollPrintOptions = function() {
		if(document.getElementById('main_prawaKolumna_fixedMenu') && document.getElementById('main_srodkowaKolumna_prezentacjaWizytowki')) {
			var box = document.getElementById('main_prawaKolumna_fixedMenu');
			var y = document.documentElement.scrollTop;
			var offset = 10;
			if(!User.isIE6 && !User.isIE7) {
				var h = document.getElementById('main_srodkowaKolumna_prezentacjaWizytowki').offsetTop;
				//alert('y: '+y+' h: '+h);
				if(y>=h) {
					box.style.position = 'fixed';
					box.style.top = offset+'px';
				} else {
					box.style.position = 'absolute';
					box.style.top = h+'px';
				}
			} else if(User.isIE6) {
				var h1 = document.getElementById('main_srodkowaKolumna_prezentacjaWizytowki').offsetTop;
				var h2 = document.getElementById('main_srodkowaKolumna_prezentacjaWizytowki').offsetParent.offsetTop;
				var h = h1+h2;
				if(y>=h) {
					box.style.position = 'fixed';
					box.style.marginTop = (y-h)+offset*2+'px';
				} else {
					box.style.position = 'absolute';
					box.style.marginTop = '0px';
				}
			} else if(User.isIE7) {
				var h1 = document.getElementById('main_srodkowaKolumna_prezentacjaWizytowki').offsetTop;
				var h2 = document.getElementById('main_srodkowaKolumna_prezentacjaWizytowki').offsetParent.offsetTop;
				var h = h1+h2;
				var offsetDown = 5;
				if(y>=h) {
					box.style.position = 'fixed';
					box.style.top = offset+'px';
				} else {
					box.style.position = 'absolute';
					box.style.top = (h+offsetDown)+'px';
				}
			}
		}
	}
	
	window.onscroll = function() {
		scrollPrintOptions();
	}
	
	
	
	// window.onscroll = function() {
		// if(document.getElementById('main_prawaKolumna_fixedMenu') && document.getElementById('main_srodkowaKolumna_prezentacjaWizytowki')) {
			// var box = document.getElementById('main_prawaKolumna_fixedMenu');
			// var y = document.documentElement.scrollTop;
			// var offset = 10;
			// if(!User.isIE6 && !User.isIE7) {
				// var h = document.getElementById('main_srodkowaKolumna_prezentacjaWizytowki').offsetTop;
				// if(y>=h) {
					// box.style.position = 'fixed';
					// box.style.top = offset+'px';
				// } else {
					// box.style.position = 'absolute';
					// box.style.top = h+'px';
				// }
			// } else if(User.isIE6) {
				// var h1 = document.getElementById('main_srodkowaKolumna_prezentacjaWizytowki').offsetTop;
				// var h2 = document.getElementById('main_srodkowaKolumna_prezentacjaWizytowki').offsetParent.offsetTop;
				// var h = h1+h2;
				// if(y>=h) {
					// box.style.position = 'fixed';
					// box.style.marginTop = (y-h)+offset*2+'px';
				// } else {
					// box.style.position = 'absolute';
					// box.style.marginTop = '0px';
				// }
			// } else if(User.isIE7) {
				// var h1 = document.getElementById('main_srodkowaKolumna_prezentacjaWizytowki').offsetTop;
				// var h2 = document.getElementById('main_srodkowaKolumna_prezentacjaWizytowki').offsetParent.offsetTop;
				// var h = h1+h2;
				// var offsetDown = 5;
				// if(y>=h) {
					// box.style.position = 'fixed';
					// box.style.top = offset+'px';
				// } else {
					// box.style.position = 'absolute';
					// box.style.top = (h+offsetDown)+'px';
				// }
			// }
		// }
	// }
/* page scroll END */

/* page view START */
	function checkResolution() {
		if(document.getElementById('main_srodkowaKolumna_prezentacjaWizytowki_fixedMenu')) {
			if(User.resolutionX>=Config.resolution.b || User.resolutionX<Config.resolution.a) {
				document.getElementById('main_srodkowaKolumna_prezentacjaWizytowki_fixedMenu').style.display='block';
				document.getElementById('main_prawaKolumna_fixedMenu').style.display='none';
			} else {
				document.getElementById('main_srodkowaKolumna_prezentacjaWizytowki_fixedMenu').style.display='none';
				document.getElementById('main_prawaKolumna_fixedMenu').style.display='block';
				//if(User.resolutionX<=Config.resolution.a || User.resolutionX>=Config.resolution.c) {
					document.getElementById('czesc21').style.clear='left';
					document.getElementById('czesc22').style.clear='left';
				//}
			}
		}
	}
/* page view END */

/* klient STAT */
var Klient = {
	ValidateForm: function() {
		var form = document.forms['formAddCompany'];
		var isOK = false;
		var errorMsg = '';
		var kod_pattern = /^[0-9]{2}-[0-9]{3}$/;
		var rok_pattern = /^[0-9]{4}$/;
		var email_pattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;

		var isOK = false;
		var errorMsg = '';
		var kod_pattern = /^[0-9]{2}-[0-9]{3}$/;
		var rok_pattern = /^[0-9]{4}$/;
		var email_pattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;

		if(form.nazwaFirmy.value == '') {
			errorMsg += '<p class="msgBox_content_lista">nazwę firmy</p>';
			styleForm(form.nazwaFirmy);
		}
		if(form.opisSkrocony.value == 0) {
			errorMsg += '<p class="msgBox_content_lista">przedmiot działalności</p>';
			styleForm(form.opisSkrocony);
		}
		if(!kod_pattern.test(form.kodPocztowy.value)) {
			errorMsg += '<p class="msgBox_content_lista">kod pocztowy</p>';
			styleForm(form.kodPocztowy);
		}
		if(form.miejscowosc.value == '') {
			errorMsg += '<p class="msgBox_content_lista">miejscowość</p>';
			styleForm(form.miejscowosc);
		}
		if(form.ulica.value == '') {
			errorMsg += '<p class="msgBox_content_lista">ulica</p>';
			styleForm(form.ulica);
		}
		if(form.numerBudynku.value == '') {
			errorMsg += '<p class="msgBox_content_lista">numer budynku</p>';
			styleForm(form.numerBudynku);
		}
		if(form.wojewodztwo.value == 0) {
			errorMsg += '<p class="msgBox_content_lista">województwo</p>';
			styleForm(form.wojewodztwo);
		}
		if(form.telefon.value == '') {
			errorMsg += '<p class="msgBox_content_lista">telefon</p>';
			styleForm(form.telefon);
		}
		if(form.email.value!='' && !email_pattern.test(form.email.value)) {
			errorMsg += '<p class="msgBox_content_lista">adres e-mail</p>';
			styleForm(form.email);
		}
		if(!formAddCompanyEmailOK && email_pattern.test(form.email.value)) {
			errorMsg += '<p class="msgBox_content_lista">podany adres E-mail istnieje w bazie danych</p>';
			styleForm(form.email);
		}
		if((form.kategoria1.value == 0) && (form.kategorie.value == '')) {
			errorMsg += '<p class="msgBox_content_lista">kategoria</p>';
			styleForm(form.kategoria1);
		}
		if((form.kategoria2.value == 0) && (form.kategorie.value == '')) {
			errorMsg += '<p class="msgBox_content_lista">podkategoria</p>';
			styleForm(form.kategoria2);
		}
		if((form.slowaKluczowe.value == '') && (form.slowa_kluczowe.value == '')) {
			errorMsg += '<p class="msgBox_content_lista">słowa kluczowe</p>';
			styleForm(form.slowaKluczowe);
		}
		if(form.input_zgoda_akceptacjaRegulaminu.value == 'false') {
			errorMsg += '<p class="msgBox_content_lista">akceptacja regulaminu jest obowiązkowa</p>';
		}
		if(errorMsg == '') isOK = true;
		if(errorMsg != '') errorMsg = '<p class="msgBox_content_h">Niepoprawnie wypełnione pola:</p>' + errorMsg;
		if(!isOK) MsgBox.Show(errorMsg,'LF24: Proszę poprawić błędy w formularzu','OK');
		if(isOK) MsgBox.ShowWaitOnly('Trwa zapisywanie danych...');
		return isOK;
	}
}
/* klient END */

/* nawigacja START */
var oldLocation = null;

document.getElementsByClassName = function(cl) {
    var retnode = [];
    var myclass = new RegExp('\\b'+cl+'\\b');
    var elem = this.getElementsByTagName('*');
    for (var i = 0; i < elem.length; i++) {
	  var classes = elem[i].className;
	  if (myclass.test(classes)) retnode.push(elem[i]);
    }
  return retnode;
}; 

function historyChange(newLocation) {

    //alert(oldLocation+'|'+newLocation);
    if(oldLocation!=null && oldLocation!=newLocation) {
		oldLocation = newLocation;
		LF24.Router.dispatch();
    } else {
	if(oldLocation==null) {
	    oldLocation = newLocation;
	    LF24.Router.dispatch();
	}
	else oldLocation = newLocation;
	
    }

}

var LF24 = {
    addHistory: function(hash) {
	//if(!User.isIE8) dhtmlHistory.add(hash,true);
    },
    init: function() {
		checkResolution();
		initMenu();
		if(User.isIE6) {
		  //
		} else {

		      if(User.isIE8) {
			LF24.Router.dispatch();
		      } else {
			Hash.init(historyChange,true);
		      }
		}
		//
		PrintCheckbox.Init();
    },
    Display: {
	ShowPage: function(name) {
	    
	    var elements = document.getElementsByClassName('lf24_page');
	    for(var i=0;i<elements.length;i++) {
		  if(elements[i].id==name) {
		    if(elements[i].style.display!='block') elements[i].style.display='block';
		  }
		  else {
		    if(elements[i].style.display!='none') elements[i].style.display = 'none';
		  }
	    }
	    document.getElementById('main').className = 'main_'+name;
	}
    },
    Router: {
	parametry: null,
	rawParams: '',
	dispatch: function() {
	    this.parametry  = new Array();
	    if(window.location.hash!='') {  
	      this.rawParams = window.location.hash.replace(/#!/,'');
	      var params = this.rawParams.split('&');
	      for(var i=0;i<params.length;i++) {
		  var parsed = params[i].split('=');
		  if(parsed.length==2) this.parametry[parsed[0]] = unescape(parsed[1]);
	      }
	    } else this.parametry['p'] = '';
	    switch(this.parametry['p']) {
		case 'wyszukiwarka': LF24.Wyszukiwarka.Init(); break;
		case 'szukaj': LF24.Wyszukiwarka.Init(); break;
		case 'search': LF24.Wyszukiwarka.Init(); break;
		case 'wyszukaj': LF24.Wyszukiwarka.Init(); break;
		default: if(this.rawParams.match(/^[A-Za-z0-9]{6}$/) || this.parametry['idfi']!=undefined) {
			    if(this.parametry['idfi']==undefined) this.parametry['idfi'] = this.rawParams;
			    LF24.Wizytowka.Init();
			 } else {
			      LF24.Static.Main();
			 }
			  //MsgBox.Show('Strona o podanym adresie nie istnieje','404: Podana strona nie istnieje');
	    }
	},
	buildUrl: function(params,useGlobal) {
		if(useGlobal==undefined) useGlobal = true;
		if(useGlobal) var urlParams = this.parametry;
		else var urlParams = new Array();
		if(urlParams==null) urlParams = new Array();
		for(name in params) urlParams[name] = params[name];
		strUrl = '#!';	    
		for(name in urlParams) if(name!='toJSONString') strUrl+=name+'='+urlParams[name]+'&';
		return strUrl.substring(0,strUrl.length-1);
	},
	buildIdfiUrl: function(idfi) {
	    return '#!'+idfi;
	},
	getParam: function(name) {
	      if(this.parametry[name]!=undefined) return this.parametry[name];
	      else return false;
	}
    },
    round: function(liczba,liczba_miejsc) {
	if(liczba_miejsc==undefined) liczba_miejsc = 0;
	var ratio = Math.pow(10,liczba_miejsc);
	return (Math.round(ratio*liczba)/ratio);
    },
    rand: function(min,max) {
	  var modulo = max-min+1;
	  return Math.round(Math.random()*10000)%modulo+min;
    },
    Wyszukiwarka: {
	co: '',
	gdzie: '',
	url: 'wyszukiwarka/getSearchResults.php',
	response: null,
	currentPage: 1,
	results: null,
	Init: function() {
	  LF24.Display.ShowPage('wyniki_wyszukiwania');
	  var noweWyszukiwanie = false;
	  if(LF24.Router.parametry['co']!=undefined) {
	      document.getElementById('slowoKluczowe').value = LF24.Router.parametry['co'];
	      if(LF24.Router.parametry['co']!=this.co) noweWyszukiwanie = true;
	      this.co = LF24.Router.parametry['co'];
	  }
	  if(LF24.Router.parametry['gdzie']!=undefined ) {
	      document.getElementById('lokalizacja').value = LF24.Router.parametry['gdzie'];
	      if(LF24.Router.parametry['gdzie']!=this.gdzie) noweWyszukiwanie = true;
	      this.gdzie = LF24.Router.parametry['gdzie'];	
	  }

	  if(LF24.Router.parametry['str']!=undefined) this.currentPage = Number(LF24.Router.parametry['str']);
	  else this.currentPage = 1;
	  if(this.results==null || noweWyszukiwanie) this.results = new Array();
	  this._pobierzWynikiWyszukiwania();
	},
	Szukaj: function(page) {
	    LF24.Display.ShowPage('wyniki_wyszukiwania');
	    this.results = new Array();
	    this.currentPage = 1;
	    this.co = document.getElementById('slowoKluczowe').value;
	    this.gdzie = document.getElementById('lokalizacja').value;
	    //this._pobierzWynikiWyszukiwania();
	    window.location.hash='#!p=wyszukiwarka&co='+this.co+'&gdzie='+this.gdzie+'&cp=1';
	    
	    //LF24.addHistory('#!p=wyszukiwarka&co='+this.co+'&gdzie='+this.gdzie);
	    return false;
	},
	pobierzFirmeWgIdfi: function(idfi) {
	    if(this.results!=null) {
	      var cnt = this.results.length;
	      for(var i=0;i<cnt;i++) if(this.results[i]!=undefined && this.results[i]['idfi']!=undefined && this.results[i]['idfi']==idfi) return this.results[i];
	    }
	    return false;
	},
	pobierzFirmeWgIndex: function(index) {
	      if(this.results==null) return false;
	      if(this.results[index-1]!=undefined) return this.results[index-1];
	      return false;
	},
	_pobierzWynikiWyszukiwania: function() {
	    //var url = this.url+'?co='+this.co+'&gdzie='+this.gdzie+'&cp='+(this.currentPage);
	    var url = this.url+'?co='+Url.encode(this.co)+'&gdzie='+Url.encode(this.gdzie)+'&cp='+(this.currentPage);
		var urlg = this.url+'?q='+Url.encode(this.co)+Url.encode(' | ')+Url.encode(this.gdzie)+Url.encode(' | ')+(this.currentPage);
	    if(this.results[(LF24.Wyszukiwarka.currentPage-1)*Config.wyszukiwarka.wynikowNaStrone]==undefined) { //jezeli juz zaladowane to nie pobieraj
	      this._pokazCzekajke();
	      if(XMLHttpRequestObject) {
		  XMLHttpRequestObject.open("GET",url,true);
		  XMLHttpRequestObject.onreadystatechange = function() {
			if((XMLHttpRequestObject.readyState == 4) && (XMLHttpRequestObject.status == 200)) {
				if(XMLHttpRequestObject.responseText != 0) {
				    LF24.Wyszukiwarka.response = eval('('+XMLHttpRequestObject.responseText+')');
				    if(LF24.Wyszukiwarka.results==undefined) LF24.Wyszukiwarka.results = new Array(); //na wszelki wypadek
				    if(LF24.Wyszukiwarka.response.Debug!=undefined) alert(LF24.Wyszukiwarka.response.Debug);
				    if(LF24.Wyszukiwarka.response.Error==0) {

					if(LF24.Wyszukiwarka.response.Total>0) {
					    if(LF24.Wyszukiwarka.response.Results!=undefined) {
						for(i=0;i<LF24.Wyszukiwarka.response.Results.length;i++) {
						    
						    j = (LF24.Wyszukiwarka.currentPage-1)*Config.wyszukiwarka.wynikowNaStrone+i;
						    LF24.Wyszukiwarka.results[j] = LF24.Wyszukiwarka.response.Results[i];
						}
					    } else {
						 if(LF24.Wyszukiwarka.currentPage>1) window.location.hash='#!p=wyszukiwarka&co='+LF24.Wyszukiwarka.co+'&gdzie='+LF24.Wyszukiwarka.gdzie+'&str=1';
					    }
						_gaq.push(['_trackEvent','search','co='+LF24.Wyszukiwarka.co+'&gdzie='+LF24.Wyszukiwarka.gdzie+' - '+LF24.Wyszukiwarka.response.Total.toString(),LF24.Wyszukiwarka.response.Total.toString()]);
					} else {
						_gaq.push(['_trackEvent','search','co='+LF24.Wyszukiwarka.co+'&gdzie='+LF24.Wyszukiwarka.gdzie+' - 0','0']);
					}
					LF24.Wyszukiwarka._renderujWyniki();
					LF24.Wyszukiwarka._ukryjCzekajke();
				    }
				}
			}
		  }
		  XMLHttpRequestObject.send(null);
	      }
	    } else {
		LF24.Wyszukiwarka._renderujWyniki();
	    }
	    scroll(0,0);
		_gaq.push(['_trackPageview',urlg]);
	},
	/*_ukryjSERP: function() {
	    document.getElementById('wyszukiwarka_wynikiWyszukiwania_pager').style.display='none';	      	    
	    document.getElementById('serp').style.display='none';
	    document.getElementById('serpPodsumowanie').style.display='none';
	},*/
	_pokazSERP: function() {
	      document.getElementById('serpPodsumowanie').style.display='block';
	      document.getElementById('serp').style.visibility='visible';
	      document.getElementById('wyszukiwarka_wynikiWyszukiwania_pager').style.display='block';
	},
	_pokazCzekajke: function() {
	    
	    document.getElementById('wyszukiwarka_wynikiWyszukiwania_pager').style.display='none';	      	    
	    document.getElementById('serp').style.visibility='hidden';
	    document.getElementById('serpPodsumowanie').style.display='none';
	    document.getElementById('serpCzekaj').style.display='block';
	},
	_ukryjCzekajke: function() {
	      document.getElementById('serpCzekaj').style.display='none';	
	      this._pokazSERP();
	},
	_generujWpis: function(lp,data) {
	    //data.nazwa = Str.CutTooLong(data.nazwa);
	    if(data.wyroznienie==1) return this._generujWpisWyrozniony(lp,data);
	    else return this._generujWpisZwykly(lp,data);
	},
	_generujWpisWyrozniony: function(lp,data)	{
	    var ret = '';
		ret += '<table class="listaWynikow"><tr><td class="numerWynikuWyszukiwania">'+lp+'</td><td>\
<div class="wynikWyszukiwaniaWyrozniony">\
	<span class="radiusTop">\
		<span class="lt"></span><span class="rt"></span>\
	</span>\
	<div class="wynikWyszukiwaniaWyrozniony_head">\
		<h1 class="poczatek"></h1>\
		<h1><a href="'+LF24.Router.buildIdfiUrl(data.idfi)+'" onclick="LF24.Wizytowka.SetBackUrl() ">'+Str.CutTooLong(data.nazwa)+'</a></h1>\
		<h1 class="koniec"></h1>\
	</div>\
	<div class="clearB"></div>\
	<div class="wynikWyszukiwaniaWyrozniony_body">\
		<span class="radiusTop">\
			<span class="line-l"> <b class="r5-1"></b> <b class="r5-2"></b> <b class="r5-3"></b> </span>	<span class="line-r"> <b class="r5-3"></b> <b class="r5-2"></b> <b class="r5-1"></b> </span>\
			<span class="line-l"> <b class="r5-4"></b> <b class="r5-5"></b> </span> <span class="line-r"> <b class="r5-5"></b> <b class="r5-4"></b> </span>\
			<span class="line-l"> <b class="r5-6"></b> </span> <span class="line-r"> <b class="r5-6"></b> </span>\
			<span class="line-l"> <b class="r5-7"></b> </span> <span class="line-r"> <b class="r5-7"></b> </span>\
		</span>\
		<span class="wynikWyszukiwaniaWyrozniony_body_bcg1"></span>\
		<span class="wynikWyszukiwaniaWyrozniony_body_bcg2"></span>\
		<div>\
			<table style="position:relative;">\
				<tr>\
					<td class="wynik_logo">';
		if(data.logo==1) {
						ret += '\
						<span class="radiusTop">\
							<span class="line-l"> <b class="r5-1"></b> <b class="r5-2"></b> <b class="r5-3"></b> </span>	<span class="line-r"> <b class="r5-3"></b> <b class="r5-2"></b> <b class="r5-1"></b> </span>	\
							<span class="line-l"> <b class="r5-4"></b> <b class="r5-5"></b> </span> <span class="line-r"> <b class="r5-5"></b> <b class="r5-4"></b> </span>\
							<span class="line-l"> <b class="r5-6"></b> </span> <span class="line-r"> <b class="r5-6"></b> </span>\
							<span class="line-l"> <b class="r5-7"></b> </span> <span class="line-r"> <b class="r5-7"></b> </span>\
						</span>\
						<span style="display:block; background-color:#ffffff; padding-left:4px; padding-right:4px; overflow:hidden;"><a href="'+LF24.Router.buildIdfiUrl(data.idfi)+'"><img src="'+Config.baseUrl.logo+data.idfi+'.png"/></a></span>\
						<span class="radiusBottom">\
							<span class="line-l"> <b class="r5-7"></b> </span> <span class="line-r"> <b class="r5-7"></b> </span>\
							<span class="line-l"> <b class="r5-6"></b> </span>	<span class="line-r"> <b class="r5-6"></b> </span>\
							<span class="line-l"> <b class="r5-4"></b> <b class="r5-5"></b> </span>	<span class="line-r"> <b class="r5-5"></b> <b class="r5-4"></b> </span>\
							<span class="line-l"> <b class="r5-1"></b> <b class="r5-2"></b> <b class="r5-3"></b> </span>	<span class="line-r"> <b class="r5-3"></b> <b class="r5-2"></b> <b class="r5-1"></b> </span>	\
						</span>';
						}
					ret += '\
					</td>\
					<td class="wynik_daneAdresowe">\
						 <p><b>Adres:</b>'+data.ulica+'<br />'+data.kod_pocztowy+' '+data.miejscowosc+', woj. '+data.wojewodztwo+'</p>\
							    <p>'+( (data.telefon!='')?('<b>Tel:</b><span class="nowrap">'+data.telefon+'</span><span class="tab">&nbsp;</span>'):'')
							    +( ( data.telefon2!='')?('<b>Tel2:</b><span class="nowrap">'+data.telefon2+'</span><span class="tab">&nbsp;</span>'):'')
							    +( ( data.fax!='')?('<b>Fax:</b><span class="nowrap">'+data.fax):'')+'</span></p>\
							    '+( data.oferta!=''?('<p><b>Oferta:</b>'+data.oferta+'</p>'):'')+'\
					</td>\
				</tr>\
		</table>\
		</div>\
		<span class="radiusBottom">\
			<span class="line-l"> <b class="r5-7"></b> </span> <span class="line-r"> <b class="r5-7"></b> </span>\
			<span class="line-l"> <b class="r5-6"></b> </span>	<span class="line-r"> <b class="r5-6"></b> </span>\
			<span class="line-l"> <b class="r5-4"></b> <b class="r5-5"></b> </span>	<span class="line-r"> <b class="r5-5"></b> <b class="r5-4"></b> </span>\
			<span class="line-l"> <b class="r5-1"></b> <b class="r5-2"></b> <b class="r5-3"></b> </span>	<span class="line-r"> <b class="r5-3"></b> <b class="r5-2"></b> <b class="r5-1"></b> </span>\
		</span>\
	</div>\
	<div class="wynikWyszukiwaniaWyrozniony_foot">\
		<div class="wynikWyszukiwaniaWyrozniony_foot_lf24ID">\
			<h2 class="poczatek"></h2>\
			<h2><span>LF24 id:</span>'+data.idfi+'</h2>\
			<h2 class="koniec"></h2>\
		</div>\
		<div class="wynikWyszukiwaniaWyrozniony_foot_ikonki">\
			<ul>\
				<li><a href="'+LF24.Router.buildIdfiUrl(data.idfi)+'" onclick="LF24.Wizytowka.SetBackUrl()" class="wizytowka">Wizytówka</a></li>\
				'+(data.email==1?'<li><a href="javascript:void(0)" onclick="MsgToCompany.PrepareMsgToCompany(\''+data.idfi+'\',\''+data.nazwa.replace(/"/gi,'').replace(/'/gi,'')+'\')" class="wyslijWiadomosc">Wyślij wiadomość</a></li>':'')+'\
				<li class="stronaLf24"><a href="#" class="stronaLf24">www.LF24.pl/'+data.idfi+'</a></li>\
				'+(data.www!=''?('<li><a href="'+Config.baseUrl.outWebsite+data.idfi+'" target="_blank" class="stronaWww">Strona WWW</a></li>'):'')+'\
				<li><a href="javascript:void(0)" onclick="Directions.CheckStartLocation(\''+data.idfi+'\')" class="mapaDojazd">Mapa / Dojazd</a></li> \
			</ul>\
		<div class="clearB"></div>\
		</div>\
	</div>\
	<span class="radiusBottom">\
		<span class="lb"></span><span class="rb"></span>\
	</span>\
</div>\
</td></tr></table>';
	   return ret;
	},
	_generujWpisZwykly: function(lp,data) {
	    return '<table class="listaWynikow"><tr><td class="numerWynikuWyszukiwania">'+lp+'</td><td>\
	    <div class="wynikWyszukiwania">\
		    <span class="radiusTop">\
			    <span class="lt"></span><span class="rt"></span>\
		    </span> \
	    <div class="wynikWyszukiwania_head">\
			    <h1><a href="'+LF24.Router.buildIdfiUrl(data.idfi)+'" onclick="LF24.Wizytowka.SetBackUrl();">'+Str.CutTooLong(data.nazwa)+'</a></h1>\
		    </div>\
		    <div class="clearB"></div>\
		    <div class="wynikWyszukiwania_body">\
			    <div>\
				    <table>\
					    <tr>\
						    <td class="wynik_logo">	\
								    '+(data.logo==1?'<a href="'+LF24.Router.buildIdfiUrl(data.idfi)+'"><img src="'+Config.baseUrl.logo+data.idfi+'.png" /></a>':'')+'\
						    </td>\
						    <td class="wynik_daneAdresowe">\
							    <p><b>Adres:</b>'+data.ulica+'<br />'+data.kod_pocztowy+' '+data.miejscowosc+', woj. '+data.wojewodztwo+'</p>\
							    <p>'+( (data.telefon!='')?('<b>Tel:</b><span class="nowrap">'+data.telefon+'</span><span class="tab">&nbsp;</span>'):'')
							    +( ( data.telefon2!='')?('<b>Tel2:</b><span class="nowrap">'+data.telefon2+'</span><span class="tab">&nbsp;</span>'):'')
							    +( ( data.fax!='')?('<b>Fax:</b><span class="nowrap">'+data.fax):'')+'</span></p>\
							    '+( data.oferta!=''?('<p><b>Oferta:</b>'+data.oferta+'</p>'):'')+'\
						    </td>\
					    </tr>\
			    </table>\
			    </div>\
		    </div>\
		    <div class="wynikWyszukiwania_foot">\
			    <div class="wynikWyszukiwania_foot_lf24ID">\
				    <h2><span>LF24 id:</span>'+data.idfi+'</h2>\
			    </div>\
			    <div class="wynikWyszukiwania_foot_ikonki">	\
				    <ul>\
					    <li><a href="'+LF24.Router.buildIdfiUrl(data.idfi)+'" onclick="LF24.Wizytowka.SetBackUrl()" class="wizytowka">Wizytówka</a></li>\
					    '+(data.email==1?'<li><a href="javascript:void(0)" onclick="MsgToCompany.PrepareMsgToCompany(\''+data.idfi+'\',\''+data.nazwa.replace(/"/gi,'').replace(/'/gi,'')+'\')" class="wyslijWiadomosc">Wyślij wiadomość</a></li>':'')+'\
					    <li class="stronaLf24"><a href="#" class="stronaLf24">www.LF24.pl/'+data.idfi+'</a></li>\
					    '+(data.www!=''?('<li><a href="'+Config.baseUrl.outWebsite+data.idfi+'" target="_blank" class="stronaWww">Strona WWW</a></li>'):'')+'\
					    <li><a href="javascript:void(0)" onclick="Directions.CheckStartLocation(\''+data.idfi+'\')" class="mapaDojazd">Mapa / Dojazd</a></li>		\
				    </ul>\
			    <div class="clearB"></div>	\
			    </div>			\
		    </div>\
		    <span class="radiusBottom">\
			    <span class="lb"></span><span class="rb"></span>\
		    </span>\
	    </div>\
	    </td></tr></table>';
	},
	_renderujPodsumowanie: function() {
	    var start = (this.currentPage-1)*Config.wyszukiwarka.wynikowNaStrone+1;
	    var stop = start+Config.wyszukiwarka.wynikowNaStrone-1;
	    if(stop>this.response.Total) stop=this.response.Total;
	    var czasGenerowania = LF24.round(this.response.Time,3);
	    if(czasGenerowania==0) czasGenerowania = 'mniej niż 0.001';
	    document.getElementById('serpPodsumowanie').innerHTML='<!-- wyniki wyszukiwania info -->\
	    <div class="wynikiWyszukiwaniaInfo">\
		    <span class="radiusTop">\
			    <span class="line-l"> <b class="r5-1"></b> <b class="r5-2"></b> <b class="r5-3"></b> </span>	<span class="line-r"> <b class="r5-3"></b> <b class="r5-2"></b> <b class="r5-1"></b> </span>	\
			    <span class="line-l"> <b class="r5-4"></b> <b class="r5-5"></b> </span> <span class="line-r"> <b class="r5-5"></b> <b class="r5-4"></b> </span>\
			    <span class="line-l"> <b class="r5-6"></b> </span> <span class="line-r"> <b class="r5-6"></b> </span>\
			    <span class="line-l"> <b class="r5-7"></b> </span> <span class="line-r"> <b class="r5-7"></b> </span>\
		    </span>	\
		    <div class="clearB"></div>\
		    <div class="wynikiWyszukiwaniaInfo_body" id="serp_podsumowanie"\
			    <span class="wynikiWyszukiwaniaInfo_znaleziono">Wyniki <b>'+start+' - '+stop+'</b> spośród <b>'+this.response.IndexTotal+' </b> dla zapytania <b>'+this.co+( (this.co!=''&&this.gdzie!='')?', ':'' )+this.gdzie+'</b>.\
			    </span><span class="wynikiWyszukiwaniaInfo_znaleziono" style="float:right !important; margin-left:10px;">(Znaleziono w <b>'+czasGenerowania+'</b> sek.)</span>\
			    <div class="clearB"></div>\
		    </div>\
		    <span class="radiusBottom">\
			    <span class="line-l"> <b class="r5-7"></b> </span> <span class="line-r"> <b class="r5-7"></b> </span>\
			    <span class="line-l"> <b class="r5-6"></b> </span>	<span class="line-r"> <b class="r5-6"></b> </span>\
			    <span class="line-l"> <b class="r5-4"></b> <b class="r5-5"></b> </span>	<span class="line-r"> <b class="r5-5"></b> <b class="r5-4"></b> </span>\
			    <span class="line-l"> <b class="r5-1"></b> <b class="r5-2"></b> <b class="r5-3"></b> </span>	<span class="line-r"> <b class="r5-3"></b> <b class="r5-2"></b> <b class="r5-1"></b> </span>	\
		    </span>	\
	    </div>\
	    <!-- koniec wyniki wyszukiwania info-->'  
	},
	_renderujWyniki: function() {
		var resultsDiv = document.getElementById('serp');
	    //resultsDiv.style.display = 'none';
	    var html = '';
	    var cnt = this.results.length;
	    var start = (this.currentPage - 1)*Config.wyszukiwarka.wynikowNaStrone;
	    var maxI = Config.wyszukiwarka.wynikowNaStrone*this.currentPage;
	    if(maxI>cnt) maxI = cnt;
	    
	    for(i=start;i<maxI;i++) if(this.results[i]!=undefined) html+=this._generujWpis(i+1,this.results[i]);
	    resultsDiv.innerHTML = html;
	    //resultsDiv.style.display = 'block';
		LF24.title(this.co+' '+this.gdzie);
	    this._renderujPager(this.response.Total,Config.wyszukiwarka.wynikowNaStrone,this.currentPage);
	    this._renderujPodsumowanie();
	},
	_renderujPager: function(liczbaWynikow,wynikowNaStr,aktualnaStrona) {
	  var maxStr = Math.ceil(liczbaWynikow/wynikowNaStr);
	  if(aktualnaStrona>maxStr) aktualnaStrona = maxStr;
	  if(aktualnaStrona<1) aktualnaStrona = 1;
	  if(maxStr==1 || maxStr==0) html='';
	  else {
	    html = '<div class="wynikiWyszukiwaniaInfo" style="margin-top:3px; margin-bottom:10px;">\
		<span class="radiusTop">\
			<span class="line-l"> <b class="r5-1"></b> <b class="r5-2"></b> <b class="r5-3"></b> </span>	<span class="line-r"> <b class="r5-3"></b> <b class="r5-2"></b> <b class="r5-1"></b> </span>	\
			<span class="line-l"> <b class="r5-4"></b> <b class="r5-5"></b> </span> <span class="line-r"> <b class="r5-5"></b> <b class="r5-4"></b> </span>\
			<span class="line-l"> <b class="r5-6"></b> </span> <span class="line-r"> <b class="r5-6"></b> </span>\
			<span class="line-l"> <b class="r5-7"></b> </span> <span class="line-r"> <b class="r5-7"></b> </span>\
		</span>	\
		<div class="wynikiWyszukiwaniaInfo_body">\
			<table class="wynikiWyszukiwaniaInfo_body_numeryStron"><tr>\
				<td class="buttonRed_td">';
				    if(aktualnaStrona>1) html+='\
					    <a class="button" href="'+LF24.Router.buildUrl({'str': aktualnaStrona-1})+'">\
						<table class="buttonRed" onclick="window.location.hash=\''+LF24.Router.buildUrl({'str': aktualnaStrona-1})+'\'">\
							<tr>\
								<td class="buttonRed_poczatekStrzalkaL"></td>\
								<td class="buttonRed_srodek">Poprzednia strona</td>\
								<td class="buttonRed_koniec"></td>\
							</tr>\
						</table>\
					    </a>';
					else html+='&nbsp;';
				html+='</td>\
				<td>\
					<div class="wynikiWyszukiwaniaInfo_body_numryStron_aktualnaStrona">';
						if(aktualnaStrona>1) html+='<a href="'+LF24.Router.buildUrl({'str': 1})+'" >1</a> ';
						if(aktualnaStrona>4) html+='<a href="'+LF24.Router.buildUrl({'str': 2})+'" >2</a> ';
						if(aktualnaStrona>5) {
						      if(aktualnaStrona==6) html+='<a href="'+LF24.Router.buildUrl({'str': 3})+'">3</a> ';
						      else html+='<span class="wielokropek">...</span> ';
						}
						if(aktualnaStrona>3) html+='<a href="'+LF24.Router.buildUrl({'str': aktualnaStrona-2})+'">'+(aktualnaStrona-2)+'</a> ';
						if(aktualnaStrona>2) html+='<a href="'+LF24.Router.buildUrl({'str': aktualnaStrona-1})+'">'+(aktualnaStrona-1)+'</a> ';
						html+='<span class="aktualnaStrona">'+aktualnaStrona+'</span> ';
						if(aktualnaStrona<(maxStr-2)) html+='<a href="'+LF24.Router.buildUrl({'str': aktualnaStrona+1})+'">'+(aktualnaStrona+1)+'</a> ';
						if(aktualnaStrona<(maxStr-3)) html+='<a href="'+LF24.Router.buildUrl({'str': aktualnaStrona+2})+'">'+(aktualnaStrona+2)+'</a> ';
						if(aktualnaStrona<(maxStr-4)) {
						  if(aktualnaStrona==(maxStr-5)) html+='<a href="'+LF24.Router.buildUrl({'str': maxStr-2})+'">'+(maxStr-2)+'</a> ';
						  else html+='<span class="wielokropek">...</span> ';
						}
						if(maxStr>=3 && aktualnaStrona<(maxStr-1)) html+='<a href="'+LF24.Router.buildUrl({'str': maxStr-1})+'">'+(maxStr-1)+'</a> ';
						if(aktualnaStrona<maxStr) html+='<a href="'+LF24.Router.buildUrl({'str': maxStr})+'">'+maxStr+'</a> ';
					html+='<div class="clearB"></div>\
					</div>			\
				</td>\
				<td class="buttonRed_td">';
					if(aktualnaStrona<maxStr && maxStr>1) html+='\
					    <a class="button" style="float:right;" href="'+LF24.Router.buildUrl({'str': aktualnaStrona+1})+'">\
						<table class="buttonRed" onclick="window.location.hash=\''+LF24.Router.buildUrl({'str': aktualnaStrona+1})+'\'">\
							<tr>								\
								<td class="buttonRed_poczatek"></td>\
								<td class="buttonRed_srodek">Następna strona</td>\
								<td class="buttonRed_koniecStrzalkaP"></td>\
							</tr>\
						</table>\
					    </a>';
					else html+='&nbsp;';
				html+='</td>\
			</tr></table>\
		</div>\
		<div class="clearB"></div>\
		<span class="radiusBottom">\
			<span class="line-l"> <b class="r5-7"></b> </span> <span class="line-r"> <b class="r5-7"></b> </span>\
			<span class="line-l"> <b class="r5-6"></b> </span>	<span class="line-r"> <b class="r5-6"></b> </span>\
			<span class="line-l"> <b class="r5-4"></b> <b class="r5-5"></b> </span>	<span class="line-r"> <b class="r5-5"></b> <b class="r5-4"></b> </span>\
			<span class="line-l"> <b class="r5-1"></b> <b class="r5-2"></b> <b class="r5-3"></b> </span>	<span class="line-r"> <b class="r5-3"></b> <b class="r5-2"></b> <b class="r5-1"></b> </span>	\
		</span>\
	  </div>';
	  }
	  document.getElementById('wyszukiwarka_wynikiWyszukiwania_pager').innerHTML = html;
      }
	
    },
    Wizytowka: {
		idfi: null,
		currentData: null,
		backUrl: null,
		Init: function() {
			this.idfi = LF24.Router.getParam('idfi');
			this.currentData = LF24.Wyszukiwarka.pobierzFirmeWgIdfi(this.idfi);
			if(this.currentData!=false) {
				this._renderuj();
				this._stat();
			}  else {
				this._wczytajDane();
			}
			//scrollPrintOptions();
		},
		SetBackUrl: function(url) {
		  if(url==undefined) url = window.location.hash;
		  this.backUrl = url;
		},
		_renderuj: function() {
			if(this.backUrl!=null) {
			  document.getElementById('JS_wizytowka_powrot_do_wynikow_wyszukiwania').href = Config.baseUrl.searchUrl+this.backUrl;
			  document.getElementById('JS_wizytowka_powrot_do_wynikow_wyszukiwania_2').href = Config.baseUrl.searchUrl+this.backUrl;
			  document.getElementById('JS_wizytowka_powrot_do_wynikow_wyszukiwania').innerHTML = 'Powrót do wyników wyszukiwania';
			  document.getElementById('JS_wizytowka_powrot_do_wynikow_wyszukiwania_2').innerHTML = 'Powrót do wyników wyszukiwania';
			} else {	//uzytkownik wszedl bezposrednio na wizytowke 
			  document.getElementById('JS_wizytowka_powrot_do_wynikow_wyszukiwania').href = Config.baseUrl.site+'#!';
			  document.getElementById('JS_wizytowka_powrot_do_wynikow_wyszukiwania_2').href = Config.baseUrl.site+'#!';
			  document.getElementById('JS_wizytowka_powrot_do_wynikow_wyszukiwania').innerHTML = 'Powrót na stronę głowną';
			  document.getElementById('JS_wizytowka_powrot_do_wynikow_wyszukiwania_2').innerHTML = 'Powrót na stronę głowną';
			}
			document.getElementById('JS_wizytowka_nazwa_firmy').innerHTML = this.currentData.nazwa;
			document.getElementById('JS_wizytowka_forma_prawna').innerHTML = ((this.currentData.forma_prawna!=''&&this.currentData.forma_prawna!=null)?(this.currentData.forma_prawna):(''));
			//document.getElementById('JS_wizytowka_logo_firmy').src = (this.currentData.logo=='1')?(Config.baseUrl.logo+this.currentData.idfi+'.png'):('');
			document.getElementById('JS_wizytowka_logo_firmy').innerHTML = (this.currentData.logo=='1')?('<img src="'+Config.baseUrl.logo+this.currentData.idfi+'.png" />'):('');
			document.getElementById('JS_wizytowka_qenerujQR_onclick').onclick = LF24.Wizytowka.ZmienOnClick.WyswietlQR;
			document.getElementById('JS_wizytowka_adres').innerHTML = '<b>Adres:</b>'+this.currentData.ulica+'<br />'+this.currentData.kod_pocztowy+' '+this.currentData.miejscowosc+', woj. '+this.currentData.wojewodztwo;
			document.getElementById('JS_wizytowka_telefony').innerHTML = ((this.currentData.telefon!='')?('<b>Tel:</b><span class="nowrap">'+this.currentData.telefon+'</span><span class="tab">&nbsp;</span>'):(''))+((this.currentData.telefon2!='')?('<b>Tel2:</b><span class="nowrap">'+this.currentData.telefon2+'</span><span class="tab">&nbsp;</span>'):(''))+((this.currentData.fax!='')?('<b>Fax:</b><span class="nowrap">'+this.currentData.fax+'</span>'):(''));
			document.getElementById('JS_wizytowka_GG').innerHTML = ((this.currentData.gg!='')?('<b>GG:</b><a href="gg://'+this.currentData.gg+'"><u>'+this.currentData.gg+'</u><img style="width:14px; height:14px; border:0px; margin-bottom:-3px; margin-left:3px;" src="http://status.gadu-gadu.pl/users/status.asp?id='+this.currentData.gg+'&styl=1" /></a><span class="tab"></span>'):(''));
			document.getElementById('JS_wizytowka_skype').innerHTML = ((this.currentData.skype!='')?('<b>Skype:</b><a href="callto:'+this.currentData.skype+'"><u>'+this.currentData.skype+'</u></a><img style="border:0px; width:11px; height:11px; margin-left:3px;" src="http://mystatus.skype.com/smallicon/'+this.currentData.skype+'" /></a>'):(''));
			document.getElementById('JS_wizytowka_nip_regon_krs_rok_zalozenia').innerHTML = ((this.currentData.NIP!='')?('<b>NIP:</b><span class="nowrap">'+this.currentData.NIP+'</span><span class="tab">&nbsp;</span>'):(''))+((this.currentData.REGON)?('<b>REGON:</b><span class="nowrap">'+this.currentData.REGON+'</span><span class="tab">&nbsp;</span>'):(''))+((this.currentData.KRS)?('<b>KRS:</b><span class="nowrap">'+this.currentData.KRS+'</span><span class="tab">&nbsp;</span>'):(''))+((this.currentData.rok_zalozenia)?('<b>Rok założenia:</b><span class="nowrap">'+this.currentData.rok_zalozenia+'</span>'):(''));
			document.getElementById('JS_wizytowka_wyslij_wiadomosc').innerHTML = ((this.currentData.email==true)?('<a href="javascript:void(0)" class="wyslijWiadomosc" id="JS_wizytowka_wyslij_wiadomosc_onclick" onclick="MsgToCompany.PrepareMsgToCompany(\''+this.currentData.idfi+'\',\''+this.currentData.nazwa.replace(/"/gi,'').replace(/'/gi,'')+'\')">Wyślij wiadomość</a>'):(''));
			document.getElementById('JS_wizytowka_www').innerHTML = ((this.currentData.www!='')?('<a href="'+Config.baseUrl.site+'out.php?id='+this.currentData.idfi+'" target="_blank" class="stronaWww">'+this.currentData.www+'</a>'):(''));
			document.getElementById('JS_wizytowka_wyznacz_trase_dojazdu_1').innerHTML = '<a href="javascript:void(0)" onclick="Directions.CheckStartLocation()" class="mapaDojazd">Wyznacz trasę dojazdu</a>';
			document.getElementById('JS_wizytowka_wyznacz_trase_dojazdu_2').innerHTML = '<a href="javascript:void(0)" onclick="Directions.CheckStartLocation()" class="mapaDojazd">Wyznacz trasę dojazdu</a>';
			document.getElementById('JS_wizytowka_lf24id').innerHTML = '<span>LF24 id:</span>'+this.currentData.idfi;
			if(this.currentData.oferta!='') {
				document.getElementById('JS_wizytowka_przedmiot_dzialalnosci').innerHTML = this.currentData.oferta;
				document.getElementById('JS_wizytowka_przedmiot_dzialalnosci_box').style.display = 'block';
			} else {
				document.getElementById('JS_wizytowka_przedmiot_dzialalnosci_box').style.display = 'none';
				document.getElementById('JS_wizytowka_przedmiot_dzialalnosci').innerHTML = '';
			}
			if(this.currentData.opis!='') {
				document.getElementById('JS_wizytowka_opis_firmy').innerHTML = this.currentData.opis;
				document.getElementById('JS_wizytowka_opis_firmy_box').style.display = 'block';
			} else {
				document.getElementById('JS_wizytowka_opis_firmy_box').style.display = 'none';
				document.getElementById('JS_wizytowka_opis_firmy').innerHTML = '';
			}
			document.getElementById('wydruk_adresWizytowki').innerHTML = 'Adres wizytówki: <b>www.LF24.pl/#!'+this.currentData.idfi+'</b>';
			document.getElementById('JS_link_podglad_wydruku_2').href = '#!'+this.currentData.idfi;
			document.getElementById('JS_link_podglad_wydruku_3').href = '#!'+this.currentData.idfi;
			document.getElementById('JS_link_drukuj_1').href = '#!'+this.currentData.idfi;
			document.getElementById('JS_link_drukuj_2').href = '#!'+this.currentData.idfi;
			document.getElementById('JS_link_drukuj_wizytowke').href = '#!'+this.currentData.idfi;
			
			//PrintCheckbox.EnableDisableCheckbox - włączanie/wyłączanie przycisków drukowania
			(this.currentData.oferta!='')?(PrintCheckbox.EnableDisableCheckbox('print_przedmiotDzialalnosci','On')):(PrintCheckbox.EnableDisableCheckbox('print_przedmiotDzialalnosci','Off'));
			(this.currentData.opis!='')?(PrintCheckbox.EnableDisableCheckbox('print_opisFirmy','On')):(PrintCheckbox.EnableDisableCheckbox('print_opisFirmy','Off'));
			if(this.currentData.fotki!=null && this.currentData.podpisy!=null  && this.currentData.fotki.length>0 && this.currentData.fotki.length==this.currentData.podpisy.length) {
			      document.getElementById('JS_wizytowka_galeria_zdjec_box').style.display='block';	  
			      this._renderujGalerie(this.currentData.fotki,this.currentData.podpisy);
			      PrintCheckbox.EnableDisableCheckbox('print_galeriaZdjec','On');
				  
			} else {
			      document.getElementById('JS_wizytowka_galeria_zdjec_box').style.display='none';
			      PrintCheckbox.EnableDisableCheckbox('print_galeriaZdjec','Off');
			}
			
			LF24.title(this.currentData.nazwa);
            this._renderujLinki();
			LF24.Display.ShowPage('wizytowka');
			initialize(); //inicjalizacja mapy google
			scroll(0,0);
			_gaq.push(['_trackPageview','#'+this.currentData.idfi+Url.encode(' '+this.currentData.nazwa)]);
		},
		_renderujWyruk: function() {
			//wydruk start
			document.getElementById('JS_wydruk_QR_img').src = 'http://chart.apis.google.com/chart?cht=qr&chs=160x160&chl=MECARD%3AN%3A'+Url.encode(this.currentData.nazwa)+'%3BTEL%3A'+Url.encode(this.currentData.telefon)+'%3BURL%3A'+Url.encode(this.currentData.www)+'%3BADR%3A'+Url.encode(this.currentData.ulica+','+this.currentData.kod_pocztowy+' '+this.currentData.miejscowosc+', woj. '+this.currentData.wojewodztwo)+'%3BNOTE%3ALF24.pl%3B%3B';
			document.getElementById('JS_wydruk_nazwa_firmy').innerHTML = this.currentData.nazwa;
			document.getElementById('JS_wydruk_forma_prawna').innerHTML = ((this.currentData.forma_prawna!=''&&this.currentData.forma_prawna!=null)?(this.currentData.forma_prawna):(''));
			document.getElementById('JS_wydruk_adres').innerHTML = '<b>Adres:</b>'+this.currentData.ulica+'<br />'+this.currentData.kod_pocztowy+' '+this.currentData.miejscowosc+', woj. '+this.currentData.wojewodztwo;
			document.getElementById('JS_wydruk_telefony').innerHTML = ((this.currentData.telefon!='')?('<b>Tel:</b><span class="nowrap">'+this.currentData.telefon+'</span><span class="tab">&nbsp;</span>'):(''))+((this.currentData.telefon2!='')?('<b>Tel2:</b><span class="nowrap">'+this.currentData.telefon2+'</span><span class="tab">&nbsp;</span>'):(''))+((this.currentData.fax!='')?('<b>Fax:</b><span class="nowrap">'+this.currentData.fax+'</span>'):(''));
			document.getElementById('JS_wydruk_gg_skype').innerHTML = ((this.currentData.gg!='')?('<b>GG:</b>'+this.currentData.gg+'<span class="tab">&nbsp;</span>'):(''))+((this.currentData.skype!='')?('<b>Skype:</b>'+this.currentData.skype):(''));
			document.getElementById('JS_wydruk_nip_regon_krs_rok_zalozenia').innerHTML = ((this.currentData.NIP!='')?('<b>NIP:</b><span class="nowrap">'+this.currentData.NIP+'</span><span class="tab">&nbsp;</span>'):(''))+((this.currentData.REGON)?('<b>REGON:</b><span class="nowrap">'+this.currentData.REGON+'</span><span class="tab">&nbsp;</span>'):(''))+((this.currentData.KRS)?('<b>KRS:</b><span class="nowrap">'+this.currentData.KRS+'</span><span class="tab">&nbsp;</span>'):(''))+((this.currentData.rok_zalozenia)?('<b>Rok założenia:</b><span class="nowrap">'+this.currentData.rok_zalozenia+'</span>'):(''));		
			document.getElementById('JS_wydruk_lf24id').innerHTML = '<span>LF24 id:</span>'+this.currentData.idfi;		
			document.getElementById('JS_wydruk_www').innerHTML = ((this.currentData.www!='')?('<b>Strona WWW:</b>'+this.currentData.www):(''));		
			//document.getElementById('JS_wydruk_logo_firmy').src = (this.currentData.logo=='1')?(Config.baseUrl.logo+this.currentData.idfi+'.png'):('');			
			document.getElementById('JS_wydruk_logo_firmy').innerHTML = (this.currentData.logo=='1')?('<img src="'+Config.baseUrl.logo+this.currentData.idfi+'.png" />'):('');
			
			//PrintCheckbox.EnableDisableCheckbox - włączanie/wyłączanie przycisków drukowania
			(this.currentData.oferta!='')?(PrintCheckbox.EnableDisableCheckbox('print_przedmiotDzialalnosci','On')):(PrintCheckbox.EnableDisableCheckbox('print_przedmiotDzialalnosci','Off'));
			(this.currentData.opis!='')?(PrintCheckbox.EnableDisableCheckbox('print_opisFirmy','On')):(PrintCheckbox.EnableDisableCheckbox('print_opisFirmy','Off'));
			if(this.currentData.fotki!=null && this.currentData.podpisy!=null  && this.currentData.fotki.length>0 && this.currentData.fotki.length==this.currentData.podpisy.length) {
			      document.getElementById('JS_wizytowka_galeria_zdjec_box').style.display='block';	  
			      this._renderujGalerie(this.currentData.fotki,this.currentData.podpisy);
			      PrintCheckbox.EnableDisableCheckbox('print_galeriaZdjec','On');
				  
			} else {
			      document.getElementById('JS_wizytowka_galeria_zdjec_box').style.display='none';
			      PrintCheckbox.EnableDisableCheckbox('print_galeriaZdjec','Off');
			}
			scroll(0,0);
			//if(pageTracker) pageTracker._trackPageview('#'+this.currentData.idfi+'/print/');
			_gaq.push(['_trackPageview','#'+this.currentData.idfi+'/print/'+Url.encode(' '+this.currentData.nazwa)]);
		},
		_renderujGalerie: function(fotki,podpisy) {
			var divFotki = document.getElementById('JS_wizytowka_galeria_zdjec_details');
			var divFotkiPrint = document.getElementById('JS_wydruk_galeria_zdjec');
			var len = fotki.length;
			var html = '';
			var html2 = '';
			
			for(var i=0;i<len;i++) {
			    html2+='<span class="wizytowka_wydruk_foto"><img class="wizytowka_wydruk_foto" src="'+Config.baseUrl.foto+this.idfi+'_T_'+fotki[i]+'.png" alt="'+this.currentData.nazwa+': '+podpisy[i]+'" /></span>&nbsp;';
			    html+='<span class="wizytowka_foto"><a class="wizytowka_foto" href="'+Config.baseUrl.foto+this.idfi+'_N_'+fotki[i]+'.png" rel="shadowbox[LF24_Galeria_Firmy]" title="'+podpisy[i]+'"><img src="'+Config.baseUrl.foto+this.idfi+'_T_'+fotki[i]+'.png" alt="'+this.currentData.nazwa+': '+podpisy[i]+'" /></a></span>&nbsp;';
			}
			divFotki.innerHTML = html;
			divFotkiPrint.innerHTML = html2;
			Shadowbox.clearCache(); 
			Shadowbox.setup("a.wizytowka_foto", {
			    gallery:            "LF24_Galeria_Firmy",
			    autoplayMovies:     true
			});
		},
		_renderujLinki: function() {
		    var divLinki = document.getElementById('JS_wizytowka_linki_details');
    	    var html = '<ul>';
		    if(this.currentData.podkategorie!=undefined) {
		    var arrPodkategorie = this.currentData.podkategorie.split(',|');
                for(i=0;i<arrPodkategorie.length;i++) {
		            arrPodkategorie[i] = arrPodkategorie[i].replace('|','');
                    if(arrPodkategorie[i]=='') continue;
		            html+='<li><a href="'+Config.baseUrl.site+'#!p=wyszukiwarka&co='+arrPodkategorie[i]+'&gdzie='+this.currentData.miejscowosc+'&str=1">'+arrPodkategorie[i]+', '+this.currentData.miejscowosc+'</a></li>';
		        }
		        for(i=0;i<arrPodkategorie.length;i++) {
		            arrPodkategorie[i] = arrPodkategorie[i].replace('|','');
                    if(arrPodkategorie[i]=='') continue;
		            html+='<li><a href="'+Config.baseUrl.site+'#!p=wyszukiwarka&co='+arrPodkategorie[i]+'&gdzie='+this.currentData.wojewodztwo+'&str=1">'+arrPodkategorie[i]+', '+this.currentData.wojewodztwo+'</a></li>';
		        }
		    }
		    html+= '<li><a href="'+Config.baseUrl.site+'#!p=wyszukiwarka&co=&gdzie='+this.currentData.wojewodztwo+'&str=1">'+this.currentData.wojewodztwo+'</a></li>';
		    html+= '<li><a href="'+Config.baseUrl.site+'#!p=wyszukiwarka&co=&gdzie='+this.currentData.miejscowosc+'&str=1">'+this.currentData.miejscowosc+'</a></li>';		    
            html+= '<li><a href="'+Config.baseUrl.site+'#!p=wyszukiwarka&co=&gdzie='+this.currentData.kod_pocztowy+'&str=1">'+this.currentData.kod_pocztowy+'</a></li>';
            html+='</ul>';		    		    
		    divLinki.innerHTML = html;
		},
		Wyswietl: function(data) {
			if(!isNaN(data)) this.currentData = LF24.Wyszukiwarka.pobierzFirmeWgIndex(data);
			else this.currentData = data;
			LF24.Display.ShowPage('wizytowka');
			this._renderuj();
		},
		ZmienOnClick: {
			WyswietlQR: function() {
				MsgBox.ShowQR('Kod QR firmy '+LF24.Wizytowka.currentData.nazwa,LF24.Wizytowka.currentData.nazwa,LF24.Wizytowka.currentData.telefon,LF24.Wizytowka.currentData.ulica+", "+LF24.Wizytowka.currentData.kod_pocztowy+" "+LF24.Wizytowka.currentData.miejscowosc,((LF24.Wizytowka.currentData.www!='')?(LF24.Wizytowka.currentData.www):("")));
			}
		},
		_pokazCzekajke: function() {
		      LF24.Display.ShowPage('wizytowka_czekajka');
		},
		_wczytajDane: function() {
			this._pokazCzekajke();
			XMLHttpRequestObject.open("GET",Config.ajaxUrl.pobierzWgIdfi+this.idfi);
			XMLHttpRequestObject.onreadystatechange = function() {
				if((XMLHttpRequestObject.readyState == 4) && (XMLHttpRequestObject.status == 200)) {
					if(XMLHttpRequestObject.responseText != 0) {
						response = eval('('+XMLHttpRequestObject.responseText+')');
						if(response.Error==0) {
						    LF24.Wizytowka.currentData = response.Result;
						    LF24.Wizytowka._renderuj();
						} else { //Error!=0
						    MsgBox.onBtnClick('OK',"window.location.hash='!'");
						    MsgBox.Show('Firma o identyfikatorze '+LF24.Wizytowka.idfi+' nie istnieje. Zostaniesz przekierowany do wyszukiwarki firm.','Nie znaleziono wizytówki','OK');
						    MsgBox.onBtnClick('OK',null);
						}
					}
				}
			}
			XMLHttpRequestObject.send(null);
		},
		_stat: function() {
		      XMLHttpRequestObject.open("GET",Config.ajaxUrl.stat+this.idfi);
		      XMLHttpRequestObject.send(null);
		}
    },
    title: function(title) {
		document.title = 'LF24.pl - '+title;
    },
    Static: {
		Main: function() {
			LF24.title('Strona główna - Lista Firm 24');
			LF24.Display.ShowPage('glowna');
			var nrCiekawostki = LF24.rand(1,4);
			if(User.isIE6 || User.isIE7) {
			var ciekawostkiDiv = document.getElementById('ciekawostki_div');
			if(ciekawostkiDiv) ciekawostkiDiv.innerHTML = '\
				  <table id="ciekawostki'+nrCiekawostki+'"   style="cursor: pointer;" onclick="document.location=\''+siteUrl+'dodaj.php\'">\
				  <tr><td class="bialaGora">&nbsp;</td><td rowspan="3" class="ciekawostka"></td><td class="bialaGora">&nbsp;</td></tr>\
				  <tr><td class="kolorowySrodek">&nbsp;</td><td class="kolorowySrodek">&nbsp;</td></tr>\
				  <tr><td class="kolorowyDol">&nbsp;</td><td class="kolorowyDol">&nbsp;</td></tr>\
				  </table>';
			} else {
				document.getElementById('ciekawostki'+nrCiekawostki).style.display = 'table';
				var ciekawostki = document.getElementsByClassName('ciekawostki');
				for(i=1;i<=ciekawostki.length;i++) {
					if(nrCiekawostki==i) continue;
					document.getElementById('ciekawostki'+i).style.display='none';
				}
			}
			//pageTracker._trackPageview();
			_gaq.push(['_trackPageview']);
		}
    }
};
/* nawigacja END */



