winsize(); 
window.onresize = winsize; 
var tileSize = 256; 
var center = 0; 
var height; 
var width; 
var path; 
var imgpath; 
var labelspath; 
var loadedXML = 0; 
var getJSON = 0; 
var loadedJSON = 0; 
var JSON; 
var JSONnum; 
var JSONout; 
var slidePointer = 0; 
var wheelmode = 0; 
var coords = 0; 
start = getVar("start"); 
if(start.length > 0) {
   slidePointer = start; 
   }
var innerDiv; 
vTier2 = getVar("vT"); 
if(vTier2.length > 0) {
   var zoom = vTier2; 
   }
else {
   var zoom = 2; 
   }
var dragging = false; 
var top; 
var left; 
var dragStartTop; 
var dragStartLeft; 
function init() {
   var _1 = $("imageLabels"); 
   var _2 = _1.getElementsByTagName("div"); 
   while(_2.length > 0) {
      _1.removeChild(_2[0]); 
      }
   path2 = getVar("path"); 
   width2 = getVar("width"); 
   height2 = getVar("height"); 
   coords2 = getVar("coords"); 
   if(path2.length > 1) {
      path = path2; 
      }
   if(width2.length > 0) {
      width = width2; 
      }
   if(height2.length > 0) {
      height = height2; 
      }
   if(coords2.length > 0) {
      coords = coords2; 
      }
   if((getVar("vX").length) > 0) {
      innerDiv.style.left =- getVar("vX"); 
      innerDiv.style.top =- getVar("vY"); 
      }
   JSON = getVar("JSON"); 
   if(JSON.length > 1 &&!loadedJSON) {
      getJSON = 1; 
      document.getElementById("Nav").style.display = "block"; 
      loadJSON(); 
      $("wheelMode").style.display = "block"; 
      }
   res = getVar("res"); 
   if(res.length < 1) {
      res = 0.46; 
      }
   resunits = getVar("resunits"); 
   if(resunits.length < 1) {
      resunits = "um"; 
      }
   if(width2.length < 1 &&!loadedXML &&!getJSON) {
      loadXMLfile(); 
      }
   imgpath = path; 
   gImageWidth = width; 
   gImageHeight = height; 
   tempWidth = gImageWidth; 
   tempHeight = gImageHeight; 
   var j; 
   divider = 2; 
   gTierCount = 1; 
   while(tempWidth > tileSize || tempHeight > tileSize) {
      tempWidth = Math.floor(gImageWidth / divider); 
      tempHeight = Math.floor(gImageHeight / divider); 
      divider *= 2; 
      if(tempWidth % 2) {
         tempWidth++; 
         }
      if(tempHeight % 2) {
         tempHeight++; 
         }
      gTierCount++; 
      }
   hidethumb = getVar("hidethumb"); 
   if(hidethumb.length > 0) {
      }
   else {
      showThumb(); 
      }
   var _4 = document.getElementById("outerDiv"); 
   _4.onmousedown = startMove; 
   _4.onmousemove = processMove; 
   _4.onmouseup = stopMove; 
   _4.ondragstart = function() {
      return false; 
      }; 
   checkTiles(); 
   updateZoom(); 
   }
function startMove(_5) {
   if(!_5) {
      _5 = window.event; 
      }
   dragStartLeft = _5.clientX; 
   dragStartTop = _5.clientY; 
   top = stripPx(innerDiv.style.top); 
   left = stripPx(innerDiv.style.left); 
   dragging = true; 
   return false; 
   }
function processMove(_6) {
   if(!_6) {
      _6 = window.event; 
      }
   if(coords) {
      $("coords").innerHTML = Math.round((( - stripPx(innerDiv.style.left) + _6.clientX - 0) / (gImageWidth / (Math.pow(2, gTierCount - 1 - zoom))) * 1000)) / 1000 + ", " + Math.round((( - stripPx(innerDiv.style.top) + _6.clientY - 16) / (gImageHeight / (Math.pow(2, gTierCount - 1 - zoom))) * 1000)) / 1000; 
      }
   if(dragging) {
      innerDiv.style.top = top + (_6.clientY - dragStartTop); 
      innerDiv.style.left = left + (_6.clientX - dragStartLeft); 
      }
   checkTiles(); 
   }
