var addFirmOptionsClicked=false,advertOptionsClicked=false,searchType=[],searchAction=1,likesTime={},SEARCH_FIRMS='firms',SEARCH_TAGS='tags',SEARCH_TRADE='trade',SEARCH_B2B='b2b',SEARCH_INTERNET='internet',SEARCH_REALESTATE='realestate',SEARCH_MAP='map',SEARCH_SHOPS='shops';SEARCH_BARTER='barter';SEARCH_KUPUJ='kupuj';SEARCH_SOLID_COMPANY='solid_company';SEARCH_VIDEO='video';SEARCH_WANTS='wants';SEARCH_HAVES='haves';searchType[SEARCH_FIRMS]=1;searchType[SEARCH_TAGS]=2;searchType[SEARCH_TRADE]=3;searchType[SEARCH_B2B]=4;searchType[SEARCH_INTERNET]=5;searchType[SEARCH_REALESTATE]=6;searchType[SEARCH_MAP]=7;searchType[SEARCH_SHOPS]=8;searchType[SEARCH_BARTER]=9;searchType[SEARCH_KUPUJ]=10;searchType[SEARCH_SOLID_COMPANY]=11;searchType[SEARCH_VIDEO]=12;searchType[SEARCH_WANTS]=13;searchType[SEARCH_HAVES]=14;$(document).ready(function(){$('#hNavTm0').click(function(){$('#hNavSm0').toggle('slow');});$('#siro').change(function(){changeSearchRadius();});$('.JQshowAddress').click(JQshowAddressEvents);$('.jq_expandTagsR').click(function(){$(this).parent().eq(0).find('a, span').show();$(this).hide();});$('.jq_collapseTagsR').click(function(){$(this).parent().eq(0).find('a:gt(2), span:gt(1)').hide();$('.jq_expandTagsR').show();$(this).hide();});var oLikes=$('#likeInputList li'),oLikesR=$('#likeInputListRadius li');if(oLikes.length)
{oLikes.click(function(){searchAction=searchType[this.id.replace(/^lInput_/gi,'')];oLikes.removeClass('dn');$('#likeInput p').text($.trim($(this).addClass('dn').text()));if(searchAction==searchType[SEARCH_FIRMS]){$('#searchInChbox').show();}else{$('#searchInChbox').hide();}
triggerLikes(true,'likeInputList');});}
if(oLikesR.length)
{oLikesR.click(function(){var v=$(this).text();$('#likeInputRadius p').text(v);$('#radInput').val(v);triggerLikes(true,'likeInputListRadius');});}
$('#likeSelect, #likeInput p, #likeSelectRadius, #likeInputRadius p').click(triggerLikes);$('#likeInput, #likeSelect, #likeInputRadius, #likeSelectRadius').mouseleave(function(){listName=getLikesListName(this);likesTime[listName]=setTimeout('likesTimeout("'+listName+'")',500);});$('#likeInput, #likeSelect, #likeInputRadius, #likeSelectRadius').mouseenter(function(){likesTime[getLikesListName(this)]=false;});initSarchInCheckBoxes();});function getLikesListName(el)
{var listName='likeInputList';if(el.id.match(/Radius$/gi)){listName='likeInputListRadius';}
return listName;}
function likesTimeout(listId)
{if(likesTime[listId])
{triggerLikes(true,listId);}}
function triggerLikes(hide,elId)
{if(this.id){elId=getLikesListName(this);}
if(!elId){elId='likeInputList';};var el=$('#'+elId),is_visible=(el.css('display')=='block');if(typeof(hide)=='boolean'&&hide)is_visible=true;is_visible?el.hide():el.show();}
function changeSearchRadius(){var r=$('#siro').val();$('#quickF input[name=rad]').remove();if(r>0){$('#quickF').append('<input type="hidden" name="rad" value="'+r+'" />');}else{searchIn('/'+links.firms);setDefaultSearch();}};function setDefaultSearch(){$('#sqc').hide();$('#quickW').show();initCas(1);$('#sirc').hide();$('#quickF input[name=rad]').remove();$('#quickF input[name=rid]').remove();fixPosition(window.document.getElementById('quickWT'),window.document.getElementById('quickW'));};function searchIn(location){document.quickF.action=location;};function selectSearchType()
{var path=location.pathname,suffix=false;if(path.match('/'+links.search+'/'+links.firms))
{searchAction=searchType[SEARCH_FIRMS];suffix=SEARCH_FIRMS;};if(path.match('/sklepy'))
{searchAction=searchType[SEARCH_SHOPS];suffix=SEARCH_SHOPS;};if(path.match('/barter-system'))
{searchAction=searchType[SEARCH_BARTER];suffix=SEARCH_BARTER;}
if(path.match('/kupuj-nasze'))
{searchAction=searchType[SEARCH_KUPUJ];suffix=SEARCH_KUPUJ;}
if(path.match('/solidnafirma'))
{searchAction=searchType[SEARCH_SOLID_COMPANY];suffix=SEARCH_SOLID_COMPANY;}
if(path.match('/firmy-oferty'))
{searchAction=searchType[SEARCH_HAVES];suffix=SEARCH_HAVES;}
if(path.match('/firmy-zlecenia'))
{searchAction=searchType[SEARCH_WANTS];suffix=SEARCH_WANTS;}
if(path.match('/video'))
{searchAction=searchType[SEARCH_VIDEO];suffix=SEARCH_VIDEO;};if(suffix){var id='lInput_'+suffix;$('.likeInputList li').removeClass('dn');$('#likeInput p').text($.trim($('#'+id).addClass('dn').text()));}}
function setSearchInDisplayType()
{if(searchAction&&searchAction==searchType[SEARCH_FIRMS]){$('#searchInChbox').show();}}
function submitForm(ms){if($('#quickF input[name=fid]').val()){document.quickF.submit();}
if(typeof ms!='undefined')
{searchAction=searchType[parseInt(ms)];}
if(searchAction){var link='';switch(searchAction){case searchType[SEARCH_FIRMS]:link=buildGetClear(links.firms,false,links.search);link=addSearchInParams(link);break;case searchType[SEARCH_TAGS]:link=buildGetClear();break;case searchType[SEARCH_TRADE]:link=buildTradeUrl();break;case searchType[SEARCH_B2B]:link=buildB2bUrl();break;case searchType[SEARCH_INTERNET]:link=buildInternetUrl();break;case searchType[SEARCH_REALESTATE]:link='http://nieruchomosci.yellowpages.pl'+buildGetClear('/oferty');break;case searchType[SEARCH_MAP]:link=buildMapUrl(links.map);break;case searchType[SEARCH_SHOPS]:link=buildGetClear('sklepy');break;case searchType[SEARCH_KUPUJ]:link=buildGetClear('kupuj-nasze','');break;case searchType[SEARCH_BARTER]:link=buildGetClear('barter-system','');break;case searchType[SEARCH_SOLID_COMPANY]:link=buildGetClear('solidnafirma','');break;case searchType[SEARCH_VIDEO]:link=buildGetClear('video','');break;case searchType[SEARCH_WANTS]:link=buildGetClear('firmy-zlecenia','','',2);break;case searchType[SEARCH_HAVES]:link=buildGetClear('firmy-oferty','','',2);break;}
var hostBase=document.location.host,isWebEnv=hostBase.match(/yellowpages\.pl$/gi);if(link.match(/^\//gi)&&isWebEnv)
{var subdomain=hostBase.match(/^([a-zA-Z0-9-_]*)/gi),dontChangeBase=subdomain[0].match(/^(en|de|ua|fr|it|ru|nocache|www|dev|beta|lb(0-9))$/gi),devsub=hostBase.match(/\.dev\./gi);if(!dontChangeBase){var newUrl=/^https/i.test(window.location.protocol)?'https':'http';newUrl+='://';newUrl+=devsub?'dev.yellowpages.pl':'www.yellowpages.pl';link=newUrl+link;}}
if(link)document.location.href=link;return false;}else{var t=parseInt($('#sType').val());switch(t){case 10:var q=$('#quickC').val();q=$.trim(q);if(q)document.location.href='/'+links.products_sevices+'/'+q+'.html';return false;break;}}
var r=$('#siro').val();$('#quickF input[name=rad]').remove();if(r>0){$('#quickF').append('<input type="hidden" name="rad" value="'+r+'" />');}
document.quickF.submit();return false;};function buildGetClear(prefix,suffix,searchPrefix,uType){var what=$.trim($('#quickC').val()),where=$.trim($('#quickW').val()),link='',linkPrefix='/',clrurl=new RegExp("[\\s!\\|@#\\$\\^\\*\\(\\)\\{\\}\\[\\]\\+=:;<>\\?\\/\\~`\\.\\\\,“”\'\"]","gi");if(what){what=what.replace(clrurl,'-');link+=what;}
if(where){where=where.replace(clrurl,'-');if(what){if(searchPrefix||uType==2){link+='-_-';}else{link+='-';}}else if(searchPrefix||uType==2){link+='_-';}
link+=where;}
if(!(searchPrefix||uType==2)){link=link.replace(/[-_]{2,}/gi,'-').replace(/^([_-]*)*|([_-])*$/gi,'');}
linkPrefix+=prefix?prefix:'';if(!link){if(prefix){link=linkPrefix;}}else{if(searchPrefix){linkPrefix='/'+searchPrefix+linkPrefix;}
if(prefix&&prefix!='sklepy'){linkPrefix+='-';}
else if(prefix=='sklepy'){linkPrefix+='/';}
link=linkPrefix+link;if(typeof(suffix)!='undefined'&&suffix)
{link+=suffix;;}else link+='.html';}
var url=document.location.href;if(url.indexOf('?')!=-1){var postfix=url.substr(url.indexOf('?')),matches=postfix.match(/[\?&]+[a-zA-Z0-9-_]+=[^\?&]*/gi);if(matches){for(k in matches){if(typeof(matches[k])=='string'){var inp=matches[k].replace(/[\?&]*/g,'').replace(/=[^\?&]*/gi,'');if(!$("#quickF input[name='"+inp+"']").length){postfix=postfix.replace(matches[k],'');}}}}
postfix=postfix.replace(/[\?&]+([qw]|cmd|rad|sit|sis|sik|sia)=[^\?&]*/gi,'');postfix=postfix.replace(/[\?&]+tab=[^\?&]*/gi,'');if(postfix.length){postfix=postfix.replace(/[\?&]+/gi,'&');postfix=postfix.slice(0,1).replace('&','?')+postfix.slice(1);link+=postfix;}}
var rad=parseInt($('#quickF [name=rad]').val());if(rad&&rad>1)
{link+=(link.indexOf('?')!=-1)?'&':'?';link+='rad='+rad;}
return link;};function addSearchInParams(link){var arr=new Array();if($('#sit').attr('checked')){arr.push('sit=1');}
if($('#sik').attr('checked')){arr.push('sik=1');}
if(arr.length){link+=(link.indexOf('?')!=-1)?'&':'?';link+=arr.join('&');}
return link;}
function buildTradeUrl()
{var link='http://gielda.yellowpages.pl/',what=$.trim($('#quickC').val()),where=$.trim($('#quickW').val());if(what||where)
{link+='list?cmd=search&tab=1&q='+what+'&l='+where+'&lang='+lang;}
return link;}
function buildInternetUrl()
{var what=$.trim($('#quickC').val()),where=$.trim($('#quickW').val()),prefix='internet',link='/'+prefix;if(what||where)link+='/';if(what){what=what.replace(/\s/gi,'-');link+=what;}
if(where){where=where.replace(/\s/gi,'-');if(what){link+='-';}
link+=where;}
if(what){link+='.html';}
var url=document.location.href;if(url.indexOf('?')!=-1){link+=url.substr(url.indexOf('?'));}
return link;}
function buildB2bUrl()
{var link='http://b2b.yellowpages.pl/',what=$.trim($('#quickC').val()),where=$.trim($('#quickW').val());if(what||where)
{link+='index.html?query=';if(what)
{link+=what.replace(' ','+');}
if(what&&where)
{link+='+';}
if(where)
{link+=where.replace(' ','+');}}
var url=document.location.href;if(url.indexOf('?')!=-1){link+=url.substr(url.indexOf('?'));}
return link;}
function buildMapUrl(prefix)
{var link='/'+prefix,what=$.trim($('#quickC').val()),where=$.trim($('#quickW').val());if(what||where)
{if(what)
{link+='/'+what;}
if(where)
{link+='/'+where;}}
return link;}
function showInfoLayer(info){$('#lmsg').html(info);$.blockUI({message:$('#lcont'),css:{backgroundColor:'#FFF',border:'none',position:'absolute',top:'50%',left:'50%',width:'350px',height:'125px',padding:'0',margin:'-150px 0 0 -150px',textAlign:'left'},overlayCSS:{backgroundColor:'#000',opacity:'0.6'}});};function bookmarkHomePageLink(contID){var h=document.all?'<a class="cp" onclick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\'http://www.yellowpages.pl/\');">':'<a class="cp" onclick="bookmarkHomePage();">';$('#'+contID).html(h+'<span>'+$('#hp1').html()+'</span></a>');};function bookmarkHomePage(){if(navigator.appName=='Netscape'){var info='<a href="http://www.yellowpages.pl/"><span>'+$('#hp2').html()+'</span></a>';}else{var info=$('#hp3').html();}
showInfoLayer(info);return false;};function addToFavoritesLink(contID){var h='',title=document.title,url=document.location;if(navigator.userAgent.indexOf('Mac')!=-1){h='<a class="cp" onclick="addToFavorites();">';}else if(navigator.appName=='Netscape'){if(navigator.userAgent.indexOf('Firefox')!=-1&&(typeof window.sidebar=='object')&&(typeof window.sidebar.addPanel=='function')){h='<a class="cp" onclick="window.sidebar.addPanel(\''+title+'\', \''+url+'\', \'\');">';}else{h='<a class="cp" onclick="addToFavorites();">';}}else if(navigator.userAgent.indexOf('Opera')!=-1){h='<a class="cp" onclick="addToFavorites();">';}else if(navigator.userAgent.indexOf('IE')!=-1){h='<a class="cp" onclick="window.external.addfavorite(\''+url+'\', \''+title+'\')">';}
if(h.length>0){h+='<span>'+$('#hf1').html()+'</span></a>';$('#'+contID).html(h);}};function addToFavorites(){showInfoLayer($('#hf2').html());return false;};var chatApiLoaded=false;function showChatButton(){var ct=new Date();var h=ct.getHours();if(h>=8&&h<=16){html='<a class="cp" onclick="showChat();"><img src="/pics/lc.png';}else{html='<a class="cp"><img src="/pics/lcia.gif';}
html+='" /></a>';document.write(html);};function showChat(){if(chatApiLoaded){showChat2();}else{var html='<scr'+'ipt language="JavaScript" src="http://chat.yp.pl/webchat/jivelive.jsp"></scr'+'ipt>';$('#scbc').html(html);chatApiLoaded=true;window.setTimeout(showChat2,1000);}
return false;};function showChat2(){launchWin('framemain','http://chat.yp.pl/webchat/start.jsp?workgroup=yellowpages-sale@workgroup.chat.yp.pl&location=http://www.yellowpages.pl/',500,400);};function JQshowAddressEvents(e){$(this).parent().hide();$(this).parent().prev().show();}
function initSarchInCheckBoxes(){if(!$('#sia').length){return;}
$('#sit, #sik').unbind().change(function(){if($('#sit').attr('checked')||$('#sik').attr('checked')){$('#sia').removeAttr('checked');}else{$('#sia').attr('checked','checked');}});$('#sia').unbind().change(function(){if($('#sia').attr('checked')){$('#sit, #sik').removeAttr('checked');}
if(!($('#sit').attr('checked')||$('#sik').attr('checked'))){if(!$('#sia').attr('checked')){$('#sia').attr('checked','checked');}}});}