var lastImgIndex=Array(); // Az utoljara kijelolt

function getImg(zoomId,index) {
  return document.getElementById('th_'+zoomId+'_'+index);
}

function getLink(zoomId,index) {
  return document.getElementById('a_'+zoomId+'_'+index);
}

function showItem(zoomId, newSrc, width, height, version, index, pdf) {
	var cur = getImg(zoomId, index);
	if (cur) {
		lastIndex = lastImgIndex[zoomId];
		var prev = getImg(zoomId, lastIndex);
		if (prev) {
			prev.style.border = '0px none';
		}
		cur.style.border = '1px solid #FF6600';
		lastImgIndex[zoomId] = index;
	}
	
	var  so = new SWFObject(newSrc, "flashContent", width, height, version, "#FFFFFF");
	so.write('alaprajzSWF');
	
	// changing border
	
	if (el = document.getElementById('pdf'+zoomId)) {
		
		html = "<table><tr><td>"+unescape(pdf)+"</td></tr></table>";
		el.innerHTML = html;
	}
	return false;
}

function zoom(zoomId,newSrc,width,height,index,pdf1,pdf2) {
  if (document && document.images && document.images[zoomId]) {
    if (th=getImg(zoomId,index)) {
      lastIndex=lastImgIndex[zoomId];
      if (lastTh=getImg(zoomId,lastIndex)) {
        lastTh.border=0;
      }
      th.border=1;
      lastImgIndex[zoomId]=index;
    }
    document.images[zoomId].src=newSrc;
    document.images[zoomId].width=width;
    document.images[zoomId].height=height;
    if (e=document.getElementById('pdf'+zoomId)) {
      html='<table><tr><td>'+unescape(pdf1);
//      if (pdf1 && pdf2) html+='<br>';
      html+='<td>'+unescape(pdf2)+'</table>';
      e.innerHTML=html;
    }
  }
  return false;
}

function click(zoomId,index) {
  if (a=getLink(zoomId,index)) {
    a.onclick();
  }
}

function galleryStep(zoomId,stepIndex) {
  if (stepIndex==0) { // First
    click(zoomId,stepIndex);
  } else if (stepIndex==1) {
    newIndex=lastImgIndex[zoomId]+1;
/*    if (newIndex>=lastImgIndex.Length) {
      newIndex=0;
    }*/
    click(zoomId,newIndex);
  } else if (stepIndex==-1) {
    click(zoomId,lastImgIndex[zoomId]-1);
  } else {
    click(zoomId,stepIndex);
  }
  return false;
}