function checkTiles() {
   innerDiv = document.getElementById("innerDiv"); 
   var _7 = getVisibleTiles(); 
   var _8 = {
      }; 
   for(i = 0; i < _7.length; i++) {
      var _9 = _7[i]; 
      gTileCountWidth = new Array(); 
      gTileCountHeight = new Array(); 
      tempWidth = gImageWidth; 
      tempHeight = gImageHeight; 
      divider = 2; 
      for(var j = gTierCount - 1; j >= 0; j--) {
         gTileCountWidth[j] = Math.floor(tempWidth / tileSize); 
         if(tempWidth % tileSize) {
            gTileCountWidth[j]++; 
            }
         gTileCountHeight[j] = Math.floor(tempHeight / tileSize); 
         if(tempHeight % tileSize) {
            gTileCountHeight[j]++; 
            }
         tempWidth = Math.floor(gImageWidth / divider); 
         tempHeight = Math.floor(gImageHeight / divider); 
         divider *= 2; 
         if(tempWidth % 2) {
            tempWidth++; 
            }
         if(tempHeight % 2) {
            tempHeight++; 
            }
         }
      if(!center) {
         innerDiv.style.left =- (width / (Math.pow(2, gTierCount - 1 - zoom))) / 2 + viewportWidth / 2; 
         innerDiv.style.top =- (height / (Math.pow(2, gTierCount - 1 - zoom))) / 2 + viewportHeight / 2; 
         center = 1; 
         }
      moveThumb2(); 
      pCol = _9[0]; 
      pRow = _9[1]; 
      tier = zoom; 
      var _b = parseFloat(pRow * gTileCountWidth[tier] + pCol); 
      for(var _c = 0; _c < tier; _c++) {
         _b += gTileCountWidth[_c] * gTileCountHeight[_c]; 
         }
      _tileGroupNum = Math.floor(_b / 256); 
      if(pCol < gTileCountWidth[zoom] && pRow < gTileCountHeight[zoom]) {
         var _d = "TileGroup" + _tileGroupNum + "/" + zoom + "-" + pCol + "-" + pRow + ".jpg"; 
         }
      _8[_d] = true; 
      var _e = document.getElementById(_d); 
      if(!_e) {
         _e = document.createElement("img"); 
         _e.src = imgpath + _d; 
         _e.style.position = "absolute"; 
         _e.style.left = (_9[0] * tileSize) + "px"; 
         _e.style.top = (_9[1] * tileSize) + "px"; 
         _e.style.zIndex = 0; 
         _e.setAttribute("id", _d); 
         imageTiles.appendChild(_e); 
         }
      }
   var _f = imageTiles.getElementsByTagName("img"); 
   for(i = 0; i < _f.length; i++) {
      var id = _f[i].getAttribute("id"); 
      if(!_8[id]) {
         imageTiles.removeChild(_f[i]); 
         i--; 
         }
      }
   }
function getVisibleTiles() {
   var _11 = stripPx(innerDiv.style.left); 
   var _12 = stripPx(innerDiv.style.top); 
   var _13 = Math.abs(Math.floor(_11 / tileSize)) - 2; 
   var _14 = Math.abs(Math.floor(_12 / tileSize)) - 1; 
   var _15 = Math.ceil(viewportWidth / tileSize) + 2; 
   var _16 = Math.ceil(viewportHeight / tileSize) + 1; 
   var _17 = []; 
   var _18 = 0; 
   for(x = _13; x < (_15 + _13); x++) {
      for(y = _14; y < (_16 + _14); y++) {
         if(x >= 0 && y >= 0) {
            _17[_18++] = [x, y]; 
            }
         }
      }
   return _17; 
   }
function stopMove() {
   dragging = false; 
   }
function ZoomIn() {
   if(zoom != gTierCount - 1) {
      top = stripPx(innerDiv.style.top); 
      left = stripPx(innerDiv.style.left); 
      innerDiv.style.top = 2 * top - viewportHeight / 2; 
      innerDiv.style.left = 2 * left - viewportWidth / 2; 
      zoom = zoom + 1; 
      var _19 = imageTiles.getElementsByTagName("img"); 
      while(_19.length > 0) {
         imageTiles.removeChild(_19[0]); 
         }
      checkTiles(); 
      var _1a = imageLabels.getElementsByTagName("div"); 
      for(var $i = 0; $i < _1a.length; $i++) {
         var _1c = "L" + $i; 
         $(_1c).style.top = 2 * stripPx($(_1c).style.top); 
         $(_1c).style.left = 2 * stripPx($(_1c).style.left); 
         }
      }
   updateZoom(); 
   }
