imgw=325;
imgh=200;
maxco=17;
maxli=17;
px=2350;
py=900;
typ=2;

var p=new Array();for(var i=1;i<=4;i++){p[i]=new Array();for(var j=1;j<=4;j++){p[i][j]=new Array();}}

function ldi(i,co,li){
document.getElementById("i"+i).src='harta/ldi.gif';
var src='harta/'+typ+'/map'+li+'-'+co+'.jpg';var buffer=new Image;buffer.onload=function(){document.getElementById('i'+i).src=buffer.src};window.setTimeout(function(){buffer.src=src;},100);
}

function rvw(){
if(px>(maxco-3)*imgw){px=(maxco-3)*imgw} if(px<0){px=0;}
if(py>(maxli-3)*imgh){py=(maxli-3)*imgh} if(py<0){py=0;}
co=Math.floor(px/imgw)+1;
li=Math.floor(py/imgh)+1;
pxx=-px%imgw;
pyy=-py%imgh;
for (var i=1;i<=4;i++){
 for (var j=1;j<=4;j++){
  p[i][j][1]=co+(i-1);
  p[i][j][2]=li+(j-1);
  p[i][j][3]=pxx+imgw*(i-1);
  p[i][j][4]=pyy+imgh*(j-1);
  im=i*10+j;
  ldi(im,p[i][j][1],p[i][j][2]);
  document.getElementById("i"+im).style.left=p[i][j][3];
  document.getElementById("i"+im).style.top=p[i][j][4];
  }
 }
drawth();
}

function drawth(){
document.getElementById("thc").style.left=Math.floor(px*0.03);
document.getElementById("thc").style.top=Math.floor(py*0.03);
}

function mv(x,y){
if(px+x>(maxco-3)*imgw){x=(maxco-3)*imgw-px} if(px+x<0){x=-px;}
if(py+y>(maxli-3)*imgh){y=(maxli-3)*imgh-py} if(py+y<0){y=-py;}
px+=x;
py+=y;
for (var i=1;i<=4;i++){
 for (var j=1;j<=4;j++){
  p[i][j][3]+=-x;
  p[i][j][4]+=-y;
  im=i*10+j;
  mde=false;
  if (p[i][j][3]<-imgw){mde=true;p[i][j][3]+=imgw*4;p[i][j][1]+=4;} //dr
  if (p[i][j][3]>imgw*3){mde=true;p[i][j][3]-=imgw*4;p[i][j][1]-=4;} //st
  if (p[i][j][4]<-imgh){mde=true;p[i][j][4]+=imgh*4;p[i][j][2]+=4;} //su
  if (p[i][j][4]>imgh*3){mde=true;p[i][j][4]-=imgh*4;p[i][j][2]-=4;} //jo
  if (mde){ldi(im,p[i][j][1],p[i][j][2]);}
  document.getElementById("i"+im).style.left=p[i][j][3];
  document.getElementById("i"+im).style.top=p[i][j][4];
  }
 }
drawth();
document.getElementById("cerc").style.left=parseInt(document.getElementById("cerc").style.left)-x;
document.getElementById("cerc").style.top=parseInt(document.getElementById("cerc").style.top)-y;
if(document.getElementById("lin").style.display==''){lk();}
}

if  (document.getElementById){
(function(){
if (window.opera){document.write("<input type='hidden' id='Q' value=' '>");}
var n = 500;
var dragok = false;
var y,x,d,dy,dx;
var uxx=0,uyy=0;
function mw(e){
if (!e) e = window.event;
 if (dragok){
  prx=dx + e.clientX - x;
  pry=dy + e.clientY - y;
  d.style.left= prx+"px";
  d.style.top=pry+"px";
  mv(-(prx-uxx),-(pry-uyy));
  uxx=dx + e.clientX - x;
  uyy=dy + e.clientY - y;
  return false;
 }
}
function down(e){
if (!e) e = window.event;
var temp = (typeof e.target != "undefined")?e.target:e.srcElement;
if (temp.tagName != "HTML"|"BODY" && temp.className != "drg"){
 temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
 }
if (temp.className == "drg"){
 if (window.opera){
  document.getElementById("Q").focus();
 }
 dragok = true;
 temp.style.zIndex = n++;
 d = temp;
 dx = parseInt(temp.style.left+0);
 dy = parseInt(temp.style.top+0);
 x = e.clientX;
 y = e.clientY;
 document.onmousemove = mw;
 document.getElementById("drg").className='drgd';
 return false;
 }
}
function up(){
dragok = false;
document.onmousemove = null;
document.getElementById("drg").style.left=0;
document.getElementById("drg").style.top=0;
document.getElementById("drg").style.zIndex=0;
document.getElementById("drg").className='drg';
uxx=0;
uyy=0;
}
document.onmousedown=down;
document.onmouseup=up;
})();
}

function htyp(n){
typ=n;
for (var i=1;i<=3;i++){document.getElementById("typ"+i).className="hb0";}
document.getElementById("typ"+n).className="hb1";document.getElementById("th").style.backgroundImage='url(\'harta/th'+typ+'.jpg\')';
rvw();
}

movr="#85B1E9",mout="#FFFFFF";
function st(){
var i=1,n=0,p=0;
b=document.getElementById("str").value;
b=b.toLowerCase();b=b.replace(/ã/g, "a");b=b.replace(/â/g, "a");b=b.replace(/î/g, "i");b=b.replace(/º/g, "s");b=b.replace(/þ/g, "t");
while(document.getElementById("o"+String(i))!=null)
 {d="o"+String(i);c=document.getElementById(d).innerHTML;
 c=c.toLowerCase();c=c.replace(/ã/g, "a");c=c.replace(/â/g, "a");c=c.replace(/î/g, "i");c=c.replace(/º/g, "s");c=c.replace(/þ/g, "t");
 document.getElementById(d).style.display="none";
 if (c.indexOf(b)>=0){n=n+1;
  if (p==0){p=i;}
  if (n<=10){document.getElementById(d).style.display="";}}
 i++;}
if (n==0){document.getElementById("dst").style.display="none";}else
 {document.getElementById("dst").style.display="";}
if(document.getElementById("str").value==""){document.getElementById("dst").style.display="none";}
}

