var kijs_client_id="T3L1";var kijs_dir="http://maps.kartes.lv/kijs/";function LogoAndScale(A){var C=this;this.HideScale=function(){D.style.visibility="hidden"};this.ShowScale=function(){D.style.visibility="visible"};this.HideLogo=function(){F.style.visibility="hidden"};this.ShowLogo=function(){F.style.visibility="visible"};var F=CreateImageNoSelect();A.viewableMap.appendChild(F);F.src=kijs_dir+"images/logo.jpg";F.alt="Karšu izdevniecība Jāņa sēta";F.title="Karšu izdevniecība Jāņa sēta";F.onclick=function(){window.open("http://www.kartes.lv","_blank")};F.style.position="absolute";F.style.zIndex="4";F.style.cursor="pointer";F.style.left="10px";F.style.bottom="10px";var D=document.createElement("div");A.viewableMap.appendChild(D);D.style.zIndex="4";D.style.position="absolute";D.style.left="55px";D.style.bottom="10px";this.scale_image=CreateImageNoSelect();D.appendChild(this.scale_image);this.scale_image.src=kijs_dir+"/images/scale.gif";var B=document.createElement("div");D.appendChild(B);B.style.position="absolute";B.style.left="7px";B.style.top="0px";B.style.fontWeight="bold";B.style.fontFamily="Arial";B.style.fontSize="12px";B.style.color="black";B.style.padding="0px";B.style.margin="0px";this.scale_in_meters=0;this.GetScale=function(){G();return this.scale_in_meters};A.event_after_level_changed.AddCallback(G);function G(){if(A.tile_width_meter==null){return }if(A.tile_width_pix==null){return }var J="";var H=102;C.scale_in_meters=HorisontalPixelsToMeters(H,A.tile_width_meter,A.tile_width_pix);var I="";if(C.scale_in_meters<100){I=(Math.round(C.scale_in_meters))+" m"}else{if(C.scale_in_meters<1000){I=(Math.round(C.scale_in_meters/10)*10)+" m"}else{if(C.scale_in_meters<5000){I=(Math.round(C.scale_in_meters/100)*100/1000)+" km"}else{if(C.scale_in_meters<100000){I=(Math.round(C.scale_in_meters/1000))+" km"}else{I=(Math.round(C.scale_in_meters/10000)*10000/1000)+" km"}}}}B.innerHTML=I}G();Kijs_SetOpacity(D,0.7)}function DomTable(C){this.table=document.createElement("table");C.appendChild(this.table);this.style=this.table.style;var B=0;var A=null;this.AddRow=function(){A=this.table.insertRow(B++)};this.AddCell=function(){if(A==null){return false}var D=document.createElement("td");A.appendChild(D);return D};this.AddCellText=function(F){var D=this.AddCell();var G=document.createElement("div");D.appendChild(G);G.innerHTML=F;return G};this.AddCellInput=function(G){var D=this.AddCell();var F=document.createElement("input");F.type="text";D.appendChild(F);F.style.width=G+"px";return F};this.AddCellInputWithText=function(H,G){var D=this.AddCell();var F=document.createElement("input");F.type="text";D.appendChild(F);F.style.width=H+"px";var I=document.createElement("span");D.appendChild(I);I.innerHTML=G;return F}}var kijs_weather_list=new Array();function KijsWeather(A){var H=this;var F=A.navigation_frame.AddButton(kijs_dir+"server_scripts/weather/weather_off.png",kijs_dir+"server_scripts/weather/weather_on.png",24,24,"Laika apstākļu slānis",I);function I(K){if(K==true){H.ShowImages()}else{H.HideImages()}}this.event_loaded=new Event();this.LoadImages=function(K){if(kijs_weather_list.length==0){A.loader.Show();call_back.LoadJson(kijs_dir+"/server_scripts/weather/get_data_json.php?kijs="+kijs_client_id,function(){K()})}else{K()}};this.ShowImages=function(){B=true;this.LoadImages(J)};this.HideImages=function(){B=false;G()};this.ShowButton=function(){F.style.display="block"};this.HideButton=function(){F.style.display="none"};var D=new Array();var C=new Array();var B=false;function J(){G();if(kijs_weather_list.length==0||B==false){A.loader.Hide();return }var K=A.MapCorners();A.loader.Show();for(var L=0;LK.x_min&&kijs_weather_list[L].xK.y_min&&kijs_weather_list[L].y100){this.value=100}if(this.value<1){this.value=1}F.svg.points.SetRadius(O,this.value)};W.AddRow();W.AddCellText("Līnijas krāsa");var N=W.AddCell();var V=new ColorPicker(N);V.event_color_changed.AddCallback(function(X){F.svg.points.SetStrokeColor(O,X.r,X.g,X.b)});W.AddRow();W.AddCellText("Līnijas platums");var J=W.AddCellInputWithText(30," (1-50)");J.maxLength=2;J.value=F.svg.points.GetStroke(O).width;J.onblur=function(){if(this.value>50){this.value=50}if(this.value<1){this.value=1}F.svg.points.SetStrokeWidth(O,this.value)};W.AddRow();W.AddCellText("Līnijas
caurspīdīgums");var T=W.AddCellInputWithText(30," (1-100)");T.maxLength=3;T.value=F.svg.points.GetStroke(O).color[3]*100;T.onblur=function(){if(this.value>100){this.value=100}if(this.value<1){this.value=1}F.svg.points.SetStrokeOpacity(O,this.value/100)};W.AddRow();W.AddCellText("Aizpildījuma krāsa");var N=W.AddCell();var V=new ColorPicker(N);V.event_color_changed.AddCallback(function(X){F.svg.points.SetFillColor(O,X.r,X.g,X.b)});W.AddRow();W.AddCellText("Aizpildījuma
caurspīdīgums");var M=W.AddCellInputWithText(30," (1-100)");M.maxLength=3;M.value=F.svg.points.GetFill(O)[3]*100;M.onblur=function(){if(this.value>100){this.value=100}if(this.value<1){this.value=1}F.svg.points.SetFillOpacity(O,this.value/100)};W.AddRow();var L=W.AddCell();var R=W.AddCell();R.align="right";var I=document.createElement("input");I.type="button";R.appendChild(I);I.value="Saglabāt";I.onclick=function(){B(O)};F.info_box.ShowNoContextChange(K,H,10,10)}catch(S){alert("Error SavePoint(). "+S.message)}};this.event_user_point_saved=new Event();function B(G){var H={};H.name=F.svg.points.GetCustomParameter(G,"name");H.description=F.svg.points.GetCustomParameter(G,"descr");H.stroke=F.svg.points.GetStroke(G);H.fill=F.svg.points.GetFill(G);H.point_id=G;H.x=F.svg.points.Get_LKS_X(G);H.y=F.svg.points.Get_LKS_Y(G);D.event_user_point_saved.Fire(H);F.info_box.Hide()}this.Show=function(S,I,G){F.info_box.Hide();F.info_box.context.innerHTML="";var T=new DomTable(F.info_box.context);T.AddRow();T.AddCellText("Nosaukums");var O=T.AddCellInput(200);O.value=F.svg.lines.GetCustomParameter(S,"name");O.onblur=function(){F.svg.lines.SetCustomParameter(S,"name",this.value)};T.AddRow();T.AddCellText("Apraksts");var R=T.AddCell();var M=document.createElement("textarea");R.appendChild(M);M.style.width="200px";M.style.height="35px";M.value=F.svg.lines.GetCustomParameter(S,"descr");M.onblur=function(){F.svg.lines.SetCustomParameter(S,"descr",this.value)};T.AddRow();T.AddCellText("Līnijas platums");var V=T.AddCellInputWithText(30," (1-50)");V.maxLength=2;V.value=F.svg.lines.GetStrokeWidth(S);V.onblur=function(){if(this.value>50){this.value=50}if(this.value<1){this.value=1}F.svg.lines.SetStrokeWidth(S,this.value)};T.AddRow();T.AddCellText("Līnijas krāsa");var L=T.AddCell();var U=new ColorPicker(L);U.event_color_changed.AddCallback(function(W){F.svg.lines.ChangeStrokeColor(S,W.r,W.g,W.b)});T.AddRow();T.AddCellText("Līnijas
caurspīdīgums");var P=T.AddCellInputWithText(30," (1-100)");P.maxLength=3;P.value=F.svg.lines.GetStrokeOpacity(S)*100;P.onblur=function(){if(this.value>100){this.value=100}if(this.value<1){this.value=1}F.svg.lines.SetStrokeOpacity(S,this.value/100)};if(F.svg.lines.GetFill(S)!=null){T.AddRow();T.AddCellText("Aizpildījuma krāsa");var L=T.AddCell();var K=new ColorPicker(L);K.event_color_changed.AddCallback(function(W){F.svg.lines.ChangeFillColor(S,W.r,W.g,W.b)});T.AddRow();T.AddCellText("Aizpildījuma
caurspīdīgums");var N=T.AddCellInputWithText(30," (1-100)");N.maxLength=3;N.value=F.svg.lines.GetFillOpacity(S)*100;N.onblur=function(){if(this.value>100){this.value=100}if(this.value<1){this.value=1}F.svg.lines.SetFillOpacity(S,this.value/100)}}T.AddRow();var J=T.AddCell();var Q=T.AddCell();Q.align="right";var H=document.createElement("input");H.type="button";Q.appendChild(H);H.value="Saglabāt";H.onclick=function(){A(S)};F.info_box.ShowNoContextChange(I,G,10,10)};this.event_user_line_saved=new Event();this.event_user_polygon_saved=new Event();function A(G){var I={};I.line_id=G;var H=F.svg.lines.GetLine(G).points;for(i=0;i=0&&B>=0&&I>=0&&G>=0){return{p1x:C,p1y:B,p2x:I,p2y:G}}else{var F=_GetXYCrosspoints(C,B,I,G);if(F.crossx<=0&&F.crossy<=0){return false}else{var A=null;var K=null;if(C>=0&&B>=0){A={x:C,y:B}}if(I>=0&&G>=0){if(A==null){A={x:I,y:G}}else{if(K==null){K={x:I,y:G}}}}if(F.crossy>=0&&((C>=0&&I<=0)||(I>=0&&C<=0))){if(A==null){A={x:0,y:F.crossy}}else{if(K==null){K={x:0,y:F.crossy}}}}if(F.crossx>=0&&((B>=0&&G<=0)||(G>=0&&B<=0))){if(A==null){A={x:F.crossx,y:0}}else{if(K==null){K={x:F.crossx,y:0}}}}A.x=Math.round(A.x);A.y=Math.round(A.y);K.x=Math.round(K.x);K.y=Math.round(K.y);var H=Math.abs(A.x-C);var D=Math.abs(K.x-I);if(H>D){var J=A;A=K;K=J}return{p1x:A.x,p1y:A.y,p2x:K.x,p2y:K.y}}}}}}}}}function _GetXYCrosspoints(B,A,D,C){if(A==0&&C==0){return{crossx:null,crossy:0}}else{if(B==0&&D==0){return{crossx:0,crossy:null}}else{var F=_GetLineEquation(B,A,D,C);return{crossx:-F.b/F.m,crossy:F.b}}}}function _GetLineEquation(D,C,G,F){var B=(F-C)/(G-D);var A=C-B*D;return{m:B,b:A}}function InfoBox(A){var C=A.GetWholeMap();var P=this;this.get_box_element=function(){return L};var L=document.createElement("div");C.appendChild(L);this.BoxStyle=function(){return L.style};this.SetClassName=function(Q){L.className=Q};L.style.color="black";L.style.padding="0px";L.style.backgroundColor="#FFFFFF";L.style.border="1px solid green";L.style.top="0px";L.style.left="0px";N(L,320,100);L.onmousedown=function(Q){if(!Q){var Q=window.event}Q.cancelBubble=true;if(Q.stopPropagation){Q.stopPropagation()}};L.style.display="none";L.style.position="absolute";L.style.zIndex="3";L.style.fontSize="12px";L.style.fontFamily="Tahoma";this.close_button_active_src=kijs_dir+"images/arrows/close_akt.gif";this.close_button_not_active_src=kijs_dir+"images/arrows/close_neakt.gif";var D=document.createElement("img");L.appendChild(D);D.src=this.close_button_not_active_src;D.onmouseover=function(){this.src=P.close_button_active_src};D.onmouseout=function(){this.src=P.close_button_not_active_src};D.onclick=function(){P.context.innerHTML="";L.style.display="none"};D.style.cursor="pointer";D.style.styleFloat="right";D.style.cssFloat="right";this.CloseButton=function(){return D};this.context=document.createElement("div");L.appendChild(this.context);this.context.style.padding="4px";function N(T,S,Q){var U=(S=="")?"":S+"px";var R=(Q=="")?"":Q+"px";T.style.width=U;if(kijs_user_browser.ie6==true&&kijs_user_browser.ie7==false){T.style.height=R}else{if(typeof document.documentElement.style.minHeight!="undefined"){T.style.minHeight=R}else{T.style.height=R}}}this.SetWidthHeight=function(R,Q){N(L,R,Q)};this.SetOpacity=function(Q){Kijs_SetOpacity(L,Q/100)};this.SetOpacity(100);this.Remove=function(){C.removeChild(L)};this.Hide=function(){L.style.display="none"};function O(){if(L.style.display=="none"){return false}else{return true}}var I=null;var H=null;var F=null;var B=null;this.show_in_map_frame=true;this.Show=function(S,Q,R,U,T){I=S;H=Q;this.context.innerHTML=R;F=U;B=T;M(this.show_in_map_frame)};this.ShowNoContextChange=function(R,Q,T,S){I=R;H=Q;F=T;B=S;M(this.show_in_map_frame)};function M(R){if(I!=null&&H!=null){L.style.visibility="hidden";L.style.display="block";var U=MetersToPixels(A,I,H);L.style.left=U.x+F+"px";L.style.top=U.y+B+"px";var T=(U.x+F)+A.GetWholeMapLeft();var S=(U.y+B)+A.GetWholeMapTop();if(T>A.GetWiewableMapWidth()/2&&R==true){L.style.left=U.x-stripPx(L.style.width)-F+"px"}if(S>A.GetWiewableMapHeight()/2&&R==true){L.style.top=U.y-L.offsetHeight-B+"px"}if(R==true){var V=stripPx(L.style.left)+A.GetWholeMapLeft();var Q=stripPx(L.style.top)+A.GetWholeMapTop();if(V<45){L.style.left=stripPx(L.style.left)-V+45+"px"}if(Q<35){L.style.top=stripPx(L.style.top)-Q+35+"px"}}L.style.visibility="visible"}}A.event_before_level_changed.AddCallback(G);var K=false;function G(Q){if(O()==true){P.Hide();K=true}}A.event_after_level_changed.AddCallback(J);function J(Q){if(K==true){M(false)}K=false}}var kijs_admin_iedal;var kijs_lt_address;var kijs_address;var kijs_nature;var kijs_apdz_viet;var kijs_streets;var kijs_terit_vien;function SearchBox(map){var me=this;this.search_lv=true;this.search_lt=false;var search_window=new Window(map);search_window.title.innerHTML=kijs_language.SearchAddress;this.Show=function(){search_window.Show()};this.address_point_right_click=new Event();this.HideSearchButton=function(){image.style.display="none"};this.ShowSearchButton=function(){image.style.display="block"};var image_src=kijs_dir+"images/search.png";var cel=map.navigation_frame.AddCell();var image=document.createElement("div");cel.appendChild(image);Kijs_SetDivAlfaSrc(image,image_src,24,24);image.title=kijs_language.SearchAddress;image.style.cursor="pointer";image.onclick=function(){search_window.ToggleDisplay()};var search_box=document.createElement("input");search_box.type="text";search_window.content.appendChild(search_box);search_box.value="rīgas 2";search_box.value=kijs_language.InputAddress;search_box.style.width="160px";search_box.style.margin="4px";search_box.style.fontFamily="Tahoma";search_box.style.fontSize="11px";search_box.onkeydown=function(e){if(KijsKeyCode(e)==13){Search(this.value);return false}};var search_button=document.createElement("input");search_button.type="button";search_window.content.appendChild(search_button);search_button.value=kijs_language.Search;search_button.style.margin="4px";search_button.style.fontFamily="Tahoma";search_button.style.fontSize="11px";search_button.onclick=function(){Search(search_box.value)};var results_head=document.createElement("div");search_window.content.appendChild(results_head);results_head.innerHTML="";results_head.style.height="10px";var results=document.createElement("div");search_window.content.appendChild(results);results.style.width="95%";results.style.height="220px";results.style.border="1px solid #C0C0C0";results.style.padding="0px";results.style.margin="4px";results.style.textAlign="left";results.style.overflow="auto";this.SearchAddress=function(query,callback){var country_query="&lv=";country_query+=(me.search_lv==true)?"1":"0";country_query+="<=";country_query+=(me.search_lt==true)?"1":"0";query=query.trim();query=BaltToEng(query);call_back.LoadJson(kijs_dir+"server_scripts/search.php?kijs="+kijs_client_id+"&r="+query.Trim()+"&q="+query+country_query,callback)};this.Search=Search;function Search(query){if(search_button.disabled==true){return }search_box.value=query;query=query.trim();query=BaltToEng(query);if(query!=""){var image="";results.innerHTML="
"+image+"
";kijs_admin_iedal=null;kijs_lt_address=null;kijs_address=null;search_button.disabled=true;var country_query="&lv=";country_query+=(me.search_lv==true)?"1":"0";country_query+="<=";country_query+=(me.search_lt==true)?"1":"0";call_back.LoadJson(kijs_dir+"server_scripts/search.php?kijs="+kijs_client_id+"&r="+query.Trim()+"&q="+query+country_query,Callback)}}var result_street_rows=new Array();var active_street_point_id=null;function RemoveStreetPoint(){if(active_street_point_id!=null){map.svg.points.Remove(active_street_point_id);active_street_point_id=null}}function Callback(){RemoveStreetPoint();results.innerHTML="";result_street_rows=new Array();active_street_point_id=null;var count=0;if(kijs_admin_iedal){count+=kijs_admin_iedal.data.length}if(kijs_address){count+=kijs_address.length}var total=0;if(kijs_admin_iedal){total+=kijs_admin_iedal.total}if(kijs_address){total+=kijs_address_count}results_head.innerHTML=kijs_language.Results+" "+count+" "+kijs_language.From+" "+total;if(kijs_streets==null&&kijs_admin_iedal==null&&kijs_lt_address==null&&kijs_address==null&&kijs_terit_vien==null){var foo_text="Nekas netika atrasts";results.innerHTML="
"+foo_text+"
"}PrintPointResults("Apdzīvotas vietas",kijs_apdz_viet.data,kijs_apdz_viet.total);PrintPointResults("Kalni",kijs_nature.hills.data,kijs_nature.hills.total);PrintDrawingResults("Ezeri",kijs_nature.lakes.data,kijs_nature.lakes.total,me.ShowAndCenterLake);PrintDrawingResults("Upes",kijs_nature.rivers.data,kijs_nature.rivers.total,me.ShowAndCenterRiver);var all_streets_data=new Array();var all_streets_total=kijs_streets.lv.total+kijs_streets.lt.total+kijs_streets.lv_riga.total+kijs_streets.ee_tallina.total+kijs_streets.lt_vilna.total;for(var i=0;i0){var list=CreateResultList(caption_text);for(var i=0;iN){O=N}if(M==null||M>L){M=L}}}D.ShowPoints([{x:G,y:P},{x:O,y:M}],4)}function B(G){D.ShowPoints([{x:kijs_temp_parish_min_max.min_x,y:kijs_temp_parish_min_max.min_y},{x:kijs_temp_parish_min_max.max_x,y:kijs_temp_parish_min_max.max_y}]);var H=kijs_dir+"server_scripts/admin_iedal/draw_image.php?i="+kijs_temp_parish_index;F=D.tile_manager.AddWmsLayer([H],false)}}var kijs_road_work_list=new Array();function KijsRoadWork(A){var H=this;var F=A.navigation_frame.AddButton(kijs_dir+"images/road_work.png",kijs_dir+"images/road_work_active.png",24,24,"Ceļu remontu slānis",I);function I(K){if(K==true){H.ShowImages()}else{H.HideImages()}}this.event_loaded=new Event();this.LoadImages=function(K){if(kijs_road_work_list.length==0){A.loader.Show();call_back.LoadJson(kijs_dir+"/server_scripts/remonti/get_data_json.php?kijs="+kijs_client_id,function(){K()})}else{K()}};this.ShowImages=function(){B=true;this.LoadImages(J)};this.HideImages=function(){B=false;G()};this.ShowButton=function(){F.style.display="block"};this.HideButton=function(){F.style.display="none"};var D=new Array();var C=new Array();var B=false;function J(){G();if(kijs_road_work_list.length==0||B==false){A.loader.Hide();return }var K=A.MapCorners();A.loader.Show();if(A.zoom_level<=7){for(var L=0;LK.x_min&&kijs_road_work_list[L].xK.y_min&&kijs_road_work_list[L].y';this.topo_layer_active=false;this.switch_topo_button=H(200,"Topo","topo",I,"black",Array(kijs_dir+"server_scripts/topo/get_image.php"));this.ActivateTopo=function(){D(this.switch_topo_button,"topo")};this.ShowTopoButton=function(){this.switch_topo_button.style.display="block"};this.HideTopoButton=function(){this.switch_topo_button.style.display="none"};var B='';this.orto_layer_active=false;this.switch_orto_button=H(120,"Aerofoto","orto",B,"white",Array(kijs_dir+"server_scripts/orto/get_orto_foto.php"));this.ActivateOrto=function(){D(this.switch_orto_button,"orto")};this.ShowOrtoButton=function(){this.switch_orto_button.style.display="block"};this.HideOrtoButton=function(){this.switch_orto_button.style.display="none"};var K='';this.map_layer_active=false;this.switch_map_button=H(40,"Karte","map",K,"black",Array(kijs_dir+"get_map.php"));this.ActivateMap=function(){D(this.switch_map_button,"map")};this.ShowMapButton=function(){this.switch_map_button.style.display="block"};this.HideMapButton=function(){this.switch_map_button.style.display="none"};function D(M,L){if(M.my_active==true){return }G.topo_layer_active=(L=="topo")?true:false;G.orto_layer_active=(L=="orto")?true:false;G.map_layer_active=(L=="map")?true:false;J(M);if(A.main_wma_layer==null){A.main_wma_layer=A.tile_manager.AddWmsLayer(M.my_tile_array,true)}else{A.tile_manager.ChangeWmsSource(A.main_wma_layer,M.my_tile_array)}}function H(M,L,N,Q,P,O){var R=document.createElement("div");G.button_frame.appendChild(R);R.style.width="70px";R.style.fontSize="13px";R.style.fontFamily="Arial";R.style.backgroundColor="white";R.style.border="1px solid black";R.style.cursor="pointer";R.style.textAlign="center";R.style.display="none";R.style.styleFloat="right";R.style.cssFloat="right";R.innerHTML=L;R.my_active=false;R.my_text=Q;R.my_text_color=P;R.my_tile_array=O;R.onclick=function(){D(this,N)};C.push(R);return R}function J(M){for(var L=0;LM){m=M}P.style.top=m+"px"}}function Q(l){if(L==true){L=false;Y()}}function I(){return V(stripPx(P.style.top)+((P.height-1)/2))}function V(o){var m=-1;var l=1000;for(var n=0;nK.length){n=K.length-1}var l=K[n]-((P.height-1)/2);P.style.top=l+"px"}catch(m){log("Error at ZoomTool.SetLevel("+n+") "+m.message)}}U(C);S.event_after_level_changed.AddCallback(f);function f(l){try{W(l.new_level)}catch(m){log("Error at GlobalChangedLevel("+l+") "+m)}}}var kijs_traffic_index=null;var kijs_traffic_data=null;function Traffic(A){var J=A.navigation_frame.AddCell();var F=document.createElement("div");J.appendChild(F);F.src_off=kijs_dir+"images/btn_traffic_off.png";F.src_on=kijs_dir+"images/btn_traffic_on.png";Kijs_SetDivAlfaSrc(F,F.src_off,24,24);F.title=kijs_language.Traffic;F.style.cursor="pointer";F.onclick=function(){G()};var O=Array();var H=false;function G(){if(H==false){C()}else{N()}}this.ShowTrafficLayer=C;function C(){A.loader.Show();H=true;Kijs_SetDivAlfaSrc(F,F.src_on,24,24);call_back.LoadJson(kijs_dir+"server_scripts/traffic/get_traffic_info.php?kijs="+kijs_client_id,function(){try{if(1==1&&kijs_traffic_index!=null){D();M();var Q=kijs_dir+"server_scripts/traffic/draw_image.php?i="+kijs_traffic_index;L=A.tile_manager.AddWmsLayer([Q],false);I()}if(1==2&&kijs_traffic_data!=null){for(var P=0;P=0;P--){A.svg.lines.DeletePolyLine(O[P]);O.remove(P)}}function D(){if(L!=-1){A.tile_manager.RemoveWmsLayer(L);L=-1}}function I(){if(kijs_traffic_index==null){return }if(H==false){return }A.loader.Show();M();if(A.zoom_level<=2){if(L!=-1){}var P=A.MapCorners();for(var Q=0;Q";V+="
Pēdējais caurbraukšanas laiks: "+Math.round(P.last_drive_time/60*10)/10+"min";V+="
Ticamība: ";if(P.auto_count<1){V+="nav datu"}else{if(P.auto_count<3){V+="zema"}else{if(P.auto_count<5){V+="laba"}else{if(P.auto_count<7){V+="augsta"}else{V+="ļoti augsta"}}}}V+="
Normālais caurbraukšanas laiks: "+Math.round(P.normal_drive_time/60*10)/10+"min";V+="
Datums: "+P.date+"";A.svg.lines.SetCustomParameter(R,"mouse_over_text",V);A.svg.lines.AddEventMouseOver(R,function(X){var W=A.svg.lines.GetCustomParameter(X,"mouse_over_text");A.tooltip.Show(W)});A.svg.lines.AddEventMouseOut(R,function(){A.tooltip.Hide()})}}function JanaSetaMap(t,Q){var T=this;this.viewableMap=null;if(Q){switch(Q){case"lv":kijs_language=kijs_lan_lv;break;case"ru":kijs_language=kijs_lan_ru;break;case"en":kijs_language=kijs_lan_en;break;case"lt":kijs_language=kijs_lan_lt;break;case"de":kijs_language=kijs_lan_de;break}}if(document.addEventListener){document.addEventListener("mouseup",K,false);document.addEventListener("mousemove",g,false)}else{if(document.attachEvent){document.attachEvent("onmouseup",K);document.attachEvent("onmousemove",g)}}var C=false;this.DetachMouseMove=function(){return ;C=true};this.AttachMouseMove=function(){C=false};this.event_mouse_move=new Event();function g(x){if(C==false){T.event_mouse_move.Fire({pointer_x:pointerX(x),pointer_y:pointerY(x),offset_x:findPosX(T.viewableMap),offset_y:findPosY(T.viewableMap)})}}this.event_mouse_up=new Event();this.event_click=new Event();function K(z){var y=pointerX(z);var x=pointerY(z);T.event_mouse_up.Fire({pointer_x:y,pointer_y:x});if(I==y&&G==x){T.event_click.Fire({pointer_x:y,pointer_y:x})}}this.event_document_mouse_down=new Event();function Y(x){T.event_document_mouse_down.Fire({pointer_x:pointerX(x),pointer_y:pointerY(x),offset_x:findPosX(T.viewableMap),offset_y:findPosY(T.viewableMap)})}this.event_resize=new Event();var c=window.onresize;window.onresize=j;var w=document.body.clientWidth;function j(x){if(w!=document.body.clientWidth){if(c!=null){c(x)}T.event_resize.Fire();w=document.body.clientWidth}}this.event_double_click=new Event();function p(x){T.event_double_click.Fire({pointer_x:pointerX(x),pointer_y:pointerY(x)})}this.event_left_click=new Event();this.event_right_click=new Event();this.zoom_tool=null;var B=null;this.GetWholeMap=function(){return B};this.svg=null;this.tooltip=null;this.menu=null;this.info_box;this.save_box;this.image_layer;this.ruler;this.route;this.adm_vien;this.region_zoom;this.navigation_frame=null;this.navigation_controls;this.loader;this.wms_control;this.event_map_mouse_down=new Event();this.zoom_level;this.tile_width_meter=null;this.tile_height_meter=null;this.tile_width_pix=300;this.tile_height_pix=300;this.first_tile_x=null;this.first_tile_y=null;var o=null;var n=null;this.logo_and_scale=null;this.GetScaleMeters=function(){if(this.logo_and_scale!=null){return this.logo_and_scale.scale_in_meters}else{return 0}};T.viewableMap=E(t);T.viewableMap.innerHTML="";T.viewableMap.style.overflow="hidden";T.viewableMap.style.backgroundColor="#E4E4E4";T.viewableMap.style.position="relative";this.Load=function(AA,y,x){try{if(T.viewableMap.style.zIndex==""){T.viewableMap.style.zIndex=10}T.viewableMap.ondblclick=p;this.event_resize.AddCallback(function(){S()});T.viewableMap.oncontextmenu=function(AB){Kijs_StopEvent(AB);T.event_left_click.Fire({pointer_x:pointerX(AB),pointer_y:pointerY(AB)});T.event_right_click.Fire({pointer_x:pointerX(AB),pointer_y:pointerY(AB)})};B=document.createElement("div");T.viewableMap.appendChild(B);B.style.position="relative";B.style.left="0px";B.style.top="0px";B.onmousemove=function(){return false};Z(AA);h(y,x);String.prototype.Trim=String.prototype.TrimTo;this.logo_and_scale=new LogoAndScale(this);this.zoom_tool=new ZoomTool(this,this,AA);this.svg=new SvgClass(B,this);this.tooltip=new Tooltip(this);this.info_box=new InfoBox(this);this.menu=new ContextMenu(this);this.save_box=new SaveBox(this);this.image_layer=new ImageLayer(this);this.route=new RouteClass(this);this.region_zoom=new RegionZoom(this);this.adm_vien=new AdminVienShow(this);this.navigation_frame=new NavigationRow(this);this.navigation_controls=new NavigationControls(this);this.ruler=new Ruler(this);this.loader=new KijsLoader(this);this.wms_control=new WmsControl(this);L();X(B);B.onmousedown=V;this.event_mouse_move.AddCallback(J);this.event_mouse_up.AddCallback(r);N(this.MapActionType.Move);if(kijs_user_browser.ie==true){T.viewableMap.onresize=function(){T.event_resize.Fire()}}else{setInterval(function(){if(T.viewableMap.my_last_resize_width!=false&&T.viewableMap.my_last_resize_height!=false){if(T.viewableMap.my_last_resize_width!=T.viewableMap.clientWidth||T.viewableMap.my_last_resize_height!=T.viewableMap.clientHeight){T.event_resize.Fire()}}T.viewableMap.my_last_resize_width=T.viewableMap.clientWidth;T.viewableMap.my_last_resize_height=T.viewableMap.clientHeight},500)}}catch(z){log("Error JanaSetaMap.Load(): "+z+", "+z.name+", "+z.message)}};this.MapActionType={Move:1,Line:2,Polygon:3,Point:4,Ruler:5,ZoomRegion:6};this.MapAction=this.MapActionType.Move;this.MoveMap=function(){N(T.MapActionType.Move)};this.ZoomMapRegion=function(){N(T.MapActionType.ZoomRegion)};this.DrawLine=function(){N(T.MapActionType.Line)};this.DrawPolygon=function(){N(T.MapActionType.Polygon)};this.DrawPoint=function(){N(T.MapActionType.Point)};this.DrawRuler=function(){N(T.MapActionType.Ruler)};this.event_map_action_type_changed=new Event();function N(x){T.MapAction=x;T.event_map_action_type_changed.Fire(x)}this.event_finished_line_drawing=new Event();this.event_finished_polygon_drawing=new Event();this.event_finished_point_drawing=new Event();this.event_start_panning=new Event();this.default_point_radius=10;this.default_point_fill=[240,10,10,0.7];this.default_point_stroke={color:[250,250,250,1],width:2};this.skip_one_drag=false;var W=false;var I=0;var G=0;var d=0;var H=0;function V(z){d=l();H=O();var AC=pointerX(z);var AB=pointerY(z);T.event_map_mouse_down.Fire({pointer_x:AC,pointer_y:AB,offset_x:findPosX(T.viewableMap),offset_y:findPosY(T.viewableMap)});if(T.MapAction==T.MapActionType.Line){N(T.MapActionType.Move);var y=T.svg.lines.AddPolyLineMovable({color:[63,78,212,1],width:4});var AA=T.svg.LayerCoords(AC,AB);T.svg.lines.AddPoint(y,AA.x_meter,AA.y_meter);T.svg.lines.DrawNextPoint(y);T.svg.lines.AddEventClick(y,function(AE,AD){T.event_finished_line_drawing.Fire({id:AE,x:AD.meter_x,y:AD.meter_y})});T.svg.lines.AddEventStopedDrawing(y,function(AE,AD){T.event_map_action_type_changed.Fire(T.MapActionType.Move);T.event_finished_line_drawing.Fire({id:AE,x:AD.meter_x,y:AD.meter_y})})}else{if(T.MapAction==T.MapActionType.Polygon){N(T.MapActionType.Move);var y=T.svg.lines.AddPolygonMovable({color:[63,78,212,1],width:4},[10,181,30,0.3]);var AA=T.svg.LayerCoords(AC,AB);T.svg.lines.AddPoint(y,AA.x_meter,AA.y_meter);T.svg.lines.DrawNextPoint(y);T.svg.lines.AddEventClick(y,function(AE,AD){T.event_finished_polygon_drawing.Fire({id:AE,x:AD.meter_x,y:AD.meter_y})});T.svg.lines.AddEventStopedDrawing(y,function(AE,AD){T.event_map_action_type_changed.Fire(T.MapActionType.Move);T.event_finished_polygon_drawing.Fire({id:AE,x:AD.meter_x,y:AD.meter_y})})}else{if(T.MapAction==T.MapActionType.Point){N(T.MapActionType.Move);var AA=T.svg.LayerCoords(AC,AB);var x=T.svg.points.AddMovable(AA.x_meter,AA.y_meter,T.default_point_radius,T.default_point_fill,T.default_point_stroke);T.event_finished_point_drawing.Fire({id:x,x:AA.x_meter,y:AA.y_meter});T.svg.points.AddEventClick(x,function(AE,AD){T.event_finished_point_drawing.Fire({id:AE,x:AD.meter_x,y:AD.meter_y})})}else{if(T.MapAction==T.MapActionType.Ruler){N(T.MapActionType.Move);T.ruler.StartDraw()}else{if(T.skip_one_drag==true){T.skip_one_drag=false}else{if(T.MapAction==T.MapActionType.ZoomRegion){}else{if(T.MapAction==T.MapActionType.Move){T.event_start_panning.Fire();W=true;I=AC;G=AB}}}}}}}return false}this.event_stoped_paning=new Event();this.event_stoped_paning_map_moved=new Event();function r(x){if(W==true){W=false;T.event_stoped_paning.Fire(x);if(I!=x.pointer_x||G!=x.pointer_y){T.event_stoped_paning_map_moved.Fire(x)}S()}}this.event_panning=new Event();function J(x){if(W){T.event_panning.Fire(x);var z=H+(x.pointer_x-I);var y=d+(x.pointer_y-G);B.style.left=z+"px";B.style.top=y+"px"}}function l(){return stripPx(B.style.top)}function O(){return stripPx(B.style.left)}this.GetWholeMapTop=l;this.GetWholeMapLeft=O;function s(){return T.viewableMap.clientWidth}function U(){return T.viewableMap.clientHeight}this.GetWiewableMapWidth=s;this.GetWiewableMapHeight=U;var e=false;var R=null;var P=null;var v=null;var F=null;this.Refresh=S;function S(){var x=O();var AA=l();var AB=s();var z=U();if(P==null||R==null){P=AA;R=x}var y=false;if(Math.abs(P-AA)>30){y=true}else{if(Math.abs(R-x)>30){y=true}else{if(v!=AB){y=true}else{if(F!=z){y=true}}}}if(y==true){if(e==false){e=true;T.tile_manager.RemoveNoneVisibleTiles();L();P=AA;R=x;v=AB;F=z;e=false}}}var D=0;var M=0;this.CalcVisibleTiles=L;function L(){D=Math.ceil(s()/T.tile_width_pix);M=Math.ceil(U()/T.tile_height_pix);var AC=-Math.ceil((O()/T.tile_width_pix));var z=-Math.ceil((l()/T.tile_height_pix));var x=AC+D;var AB=z+M;var y=z+Math.ceil(M/2)-0;var AA=AC+Math.ceil(D/2)-0;q(y,AA)}this.event_before_center_changed=new Event();this.event_after_center_changed=new Event();this.ChangeLevelAndCenter=function(AB,z,x){try{var y=Z(AB);if(y==true){this.event_before_level_changed.FireNoThread({new_level:T.zoom_level});this.event_before_center_changed.Fire();h(z,x);f();this.event_after_level_changed.Fire({new_level:T.zoom_level});this.event_after_center_changed.Fire({x:z,y:x})}else{this.SetCenter(z,x)}}catch(AA){log("Error JanaSetaMap.ChangeLevelAndCenter(): "+AA+", "+AA.name+", "+AA.message)}};this.SetCenter=function(y,x){this.event_before_center_changed.Fire();h(y,x);f();this.event_after_center_changed.Fire({x:y,y:x})};function h(AA,z){try{T.first_tile_x=Math.floor(AA/T.tile_height_meter)*T.tile_height_meter;T.first_tile_y=Math.floor(z/T.tile_width_meter)*T.tile_width_meter;o=HorisontalMetersToPixels(AA-T.first_tile_x,T.tile_width_meter,T.tile_width_pix);n=VerticalMetersToPixels(z-T.first_tile_y,T.tile_height_meter,T.tile_height_pix);var x=s()/2;var y=U()/2;B.style.left=(x-o)+"px";B.style.top=(y-(T.tile_height_pix-n))+"px"}catch(AB){log("Error JanaSetaMap.SetCenterLocal(): "+AB+", "+AB.name+", "+AB.message)}}this.GetCenter=u;function u(){try{if(T.first_tile_x==null){return false}var AD=O()-s()/2;var y=l()-U()/2;var AA=HorisontalPixelsToMeters(AD,T.tile_width_meter,T.tile_width_pix);var AB=VerticalPixelsToMeters(y,T.tile_height_meter,T.tile_height_pix);var x=T.first_tile_x-AA;var z=T.first_tile_y+AB+T.tile_height_meter;return{x:x,y:z}}catch(AC){log("Error JanaSetaMap.GetCenter(): "+AC+", "+AC.name+", "+AC.message)}}this.SetLevel=Z;function Z(x){try{x=Math.round(x);if(x<-2){x=-2}if(x>11){x=11}if(T.zoom_level!=x){T.zoom_level=x;var z=T.GetLevelInfo(x);T.tile_width_meter=z.tile_width_meter;T.tile_height_meter=z.tile_height_meter;return true}else{return false}}catch(y){log("Error map.SetLevel("+x+"): "+y+", "+y.name+", "+y.message)}}this.first_level_meters=220;this.GetLevelInfo=function(AC){try{var AB=this.first_level_meters*Math.pow(2,AC);var x=this.first_level_meters*Math.pow(2,AC);var z=HorisontalPixelsToMeters(s(),AB,T.tile_width_pix);var y=VerticalPixelsToMeters(U(),x,T.tile_height_pix);return{tile_width_meter:AB,tile_height_meter:x,map_width_meter:z,map_height_meter:y}}catch(AA){log("Error map.GetLevelInfo("+value+"): "+AA.name+", "+AA.message)}};this.LoadImageTilesFromCenter=q;function q(AD,z){try{var AE=Math.max(D,M)+4;T.tile_manager.NeedTile(AD,z);var AA=0;for(var AC=1;AC<=AE;AC++){for(var x=0;x<2;x++){for(var y=0;yx&&AB.map_height_meter>AA){break}}return y};this.BestView=function(AG){var AD=null;var z=null;var AC=null;var x=null;for(var AB=0;ABAD){AD=AG[AB].x}if(z==null||AG[AB].xAC){AC=AG[AB].y}if(x==null||AG[AB].y.kijs_pointer{cursor: pointer;}");document.write("");function SvgPoints(B,O,D){var C=Array();var Y=this;this.Get_LKS_X=function(d){return C[d].lks_x};this.Get_LKS_Y=function(d){return C[d].lks_y};this.Add=function(h,g,d,f,e){return P(h,g,d,f,e,false)};this.AddMovable=function(h,g,d,f,e){return P(h,g,d,f,e,true)};function P(l,k,d,m,n,o){var j=Kijs_Clone(m);var h=Kijs_Clone(n);try{var g=C.length;C.push({type:"circle",lks_x:l,lks_y:k,cx:-1,cy:-1,r:d,fill:j,stroke:h,object:null,mouse_over:null,mouse_out:null,point_moving:null,point_moving_args:null,point_moved:null,point_clicked:null,left_click:null,left_click_args:null,movable:o,last_position:null,belongs_to_line_id:null,usage_type:""});Y.Draw(g);return g}catch(f){log("Error SvgPoints.AddMain(): "+f+", "+f.name+", "+f.message)}}this.AddImage=function(k,h,f,d,j,g,e){return U(k,h,f,d,j,g,e,false)};this.AddImageMovable=function(k,h,f,d,j,g,e){return U(k,h,f,d,j,g,e,true)};function U(k,j,e,l,d,g,f,m){var h=C.length;C.push({type:"image",lks_x:k,lks_y:j,x:-1,y:-1,width:e,height:l,src:d,offset_x:g,offset_y:f,object:null,mouse_over:null,mouse_out:null,point_moving:null,point_moving_args:null,point_moved:null,point_clicked:null,left_click:null,left_click_args:null,movable:m,last_position:null});Y.Draw(h);return h}this.Remove=function(d){if(df&&k>f){var g=null;if(h.type=="circle"){g=O.createCircle({cx:d,cy:k,r:h.r}).setFill(h.fill).setStroke(h.stroke)}else{if(h.type=="image"){g=O.createImage({x:d,y:k,width:h.width,height:h.height,src:h.src})}}g.getEventSource().setAttribute("circle_id",l);Kijs_AddClass(g.getEventSource(),"kijs_pointer");C[l].object=g}else{}}}}catch(j){log("Error SvgPoints.Draw(): "+j.name+", "+j.message)}};function I(h){var e=C[h];if(e!=null){var f=MetersToPixels(D.parent,e.lks_x,e.lks_y);var d=f.x-MyLeft(B);var g=f.y-MyTop(B);if(e.type=="circle"){C[h].cx=d;C[h].cy=g}else{if(e.type=="image"){C[h].x=d;C[h].y=g}}}}this.RedrawPoints=function(){for(var d=0;d0){h+=","}var f=g.stroke.color;h+="{x:"+g.lks_x+",y:"+g.lks_y+",r:"+g.r+",fill:["+g.fill[0]+","+g.fill[1]+","+g.fill[2]+","+g.fill[3]+"]";h+=",stroke:{color:["+f[0]+","+f[1]+","+f[2]+","+f[3]+"],width:"+g.stroke.width+"}";h+=',name:"'+this.GetCustomParameter(d,"name").replace(/"/g,'\\"')+'"';h+=',descr:"'+this.GetCustomParameter(d,"descr").replace(/"/g,'\\"')+'"';h+="}";e++}h+="]";return h};this.event_object_loaded_from_status_string=new Event();this.LoadStatusString=function(f){for(var d=0;d.kijs_noprint{display:none;visibility:hidden;width:0px;height:0px;}");document.write("");function SvgClass(H,D){var F=this;this.parent=D;this.whole_map=H;this.test="test";var B=document.createElement("div");B.style.position="absolute";B.style.zIndex=2;H.appendChild(B);if(kijs_user_browser.ff==true&&kijs_user_browser.ff3==false){B.className="kijs_noprint"}if(kijs_user_browser.op==true){B.className="kijs_noprint"}Kijs_Require("dojox.gfx");var G=Kijs_CreateSurface(B,3000,3000);B.style.top="-500px";B.style.left="-500px";var F=this;this.points=new SvgPoints(B,G,this);this.lines=new SvgPolyLine(B,G,this);D.event_before_level_changed.AddCallback(A);D.event_before_center_changed.AddCallback(A);function A(I){B.style.visibility="hidden"}D.event_after_level_changed.AddCallback(C);D.event_after_center_changed.AddCallback(C);D.event_stoped_paning_map_moved.AddCallback(C);this.Refresh=C;function C(I){B.style.visibility="hidden";B.style.left=(-1*MyLeft(F.whole_map)-500)+"px";B.style.top=(-1*MyTop(F.whole_map)-500)+"px";B.style.visibility="visible";F.lines.RedrawPolyLines();F.points.RedrawPoints()}this.LayerCoords=function(R,Q){var K=D.viewableMap;var I=findPosX(K);var V=findPosY(K);var M=R-I;var L=Q-V;M-=MyLeft(this.whole_map);L-=MyTop(this.whole_map);var P=M-MyLeft(B);var O=L-MyTop(B);var T=R-I;var S=Q-V;var U=PixelsToMeters(D,M,L);var N=U.x;var J=U.y;return{pix_x:P,pix_y:O,x_meter:N,y_meter:J}}}kijs_user_browser=new KijsBrowser();function log(A){setTimeout(function(){var B=E("kijs_debug");if(!B){B=E("debug")}if(B){var C=new Date();var D=C.getHours()+":"+C.getMinutes()+":"+C.getSeconds();B.innerHTML="["+D+"] - "+A+"\n
"+B.innerHTML;B.innerHTML=B.innerHTML.substring(0,7000)}},10)}function E(B){try{return document.getElementById(B)}catch(A){return false}}function pointerX_old(B){var A=0;if(!B){var B=window.event}if(B.pageX){A=B.pageX}else{if(B.clientX){A=B.clientX+document.body.scrollLeft+document.documentElement.scrollLeft}}return A}function pointerY_old(A){var B=0;if(!A){var A=window.event}if(A.pageY){B=A.pageY}else{if(A.clientY){B=A.clientY+document.body.scrollTop+document.documentElement.scrollTop}}return B}function pointerX(F){if(!kijs_user_browser.ie){return pointerX_old(F)}else{var A=0;if(!F){var F=window.event}var C=F.srcElement;var D=(C&&C.ownerDocument)||document;var B=((Kijs_IsIE()<6)||(D.compatMode=="BackCompat"))?D.body:D.documentElement;var G=Kijs_IeDocElemOffset();A=F.clientX+Kijs_FixIeBiDiScrollLeft(B.scrollLeft||0)-G.x;return A}}function pointerY(D){if(!kijs_user_browser.ie){return pointerY_old(D)}else{var G=0;if(!D){var D=window.event}var B=D.srcElement;var C=(B&&B.ownerDocument)||document;var A=((Kijs_IsIE()<6)||(C.compatMode=="BackCompat"))?C.body:C.documentElement;var F=Kijs_IeDocElemOffset();G=D.clientY+(A.scrollTop||0)-F.y;return G}}function findPosX(A){var B=0;if(A.offsetParent){while(A.offsetParent){B+=A.offsetLeft;A=A.offsetParent}}else{if(A.x){B+=A.x}}return B}function findPosY(B){var A=0;if(B.offsetParent){while(B.offsetParent){A+=B.offsetTop;B=B.offsetParent}}else{if(B.y){A+=B.y}}return A}function HorisontalMetersToPixels(A,B,D){var C=D/B;return Math.round(A*C)}function VerticalMetersToPixels(B,C,A){var D=A/C;return Math.round(B*D)}function HorisontalPixelsToMeters(D,A,C){var B=A/C;return Math.round(D*B)}function VerticalPixelsToMeters(D,B,A){var C=B/A;return Math.round(D*C)}function FromPixelsToMeters(L,J,G,C,H,M,I,K){var F=HorisontalPixelsToMeters(L,H,I);var B=VerticalPixelsToMeters(J,M,K);var D=G+F;var A=C-B+M;return{x:D,y:A}}function FromMetersToPixels(G,C,F,B,H,K,I,J){var D=G-F;var A=B-C;var M=HorisontalMetersToPixels(D,H,I);var L=VerticalMetersToPixels(A,K,J);L+=J;return{x:M,y:L}}function MetersToPixels(D,B,A){var C=FromMetersToPixels(B,A,D.first_tile_x,D.first_tile_y,D.tile_width_meter,D.tile_height_meter,D.tile_width_pix,D.tile_height_pix);return{x:C.x,y:C.y}}function PixelsToMeters(D,B,A){var C=FromPixelsToMeters(B,A,D.first_tile_x,D.first_tile_y,D.tile_width_meter,D.tile_height_meter,D.tile_width_pix,D.tile_height_pix);return{x:C.x,y:C.y}}String.prototype.trim=function(){return this.replace(/^\s+|\s+$/,"")};function MyLeft(A){if(A==null){return false}return stripPx(A.style.left)}function MyTop(A){if(A==null){return false}return stripPx(A.style.top)}function stripPx(A){if(A==""){return 0}else{return parseFloat(A.substring(0,A.length-2))}}function CreateImageNoSelect(){var A=document.createElement("img");A.setAttribute("style","-moz-user-select: none; ");A.unselectable="on";return A}function GetJsonData(B){document.write("