function ZoomOut() {
   if(zoom != 0) {
      top = stripPx(innerDiv.style.top); 
      left = stripPx(innerDiv.style.left); 
      innerDiv.style.top = top / 2 + viewportHeight / 4; 
      innerDiv.style.left = left / 2 + viewportWidth / 4; 
      zoom = zoom - 1; 
      var _1d = imageTiles.getElementsByTagName("img"); 
      while(_1d.length > 0) {
         imageTiles.removeChild(_1d[0]); 
         }
      checkTiles(); 
      var _1e = imageLabels.getElementsByTagName("div"); 
      for(var $i = 0; $i < _1e.length; $i++) {
         var _20 = "L" + $i; 
         $(_20).style.top = 0.5 * stripPx($(_20).style.top); 
         $(_20).style.left = 0.5 * stripPx($(_20).style.left); 
         }
      }
   updateZoom(); 
   }
function updateZoom() {
   if(JSONnum) {
      //$("theScale").innerHTML = Math.pow(2, gTierCount - 1 - zoom) * res * 50 + " " + resunits + "<br><br>zoom level: " + zoom + "/" + (gTierCount - 1) + "<br>slide #: " + (slidePointer + 1) + "/" + JSONnum; 
	  $("theScale").innerHTML = "Szint: " + zoom + "/" + (gTierCount - 1); 
      }
   else {
   //   $("theScale").innerHTML = Math.pow(2, gTierCount - 1 - zoom) * res * 50 + " " + resunits + "<br><br>zoom level: " + zoom + "/" + (gTierCount - 1);
      $("theScale").innerHTML = "Szint: " + zoom + "/" + (gTierCount - 1);
      }
   }
function showThumb() {
   var _21 = $("Thumb"); 
   _21.innerHTML = "<img src=\"" + imgpath + "TileGroup0/0-0-0.jpg\">"; 
   $("Thumb0").style.height = gImageHeight / (Math.pow(2, gTierCount - 1)) + 2; 
   $("Thumb0").style.width = gImageWidth / (Math.pow(2, gTierCount - 1)) + 3; 
   _21.style.display = "block"; 
   $("Thumb2").style.display = "block"; 
   _21.onmouseup = clickThumb; 
   _21.ondragstart = function() {
      return false; 
      }; 
   }
function hideThumb() {
   $("Thumb").style.display = "none"; 
   }
function moveThumb2() {
   var _22 = $("Thumb2"); 
   topT = stripPx(innerDiv.style.top); 
   leftT = stripPx(innerDiv.style.left); 
   _22.style.width = viewportWidth / Math.pow(2, zoom); 
   _22.style.height = viewportHeight / Math.pow(2, zoom); 
   _22.style.left =- leftT / (Math.pow(2, zoom)); 
   _22.style.top =- topT / (Math.pow(2, zoom)); 
   }
function clickThumb(_23) {
   if(_23) {
      xThumb = _23.clientX; 
      yThumb = _23.clientY; 
      var _24 = $("innerDiv"); 
      _24.style.left =- (1 - Math.abs(viewportWidth - xThumb) / stripPx($("Thumb0").style.width)) * width / (Math.pow(2, gTierCount - zoom - 1)); 
      _24.style.top =- (1 - Math.abs(viewportHeight - yThumb) / stripPx($("Thumb0").style.height)) * height / (Math.pow(2, gTierCount - zoom - 1)); 
      moveThumb2(); 
      }
   }
function wheelMode1() {
  // $("wheelMode").innerHTML = "<b>Egér görgo:</b><br><input type=\"radio\" checked onClick=\"wheelMode1()\">&nbsp;Nagyítás<br><input type=\"radio\" onClick=\"wheelMode2()\" >&nbsp;Képváltás"; 
   wheelmode = 0; 
   }
