
// © 2002-2004 Supernavigator s.r.o., Vsetky prava vyhradene!
// Riesenie je priemyselno-pravne chranene a je predmetom chraneneho autorskeho diela!
// Precitajte si podmienky pouzitia (http://www.supernavigator.sk/navigator/conditions.php)
	
var Search=new Object();Search.init=function(){Search.form=getById('vyhladavanie');if(Search.form){Search.form.onsubmit=function(){getById('searchbutton').focus();return false;}
Search.keyword=Search.form.keyword;Search.keyword.active=false;Search.keyword.onfocus=function(){SuperNavigator.keysEnabled=false;}
Search.keyword.onblur=function(){SuperNavigator.keysEnabled=true;}
Search.buttons=new Array("searchCategory","searchFirmName","searchKeyword","searchStreet","searchCity");if(getById('searchCategory'))getById('searchCategory').onmousedown=function(e){Search.setObject(Category);return Search.go(e);}
if(getById('searchFirmName'))getById('searchFirmName').onmousedown=function(e){Search.setObject(Firm);return Search.go(e);}
if(getById('searchKeyword'))getById('searchKeyword').onmousedown=function(e){return false;}
if(getById('searchStreet'))getById('searchStreet').onmousedown=function(e){Search.setObject(Street);return Search.go(e);}
if(getById('searchCity'))getById('searchCity').onmousedown=function(e){Search.setObject(City);return Search.go(e);}}
var ikony=Search.defaultIconMaxDisplayResult.unique();for(var id in ikony)if(typeof(ikony[id])=="string")loadIcon(ikony[id]);Search.objects=new Array(window.City,window.Street,window.Firm,window.Property);}
Search.defaultIconMaxDisplayResult=new Array(0,'a','a','b','b','b','b','a','b','b','b','b');Search.lastSearch=new Array();Search.actualKeyword='';Search.actualCategory=null;Search.actualPobocka=null;Search.actualFirmID=null;Search.actualFirmIDs=null;Search.actualMyPosIDs=null;Search.actualClientCategoryIDs=null;Search.actualMyPosCategoryIDs=null;Search.actualClear=function(){Search.actualKeyword='';Search.actualCategory=null;Search.actualPobocka=null;Search.actualFirmID=null;Search.actualFirmIDs=null;Search.actualMyPosIDs=null;Search.actualClientCategoryIDs=null;}
Search.setActualKeyword=function(keyword){Search.actualClear();Search.actualKeyword=keyword;}
Search.setActualCategory=function(categoryID){Search.actualClear();Search.actualCategory=categoryID;}
Search.setActualPobocka=function(pobockaID){Search.actualClear();Search.actualPobocka=pobockaID;}
Search.setActualFirmID=function(ID){Search.actualClear();Search.actualFirmID=ID;}
Search.setActualFirmIDs=function(IDsArray){Search.actualClear();Search.actualFirmIDs=IDsArray;}
Search.setActualMyPosIDs=function(IDsArray){Search.actualClear();Search.actualMyPosIDs=IDsArray;}
Search.setActualClientCategoryIDs=function(CategoryIDs){Search.actualClear();Search.actualClientCategoryIDs=CategoryIDs;}
Search.setActualMyPosCategoryIDs=function(CategoryIDs){Search.actualClear();Search.actualMyPosCategoryIDs=CategoryIDs;}
Search.totalCount=0;Search.displayedCount=0;Search.object=null;Search.setObject=function(object){Search.object=object;Search.reset();}
Search.maxDisplayResult=300;Search.clearLastArea=function(){Search.last=new Area(null,null);}
Search.clearLastArea();Search.displayedAlreadyAll=function(){return Search.totalCount&&Search.totalCount==Search.displayedCount;}
Search.setLastArea=function(area){if(area)Search.last=area.getCopy();else Search.last=MapView.wholeArea;}
Search.clearItems=function(){var obj;for(var i=0;i<Search.buttons.length;i++){obj=getById(Search.buttons[i]);if(obj)obj.className="";}}
Search.activateItem=function(e){var obj=eventElement(e);if(obj&&obj.id.indexOf("search")===0&&obj.id!="searchbutton"){Search.clearItems();obj.className="selected";}}
Search.isInArea=function(area){return area.isInArea(Search.last)}
Search.keywordCheck=function(){var keyword=Search.keyword.value.trim();if(keyword.length<3){alert(text["3_znaky"]);Search.keyword.value=escape(keyword);Search.keyword.focus();return false;}
Search.setActualKeyword(keyword);return keyword;}
Search.reset=function(){Search.showAllLevel=false;Search.totalCount=0;}
Search.newSearch=function(){Search.lastSearch=new Array();}
Search.go=function(e){Search.keyword.blur();if(Search.keywordCheck()){Search.activateItem(e);Search.clearLastArea();Search.totalCount=0;getById('searchbutton').onclick=Search.form.onsubmit=function(){Search.go(e);return false;};getById('searchbutton').blur();MapView.setFnWhenFinished(Search.object.search);Search.object.reset();MapView.redraw();}
return false;}
Search.getActualKeywordForURL=function(){return escape(Search.actualKeyword);}
Search.load=function(plusURL){var mapa=MapView.actual;if(!mapa)mapa=Map.first_map;var area=mapa.getArea();if(!Search.isInArea(area)&&!Search.displayedAlreadyAll()){area=Area.compound(Search.last,area);Search.setLastArea(area);this.block(SuperNavigator.loadFrame);stopWatch.start();var area="&x1="+area.cornerUL.x+"&y1="+area.cornerUL.y+"&x2="+area.cornerBR.x+"&y2="+area.cornerBR.y;var plus=plusURL?"&"+plusURL:"";plus+="&"+SuperNavigator.SID;if(SuperNavigator.canZoomOptimal()&&(Search.actualFirmIDs||Search.actualMyPosIDs||Search.actualClientCategoryIDs||Search.actualMyPosCategoryIDs))plus+="&zoom2optimum";var script=".."+((!Search.actualMyPosIDs&&!Search.actualMyPosCategoryIDs)?"/navigator/search.php":"/mypositions/getmypositions.php");if(Search.actualKeyword!="")SuperNavigator.load(script+"?keyword="+Search.getActualKeywordForURL()+"&what="+Search.object.name+area+plus);else if(Search.actualCategory)SuperNavigator.load(script+"?category="+Search.actualCategory+"&what="+Search.object.name+area+plus);else if(Search.actualPobocka)SuperNavigator.load(script+"?pobocka="+Search.actualPobocka+"&what="+Search.object.name+area+plus);else if(Search.actualFirmID)SuperNavigator.load(script+"?"+Search.object.name.LCFirst()+"ID="+Search.actualFirmID+"&what="+Search.object.name+plus);else if(Search.actualFirmIDs)SuperNavigator.load(script+"?"+Search.object.name.LCFirst()+"IDs="+Search.actualFirmIDs.implode(",")+"&what="+Search.object.name+plus);else if(Search.actualMyPosIDs)SuperNavigator.load(script+"?"+Search.object.name.LCFirst()+"IDs="+Search.actualMyPosIDs.implode(",")+"&firmID="+SuperNavigator.loggedFirm.id+"&what=load"+plus);else if(Search.actualMyPosCategoryIDs)SuperNavigator.load(script+"?"+Search.object.name.LCFirst()+"CategoryIDs="+Search.actualMyPosCategoryIDs.implode(",")+"&firmID="+SuperNavigator.loggedFirm.id+"&what=load"+plus);else if(Search.actualClientCategoryIDs)SuperNavigator.load(script+"?clientCategoryIDs="+Search.actualClientCategoryIDs.implode(",")+"&what="+Search.object.name+plus);Search.changeHeader();}
else{Search.redraw();}}
Search.point2ObjectOnMap=function(obj){MapView.showPointer(obj.position.toScreenFromBase());}
Search.hidePointerOnMap=function(){MapView.hidePointer();}
Search.zoom2max=function(obj){if(obj){obj.visit();if(obj.position){if(obj.city)MapView.zoom2max(obj.position,obj.city.id);else
MapView.zoom2max(obj.position);}}}
Search.goBack=function(e){if(rightMouse(e)){MapView.setFnWhenFinished(null);if(Search.actualCategory)Category.backUpOneLevel(e);else
Category.backToRoot(e);}}
Search.sortByNameFn=function(a,b){var an=a.name.bootless();var bn=b.name.bootless();if(an>bn)return 1;if(an<bn)return-1;if(a.city&&b.city){var an=a.city.name.bootless();var bn=b.city.name.bootless();if(an>bn)return 1;if(an<bn)return-1;}
if(a.street&&b.street){var an=a.street.name.bootless();var bn=b.street.name.bootless();if(an>bn)return 1;if(an<bn)return-1;}
if(a.id>b.id)return 1;else return-1;return 0;}
Search.sortByStreetFn=function(a,b){if(!a.street&&b.street)return-1;if(a.street&&!b.street)return 1;if(a.street&&b.street){var an=a.street.name.bootless();var bn=b.street.name.bootless();if(an>bn)return 1;if(an<bn)return-1;}
var an=a.name.bootless();var bn=b.name.bootless();if(an>bn)return 1;if(an<bn)return-1;if(a.city&&b.city){var an=a.city.name.bootless();var bn=b.city.name.bootless();if(an>bn)return 1;if(an<bn)return-1;}
if(a.id>b.id)return 1;else return-1;return 0;}
Search.sortByCityFn=function(a,b){if(!a.city&&b.city)return-1;if(a.city&&!b.city)return 1;if(a.city&&b.city){var an=a.city.name.bootless();var bn=b.city.name.bootless();if(an>bn)return 1;if(an<bn)return-1;}
var an=a.name.bootless();var bn=b.name.bootless();if(an>bn)return 1;if(an<bn)return-1;if(a.street&&b.street){var an=a.street.name.bootless();var bn=b.street.name.bootless();if(an>bn)return 1;if(an<bn)return-1;}
return 0;}
Search.sortPrimaryFn=function(a,b){return a.suborder-b.suborder;}
Search.howToSort=function(){return this.sorting[this.zoradit_objekty];}
Search.isSortDefault=function(){return Search.object.zoradit_objekty==Search.object.zoradit_objekty_default;}
Search.printTotalCount=function(){var countObj;for(var i=0;i<Search.objects.length;i++)if(Search.objects[i]){countObj=getById(Search.objects[i].htmlMenuID+'total_count');if(countObj)countObj.innerHTML=Search.totalCount;countObj=getById(Search.objects[i].htmlMenuID+'total_count2');if(countObj)countObj.innerHTML=Search.objects[i].totalCount;}}
Search.printAktualnyPocet=function(kolko){var countObj;for(var i=0;i<Search.objects.length;i++)if(Search.objects[i]){if(!kolko)var kolko=Search.displayedCount;countObj=getById(Search.objects[i].htmlMenuID+'pocet_zobrazenych');if(countObj)countObj.innerHTML=kolko;countObj=getById(Search.objects[i].htmlMenuID+'pocet_zobrazenych2');if(countObj)countObj.innerHTML=kolko;}}
Search.resetAllCountsInClasses=function(){for(var i=0;i<Search.objects.length;i++)if(Search.objects[i])Search.objects[i].totalCount=Search.objects[i].displayedCount=0;}
Search.makeObjectVisited=function(obj,hideIt,notVisitedBoolean){if(!obj.visited||notVisitedBoolean){obj.visited=!notVisitedBoolean;var CLASS=obj.constructor;var MENUobj=getById(CLASS.htmlMenuID+obj.id);var MAPobj=getById(CLASS.htmlMapID+obj.id);if(MENUobj&&(MENUobj.className=="item"||MENUobj.className=="item special"||MENUobj.className=="itemSelected")&&!notVisitedBoolean)MENUobj.className="item visited";else
MENUobj.className=MENUobj.className.replace(" visited","");if(MAPobj){if(!notVisitedBoolean&&MAPobj.firstChild.src==icons[CLASS.defaultIcon[MapView.actual.map.level]].src)MAPobj.firstChild.src=icons[CLASS.defaultVisitedIcon[MapView.actual.map.level]].src;else if(notVisitedBoolean&&MAPobj.firstChild.src==icons[CLASS.defaultVisitedIcon[MapView.actual.map.level]].src)MAPobj.firstChild.src=icons[CLASS.defaultIcon[MapView.actual.map.level]].src;}
if(hideIt){Search.displayedCount--;obj.constructor.displayedCount--;Search.printAktualnyPocet();if(MENUobj)MENUobj.style.display="none";if(MAPobj)MAPobj.style.display="none";if(Search.displayedCount<8){var obj=getById('pocet2');if(obj)obj.style.display="none";}
if(Search.displayedCount==0){MapView.clear();Search.redraw();}}}}
Search.getPocetHTML=function(loadBoolean,CLASS){var HTML="";HTML+='<div id="pocet1"><div class="pocty_celkom">';HTML+='<span class="text">'+CLASS.get_celkovy_pocet_text()+':</span>';HTML+='<span class="cislo" id="'+CLASS.htmlMenuID+'total_count">'+Search.totalCount+'</span>';HTML+="</div>\n";HTML+='<div class="pocty">';HTML+='<span class="text">'+CLASS.get_pocet_text()+':</span>';HTML+='<span class="cislo" id="'+CLASS.htmlMenuID+'pocet_zobrazenych">'+(loadBoolean?"???":CLASS.displayedCount)+"</span>";HTML+="</div></div>\n";return HTML;}
Search.showAllLevel=false;Search.showAll=function(){Search.showAllLevel=MapView.actual.map.level;MapView.redraw();}
Search.changeHeader=function(){if(window.Category){Category.MenuHeader(Search.object.get_menuHeader_text());Category.MenuLink(text["spat_na_uvodne"],Category.toRootFalse);}}
Search.zobrazovat_alebo_ne=function(obj){return(((!obj.visited&&obj.constructor.zobrazovat_objekty!=3)||obj.constructor.zobrazovat_objekty<2)||(obj.visited&&obj.constructor.zobrazovat_objekty==3))}
Search.printIndex=0;Search.redraw=function(onlyHeader){var CLASS=Search.object;if(!CLASS||(window.Category&&CLASS==Category))return false;if("first"in CLASS)CLASS.first=null;if(window.Category)Category.ScrollOnTop();var mapHTML="";var menuHTML="";var area=MapView.actual.getArea();var aLevel=MapView.actual.map.level;var ikona=icons[CLASS.defaultIcon[aLevel]];var ikonaVis=icons[CLASS.defaultVisitedIcon[aLevel]];addHalfIcon(ikona);addHalfIcon(ikonaVis);Search.resetAllCountsInClasses();if(CLASS.defaultSpecialIcon){var ikonaSpecial=icons[CLASS.defaultSpecialIcon[aLevel]];addHalfIcon(ikonaSpecial);}
if(!onlyHeader){if(window.Category)Category.Div.onmousedown=Search.goBack;var objekty=new Array();var objekty_bez_pozicie=new Array();var objekty_vypisane=new Array();var i=0;var k=0;var previous;var pocet_celkom=0;var pocet_in_area=0;var id,obj;var Classes=new Array();for(id in Search.lastSearch)if(typeof(Search.lastSearch[id])=="object"){obj=Search.lastSearch[id];if(!Classes.contain(obj.constructor))Classes.push(obj.constructor);if(!obj.position&&(!MapView.actualCity||obj.city.id==MapView.actualCity.id)&&Search.zobrazovat_alebo_ne(obj)){objekty_bez_pozicie[k++]=obj;pocet_in_area++;}
else if(obj.position&&obj.position.isInArea(MapView.actual.getArea())){if(i==0&&"first"in CLASS)CLASS.first=obj;if(previous)previous.next=obj;previous=obj;if(Search.zobrazovat_alebo_ne(obj)){objekty[i++]=obj;obj.constructor.displayedCount++;}
pocet_in_area++;}
obj.constructor.totalCount++;pocet_celkom++;}
if(previous)previous.next=null;Search.displayedCount=0;var pocet_adeptov_na_cyklus=objekty.length;Search.changeHeader();if(window.Category&&(!Search.isSortDefault()||browser.isOP))objekty.sort(CLASS.howToSort());if(window.Category)objekty.sort(Search.sortPrimaryFn);var temp1="";var temp2="";Search.printIndex=0;var load_step=50/pocet_adeptov_na_cyklus;var load_phase=0;var priliz_vela=function(){return(!Search.showAllLevel||(Search.showAllLevel>MapView.actual.map.level))&&(pocet_adeptov_na_cyklus>Search.maxDisplayResult);}
var icon;if(priliz_vela()){var pos,posArray;icon=icons[Search.defaultIconMaxDisplayResult[MapView.actual.map.level]];addHalfIcon(icon);var uz_je=new Array();var koef=1/(parseInt(icon.width)*1);var pocet_casti=parseInt(MapView.getWidth()*koef);for(var i=0;i<pocet_adeptov_na_cyklus;i++){pos=objekty[i].position.toScreenFromBase().floor();posArray=parseInt(pos.x*koef)+parseInt(pos.y*koef)*pocet_casti;pos.minus(icon.half);if(uz_je[posArray]!==1){uz_je[posArray]=1;temp1+='<img src="'+icon.src+'" class="si" style="'+pos.printToStyleHTML()+'" onclick="return MapView.zoomClick();" />';if(temp1.length>1024){mapHTML+=temp1;temp1="";}}
Search.displayedCount++;}}
else{var actualClass;for(var i=0;i<pocet_adeptov_na_cyklus;i++){if(!actualClass||actualClass!=objekty[i].constructor){actualClass=objekty[i].constructor;temp2+=Search.getPocetHTML(false,actualClass);}
if(Math.floor(load_phase+load_step)==Math.floor(load_phase)+1)SuperNavigator.message(text["vysledok_sa_pripravuje"]+" "+Math.floor(load_phase)+"%");load_phase+=load_step;if(objekty[i].special)icon=ikonaSpecial;else if(objekty[i].visited&&(CLASS.zobrazovat_objekty==1||CLASS.zobrazovat_objekty==3))icon=ikonaVis;else
icon=ikona;temp1+=objekty[i].add2MapHTML(icon);temp2+=objekty[i].add2MenuHTML();Search.printIndex++;objekty_vypisane[Search.displayedCount]=objekty[i];Search.displayedCount++;if(temp1.length>1024){mapHTML+=temp1;temp1="";}
if(temp2.length>1024){menuHTML+=temp2;temp2="";}}}
if(!priliz_vela()){var pocet_adeptov_na_cyklus_bez_pozicie=objekty_bez_pozicie.length;var obj;var k=0;var bezpozHTML="";for(var i=0;i<pocet_adeptov_na_cyklus_bez_pozicie;i++){obj=objekty_bez_pozicie[i];bezpozHTML+=obj.add2MenuHTML();Search.printIndex++;objekty_vypisane[Search.displayedCount]=obj;Search.displayedCount++;k++;}
if(k>0)temp2+="<div class=\"bez_pozicie\">"+text["bez_pozicie"]+"</div>"+bezpozHTML;}
mapHTML+=temp1;menuHTML+=temp2;var pocetHTML=Search.getPocetHTML(false,CLASS);if(priliz_vela()){menuHTML+="<div class=\"alert toomuch\">";menuHTML+=text["velmi_vela_vysledkov"];menuHTML+="</div>\n";menuHTML+='<input type="button" value="'+text["pokracovat_budem_cakat"]+'" onclick="Search.showAll()" />\n';}
else{if(Search.displayedCount>4*MapView.size.y)menuHTML+="<br />"+pocetHTML.replace(CLASS.htmlMenuID+'total_count',CLASS.htmlMenuID+'total_count2').replace(CLASS.htmlMenuID+'pocet_zobrazenych',CLASS.htmlMenuID+'pocet_zobrazenych2').replace('pocet1','pocet2');if(Search.totalCount==0){menuHTML+="<div class=\"alert\">"+CLASS.get_nic_nenaslo_text()+"</div>\n";if(Search.keyword)Search.keyword.focus();}
else
if(Search.totalCount>0&&Search.displayedCount==0&&pocet_in_area==0)menuHTML+="<div class=\"alert\">"+CLASS.get_naslo_inde_text()+"</div>\n";else
{if(pocet_in_area>0&&Search.displayedCount==0)menuHTML+=CLASS.get_skryte_text(pocet_in_area-Search.displayedCount);menuHTML+="<br />\n";menuHTML+=CLASS.get_moznosti_zobrazovania_text();if(Search.displayedCount>4*MapView.size.y)menuHTML+=CLASS.get_moznosti_zoradovania_text();}
menuHTML+="<br />\n";}}
else{if(Search.totalCount>0)menuHTML+=Search.getPocetHTML(true,CLASS);menuHTML+="<div class=\"message wait\">";menuHTML+=text["cakajte_process"];menuHTML+="</div>\n";menuHTML+="<div class=\"message tip\">";menuHTML+="<h3>"+text["tip_dlha_chvila"]+"</h3>";var nahodne_cislo=Math.round(Math.random()*(SuperNavigator.pocetTipov-1))+1;menuHTML+=text["tip_"+nahodne_cislo.zerofill(2)];menuHTML+="</div>\n";}
if(window.Category&&Search.actualCategory)menuHTML=Category.makePathMenu(Search.actualCategory)+"<br />"+menuHTML;MapView.objectsDiv.innerHTML+=mapHTML;if(window.Category)Category.Div.innerHTML=menuHTML;if(window.MyPosition&&SuperNavigator.loggedFirm.id)MyPosition.redraw();if(priliz_vela&&!priliz_vela()){var objMap=null;var objMenu=null;for(var i=0;i<Search.displayedCount;i++){if(Math.floor(load_phase+load_step)==Math.floor(load_phase)+1)SuperNavigator.message(text["vysledok_sa_pripravuje"]+" "+Math.floor(load_phase)+"%");load_phase+=load_step;CLASS=objekty_vypisane[i].constructor;objMap=getById(CLASS.htmlMapID+objekty_vypisane[i].id);if(objMap){objMap.realObject=objekty_vypisane[i];if(window.Category)objMap.onmouseover=Search.highlightInMenu_on;if(window.Category)objMap.onmouseout=Search.highlightInMenu_off;objMap.onclick=Search.click;}
objMenu=getById(CLASS.htmlMenuID+objekty_vypisane[i].id);if(objMenu){objMenu.realObject=objekty_vypisane[i];if(objMap){objMenu.onmouseover=Search.showOnMap;objMenu.onmouseout=Search.hideOnMap;}
objMenu.onclick=Search.click;if(objMenu.lastChild.nodeName=="DIV")objMenu.lastChild.onmouseover=Search.E_hideLogo;}}}
SuperNavigator.message();if(priliz_vela&&!priliz_vela())for(var i=0;i<Classes.length;i++)if(Classes[i].loadIcons)Classes[i].loadIcons();}
Search.click=function(){if(SuperNavigator.clientsProfileURL)window.open(SuperNavigator.clientsProfileURL+"?id="+this.realObject.id,"win"+this.realObject.id);else if(!SuperNavigator.cannotOpenProfiles)this.realObject.click();return false;}
Search.loadLogo=function(imgObj){if(imgObj.name!=""){imgObj.src=imgObj.name;imgObj.name="";}}
Search.highlightInMenu_on=function(e){var object=("realObject"in this)?this.realObject:e;var CLASS=object.constructor;var elementHTML=getById(CLASS.htmlMenuID+object.id);if(!elementHTML)return false;if(elementHTML.lastChild.nodeName=="DIV")Search.loadLogo(elementHTML.lastChild.firstChild);if(window.Category)Category.highlight_on(elementHTML);}
Search.highlightInMenu_off=function(e){var object=("realObject"in this)?this.realObject:e;var CLASS=object.constructor;var elementHTML=getById(CLASS.htmlMenuID+object.id);if(!elementHTML)return false;Category.highlight_off(elementHTML);}
Search.showOnMap=function(e){var object=("realObject"in this)?this.realObject:e;var CLASS=object.constructor;var elementHTML=getById(CLASS.htmlMenuID+object.id);if(!elementHTML)return false;Search.point2ObjectOnMap(object);Search.showLogo(elementHTML);}
Search.hideOnMap=function(e){var object=("realObject"in this)?this.realObject:e;var CLASS=object.constructor;Search.hidePointerOnMap();var elementHTML=getById(CLASS.htmlMenuID+object.id);if(!elementHTML)return false;Search.hideLogo(elementHTML);}
Search.showLogo=function(elementHTML){if(elementHTML.lastChild.nodeName=="DIV"){Search.loadLogo(elementHTML.lastChild.firstChild);elementHTML.lastChild.style.display="block";}}
Search.E_hideLogo=function(e){var obj=eventElement(e);if(obj.nodeName=="IMG")obj=obj.parentNode;Search.hideLogo(obj);stopBubbling(e);}
Search.hideLogo=function(elementHTML){if(elementHTML.lastChild.nodeName=="DIV")elementHTML.lastChild.style.display="none";}
Search.zoom2optimum=function(CLASS){var city=-1;var cityBool=false;var area=new Area();area.cornerUL=new Position(1000,1000);area.cornerBR=new Position(0,0);var id;var objekty=(!window.MyPosition||CLASS!=MyPosition)?Search.lastSearch:MyPosition.lastSearch;for(id in objekty)if(typeof(objekty[id])=="object"&&objekty[id].constructor==CLASS){if(area.cornerUL.x>objekty[id].position.x)area.cornerUL.x=objekty[id].position.x;if(area.cornerBR.x<objekty[id].position.x)area.cornerBR.x=objekty[id].position.x;if(area.cornerUL.y>objekty[id].position.y)area.cornerUL.y=objekty[id].position.y;if(area.cornerBR.y<objekty[id].position.y)area.cornerBR.y=objekty[id].position.y;if(city!=objekty[id].city&&!cityBool){city=objekty[id].city;cityBool=true;}
else if(city!=objekty[id].city&&cityBool)city=-1;}
if(city===-1)city=null;if(city){if(mapCity[city.id]&&!mapCity[city.id].haveLoadedMaps()){if(this.isStack)this.free();var center=area.getCenter();stack.addProcess(Map.load_mapu_mesta,25.5,city.id,Map.max_level_statu+1,center.x,center.y);stack.addProcess(CLASS.zoom2optimum,Map.processCode);return false;}}
MapView.zoom2optimum(area,city);}
Search.searchAndZoomObjectByID=function(objID,CLASS){Search.clearLastArea();Search.setObject(CLASS);Search.setActualFirmID(objID);MapView.setFnWhenFinished(null);stack.addProcess(Search.load,Map.processCode);return false;}
Search.searchAndZoomObjectByIDs=function(objectIDs,CLASS){Search.clearLastArea();Search.setObject(CLASS);if(CLASS==Firm)Search.setActualFirmIDs(objectIDs);else if(CLASS==MyPosition)Search.setActualMyPosIDs(objectIDs);MapView.setFnWhenFinished(null);stack.addProcess(Search.load,Map.processCode);return false;}
Search.searchAndZoomObjectByCategoryIDs=function(CategoryIDs,CLASS){Search.clearLastArea();Search.setObject(CLASS);if(CLASS==Firm)Search.setActualClientCategoryIDs(CategoryIDs);else if(CLASS==MyPosition)Search.setActualMyPosCategoryIDs(CategoryIDs);MapView.setFnWhenFinished(null);stack.addProcess(Search.load,Map.processCode);return false;}
Search.searchInCategory=function(categoryObj){Search.clearLastArea();if(categoryObj.special=="no")Search.setObject(Firm);if(categoryObj.special=="realitna")Search.setObject(Property);if(categoryObj.special=="no"||categoryObj.special=="realitna"){Search.setActualCategory(categoryObj.id);Category.aktivna=categoryObj;}
else if(categoryObj.special=="mesta"){Search.setObject(City);Search.setActualKeyword('[vsetky mesta s mapou]');}
if(Search.keyword)Search.keyword.value='';MapView.setFnWhenFinished(Firm.search);MapView.redraw();return false;}
Search.searchInPobocka=function(pobID){Search.setObject(Firm);Search.clearLastArea();Search.setActualPobocka(pobID);MapView.setFnWhenFinished(null);if(Search.keyword)Search.keyword.value='';stack.addProcess(Search.load,Map.processCode,"zoom2optimum=true");return false;}
Search.MapHTML="";Search.MenuHTML="";Search.pos="";Search.add2MapHTML=function(icon){Search.MapHTML="";Search.pos=this.position.toScreenFromBase().minus(icon.half);Search.MapHTML+='<a id="'+this.constructor.htmlMapID+this.id+'" class="i" href="" ';Search.MapHTML+='style="'+Search.pos.printToStyleHTML()+'"';Search.MapHTML+='><img src="'+icon.src+'"';if(!window.Category){Search.MapHTML+=' title="'+this.name;Search.MapHTML+=(!browser.isIE)?", ":"\n";Search.MapHTML+=this.printAddress()+'"';}
Search.MapHTML+=' />';Search.MapHTML+='<var>'+(Search.printIndex+1)+'.</var></a>';return Search.MapHTML;}
Search.add2MenuHTML=function(){Search.MenuHTML="";Search.MenuHTML+='<a id="'+this.constructor.htmlMenuID+this.id+'" href="" class="item';if(this.visited&&(this.constructor.zobrazovat_objekty==1||this.constructor.zobrazovat_objekty==3))Search.MenuHTML+=' visited';if(this.special&&(!this.visited||(this.constructor.zobrazovat_objekty!=1&&this.constructor.zobrazovat_objekty!=3)))Search.MenuHTML+=' special';if(this.font)Search.MenuHTML+=' font';Search.MenuHTML+='">';Search.MenuHTML+='<var>'+(Search.printIndex+1)+'.</var><strong';if(this.font){Search.MenuHTML+=' class="'+this.font.replace(/ /g,'')+'font"';if(this.color)Search.MenuHTML+=' style="color: #'+this.color+';"';}
Search.MenuHTML+='>'+this.name+'</strong><address>'+this.printAddress()+"</address>";if(this.logo)Search.MenuHTML+='<div><img src="../img/im.gif" border="1" name="'+SuperNavigator.dataFolder+"logos/"+this.logo+'" /></div>';Search.MenuHTML+='</a>';return Search.MenuHTML;}
Search.showOnProfileMapObject=null;Search.showOnProfileMap=function(priStarteMapy){if(!priStarteMapy){var obj=Search.showOnProfileMapObject;var CLASS=obj.constructor;var mapHTML="";var icon=icons[CLASS.defaultIcon[MapView.actual.map.level]];addHalfIcon(icon);var mapHTML="";var pos=obj.position.toScreenFromBase().round();mapHTML+='<div style="width:'+MapView.getWidth()+'px; height:'+pos.getY()+'px;" class="printposition" id="horizontalpositionline"></div>';mapHTML+='<div style="width:'+pos.getX()+'px; height:'+MapView.getHeight()+'px;" class="printposition" id="verticalpositionline"></div>';var box=new Size(11,11);var posBox=pos.getCopy().minus(box.getCopy().divide(2)).minus(1);mapHTML+='<div style="'+box.plus(1).printToStyleHTML()+posBox.printToStyleHTML()+'" class="printposition" id="positionbox"></div>';pos.minus(icon.half);mapHTML+='<a class="ikona" href="" ';mapHTML+='style="'+pos.printToStyleHTML()+'"';mapHTML+=' onclick="return false;"';mapHTML+='><img src="'+icon.src+'" /></a>';mapHTML+=here(obj.position);MapView.showOnProfile=vytvorHTMLElement("div","showOnProfile",MapView.mainDiv);MapView.showOnProfile.style.display="block";MapView.showOnProfile.style.position="absolute";MapView.showOnProfile.style.left="0px";MapView.showOnProfile.style.top="0px";MapView.showOnProfile.style.border="1px solid red";MapView.showOnProfile.style.zIndex="5";MapView.showOnProfile.innerHTML=mapHTML;MapView.showDistanceToPosition(obj.position);}}