var w;
function su(c){
pt=c.indexOf(".");
x=Number(c.substr(0,pt));
y=Number(c.substr(pt+1));
cerc(x,y);
document.getElementById("dst").style.display="none";
document.getElementById("str").value="";
}

function ovr1(t){
var i=1;
while(document.getElementById("o"+String(i))!=null){document.getElementById("o"+String(i)).style.background=mout;i++;}
t.style.background=movr;}
function ovr(t){
ovr1(t);
ms=1;}
function out(t){
t.style.background=mout;
ms=0;}

function cerc(x,y){
px=x-Math.floor(imgw*3/2);
py=y-Math.floor(imgh*3/2);
rvw();
x-=(px+25);
y-=(py+25);
document.getElementById("cerc").style.left=x;
document.getElementById("cerc").style.top=y;
document.getElementById("cerc").style.display="";
}

function gr(){if(document.getElementById("grd").style.display=="none"){document.getElementById("grd").style.display="";document.getElementById("gridbtn").className="hb1";}else{document.getElementById("grd").style.display="none";document.getElementById("gridbtn").className="hb0";}}
function tu(){if(document.getElementById("th").style.display=="none"){document.getElementById("th").style.display="";document.getElementById("thubtn").className="hb1";}else{document.getElementById("th").style.display="none";document.getElementById("thubtn").className="hb0";}}
function aj(){if(document.getElementById("ajutor").style.display=="none"){document.getElementById("ajutor").style.display="";document.getElementById("ajutorbtn").className="hb1";}else{document.getElementById("ajutor").style.display="none";document.getElementById("ajutorbtn").className="hb0";}}

function lk(){
if (document.getElementById("lin").style.display=="none")
 {document.getElementById("lin").style.display="";document.getElementById("linkbtn").className="hb1";
x=px+Math.floor(imgw*3/2);
y=py+Math.floor(imgh*3/2);
document.getElementById("link").value="http://www.alba-iulia.info/harta.asp?c="+x+"."+y+"";}
else{document.getElementById("lin").style.display="none";document.getElementById("linkbtn").className="hb0";}
}

function thp(event){
var x=event.offsetX?(event.offsetX):event.pageX-806;x-=14.5;
var y=event.offsetY?(event.offsetY):event.pageY-34;y-=9;
px=Math.floor(x/0.03);
py=Math.floor(y/0.03);
rvw();
}

function thv(v){
document.getElementById('th').style.opacity=v/100;
document.getElementById('th').style.filter='alpha(opacity='+v+')';
}

function init(rr){
//document.write('<div id="log" style="position:absolute;top:50;left:50;width:200;height:200;background-color:FFFF00;overflow:auto;"></div>');
//document.getElementById("log").innerHTML='-';
r='';
for(var i=1;i<=4;i++){
 for(var j=1;j<=4;j++){
  r=r+'<img id="i'+i+''+j+'" style="position:absolute;" src="harta/defimg.gif">';
 }
}
r=r+'<img id="grd" style="position:absolute;display:none;" src="harta/grid.gif"><img class="drg" id="drg" src="harta/drg.gif" galleryimg="false">';
r=r+'<img id="cerc" style="position:absolute;left:0;top:0;display:none;" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\',src=\'harta/cerc.png\');" width=50 height=50 src="harta/defimg.gif" onclick="this.style.display=\'none\';">';
r=r+'<div style="position:absolute;left:0;top:0;"><img id="hhd" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\',src=\'harta/hhd.png\');" src="harta/defimg.gif"></div>';
r=r+'<div id="th" style="position:absolute;top:33;left:805;width:166;height:102;border:1px solid #FFFFFF;opacity:0.7;filter:alpha(opacity=70);background-image:url(\'harta/th2.jpg\');"><div style="position:relative;"><div id="thc" style="position:absolute;top:0;left:0;width:29;height:18;background-image:url(\'harta/thc.gif\');"></div><div id="tho" style="position:absolute;left:0;top:0;width:166;height:102;cursor:pointer;" onclick="thp(event)" onmouseover="thv(100)" onmouseout="thv(70)"></div></div></div>';
r=r+'<div id="lin" style="position:absolute;left:420;top:50;width:380;height:50;background-color:FFFFFF;display:none;"><div style="position:absolute;right:5;top:5;width:21;height:21;background-image:url(\'harta/cl.gif\');cursor:pointer;" onclick="lk()"></div><br>Link: <input type="text" class="fld" style="width:300;" id="link"></div>';
r=r+'<div id="ajutor" style="position:absolute;left:40;top:105;width:500;background-color:FFFFFF;display:none;padding:5;font-size:11;">';
r=r+'<div style="position:absolute;right:5;top:5;width:21;height:21;background-image:url(\'harta/cl.gif\');cursor:pointer;" onclick="aj()"></div>';
document.getElementById("fa").innerHTML=r+document.getElementById("fa").innerHTML;
document.getElementById("dst").style.display="none";
document.getElementById("str").value="";
if(navigator.userAgent.search(/msie/i)==-1){document.getElementById("hhd").src="harta/hhd.png";document.getElementById("cerc").src="harta/cerc.png";}
if (rr){rvw();htyp(2);}
window.setTimeout(function(){document.getElementById("load").style.display='none'},1000);
}