function wheelMode2() {
   //$("wheelMode").innerHTML = "<b>Egér görgo:</b><br><input type=\"radio\" onClick=\"wheelMode1()\">&nbsp;Nagyítás<br><input type=\"radio\" checked onClick=\"wheelMode2()\" >&nbsp;Képváltás"; 
   wheelmode = 1; 
   }
function loadJSON() {
   JSONrequest = getHTTPObject(); 
   JSONrequest.onreadystatechange = JSONread; 
   JSONrequest.open("GET", JSON, true); 
   JSONrequest.send(null); 
   }
function JSONread() {
   if(JSONrequest.readyState == 4) {
      JSONout = eval("(" + JSONrequest.responseText + ")"); 
      JSONnum = JSONout.slides.length; 
      path = JSONout.slides[slidePointer].path; 
      width = JSONout.slides[slidePointer].width; 
      height = JSONout.slides[slidePointer].height; 
      if(JSONout.slides[slidePointer].labelspath != undefined) {
         labelspath = JSONout.slides[slidePointer].labelspath; 
         loadLabels(); 
         }
      loadedJSON = 1; 
      init(); 
      }
   }
labels = getHTTPObject(); 
function loadLabels() {
   var _25 = labelspath; 
   var _26 = $("L0"); 
   if(_26) {
      imageLabels = $("imageLabels"); 
      var _27 = imageLabels.getElementsByTagName("div"); 
      while(_27.length > 0) {
         imageLabels.removeChild(_27[0]); 
         }
      }
   else {
      labels.open("GET", _25, true); 
      labels.onreadystatechange = labelsHandler; 
      labels.send(null); 
      }
   }
function labelsHandler() {
   if(labels.readyState == 4) {
      var _28 = eval("(" + labels.responseText + ")"); 
      var lab = _28.labels.length; 
      for(var $i = 0; $i < lab; $i++) {
         var _2b = _28.labels[$i].label; 
         var _2c = _28.labels[$i].name; 
         var nX = _28.labels[$i].x; 
         var nY = _28.labels[$i].y; 
         pinImage = document.createElement("div"); 
         pinImage.style.position = "absolute"; 
         pinImage.style.left = (nX * gImageWidth / (Math.pow(2, gTierCount - 1 - zoom))) + "px"; 
         pinImage.style.top = (nY * gImageHeight / (Math.pow(2, gTierCount - 1 - zoom))) + "px"; 
         pinImage.style.width = 8 * _2b.length + "px"; 
         pinImage.style.height = "2px"; 
         pinImage.style.zIndex = 1; 
         pinImage.setAttribute("id", "L" + $i); 
         pinImage.innerHTML = "<a href=http://www.szallaskereso.hu><img src=images/potty.gif border=0 alt=hahaha></a>" + _2b; 
         $("imageLabels").appendChild(pinImage); 
         }
      }
   }
function refreshTiles() {
   var _2f = $("imageTiles"); 
   var _30 = _2f.getElementsByTagName("img"); 
   while(_30.length > 0) {
      _2f.removeChild(_30[0]); 
      }
   }
function slideNext() {
   if(slidePointer < JSONnum - 1) {
      slidePointer++; 
      }
   else {
      slidePointer = 0; 
      }
   path = JSONout.slides[slidePointer].path; 
   width = JSONout.slides[slidePointer].width; 
   height = JSONout.slides[slidePointer].height; 
   if(JSONout.slides[slidePointer].labelspath != undefined) {
      labelspath = JSONout.slides[slidePointer].labelspath; 
      loadLabels(); 
      }
   else {
      labelspath = ""; 
      }
   init(); 
   refreshTiles(); 
   checkTiles(); 
   }
function slidePrev() {
   if(slidePointer > 0) {
      slidePointer--; 
      }
   else {
      slidePointer = JSONnum - 1; 
      }
   path = JSONout.slides[slidePointer].path; 
   width = JSONout.slides[slidePointer].width; 
   height = JSONout.slides[slidePointer].height; 
   if(JSONout.slides[slidePointer].labelspath != undefined) {
      labelspath = JSONout.slides[slidePointer].labelspath; 
      loadLabels(); 
      }
   else {
      labelspath = ""; 
      }
   init(); 
   refreshTiles(); 
   checkTiles(); 
   }
function loadXMLfile() {
   request = getHTTPObject(); 
   request.onreadystatechange = xmlread; 
   request.open("GET", path + "ImageProperties.xml", true); 
   request.send(null); 
   }
function xmlread() {
   if(request.readyState == 4) {
      var _31 = request.responseXML.documentElement; 
      width = parseFloat(_31.getAttribute("WIDTH")); 
      height = parseFloat(_31.getAttribute("HEIGHT")); 
      loadedXML = 1; 
      init(); 
      }
   }
function stripPx(_32) {
   if(_32 == "") {
      return 0; 
      }
   return parseFloat(_32.substring(0, _32.length - 2)); 
   }
function winsize() {
   viewportWidth = 1300; 
   viewportHeight = 1000; 
   if(typeof (window.innerWidth) == "number") {
      viewportWidth = window.innerWidth; 
      viewportHeight = window.innerHeight; 
      }
   else {
      if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
         viewportWidth = document.documentElement.clientWidth; 
         viewportHeight = document.documentElement.clientHeight; 
         }
      else {
         if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
            viewportWidth = document.body.clientWidth; 
            viewportHeight = document.body.clientHeight; 
            }
         }
      }
   }
function $(i) {
   return document.getElementById(i); 
   }
function handle(_34) {
   if(_34 < 0) {
      if(wheelmode == 0) {
         ZoomIn(); 
         }
      else {
         slideNext(); 
         }
      }
   else {
      if(wheelmode == 0) {
         ZoomOut(); 
         }
      else {
         slidePrev(); 
         }
      }
   }
function wheel(_35) {
   var _36 = 0; 
   if(!_35) {
      _35 = window.event; 
      }
   if(_35.wheelDelta) {
      _36 = _35.wheelDelta / 120; 
      }
   else {
      if(_35.detail) {
         _36 =- _35.detail / 3; 
         }
      }
   if(_36) {
      handle(_36); 
      }
   if(_35.preventDefault) {
      _35.preventDefault(); 
      }
   _35.returnValue = false; 
   }
if(window.addEventListener) {
   window.addEventListener("DOMMouseScroll", wheel, false); 
   }
window.onmousewheel = document.onmousewheel = wheel; 
function capturekey(e) {
   var k = (typeof event != "undefined") ? window.event.keyCode : e.keyCode; 
   if(k == 187 || k == 61) {
      ZoomIn(); 
      }
   else {
      if(k == 189 || k == 109) {
         ZoomOut(); 
         }
      else {
         if(k == 39 || k == 40 || k == 34) {
            slideNext(); 
            }
         else {
            if(k == 37 || k == 38 || k == 33) {
               slidePrev(); 
               }
            }
         }
      }
   }
if(navigator.appName != "Mozilla") {
   document.onkeyup = capturekey; 
   }
else {
   document.addEventListener("keypress", capturekey, true); 
   }
function getVar(_39) {
   get_string = document.location.search; 
   return_value = ""; 
   do {
      name_index = get_string.indexOf(_39 + "="); 
      if(name_index !=- 1) {
         get_string = get_string.substr(name_index + _39.length + 1, get_string.length - name_index); 
         end_of_value = get_string.indexOf("&"); 
         if(end_of_value !=- 1) {
            value = get_string.substr(0, end_of_value); 
            }
         else {
            value = get_string; 
            }
         if(return_value == "" || value == "") {
            return_value += value; 
            }
         else {
            return_value += ", " + value; 
            }
         }
      }
   while(name_index !=- 1); 
   space = return_value.indexOf("+"); 
   while(space !=- 1) {
      return_value = return_value.substr(0, space) + " " + return_value.substr(space + 1, return_value.length); 
      space = return_value.indexOf("+"); 
      }
   return (return_value); 
   }
function getHTTPObject() {
   var xhr; 
   try {
      xhr = new ActiveXObject("Msxml2.XMLHTTP"); 
      }
   catch(e) {
      try {
         xhr = new ActiveXObject("Microsoft.XMLHTTP"); 
         }
      catch(E) {
         xhr = false; 
         }
      }
   if(!xhr && typeof XMLHttpRequest != " undefined") {
      xhr = new XMLHttpRequest(); 
      }
   return xhr; 
   }


