
function open_doc(cime,szelesseg,magassag,ablak){
	if (!szelesseg) szelesseg=500;
	if (!magassag) magassag=535;
	if (typeof usrwindow != 'undefined'){
	if (!usrwindow.closed){usrwindow.close();}}
		usrwindow=window.open(cime, ablak, 'top=0,left=0,resizable=no,hotkeys=yes,width='+szelesseg+',height='+magassag);
}

function open_doc_scroll(cime,szelesseg,magassag,ablak){
	if (!szelesseg) szelesseg=516;
	if (!magassag) magassag=535;
	if (typeof usrwindow != 'undefined'){
	if (!usrwindow.closed){usrwindow.close();}}
		usrwindow=window.open(cime, ablak, 'toolbar=no,scrollbars=yes,menubar=no,top=0,left=0,resizable=yes,hotkeys=yes,width='+szelesseg+',height='+magassag);
}

function addEvent(obj, evType, fn) {
  if (obj.addEventListener) {
		obj.addEventListener(evType, fn, true);
		return true;
   } else if (obj.attachEvent) {
    var r = obj.attachEvent("on"+evType, fn);
		return r;
   } else {
    return false;
  }
}

function fixMenuForIE() {
  var navRoot = document.getElementById("left-menu");
  if (navRoot) {
    for (var i=0; i < navRoot.childNodes.length; i++) {
  	  var node = navRoot.childNodes[i];
  	  if (node.nodeName == "LI" || node.nodeName == "li") {
  		  node.onmouseover=function() { this.className+=" over"; this.style.zIndex=1000; }
  		  node.onmouseout=function() { this.className=this.className.replace(" over", ""); }
  	  }
    }
  }
}

//addEvent(window, 'load', fixMenuForIE);

var gallery_imgs = new Array();
var gallery_titles = new Array();
var gallery_loaded = false;

function gallery_init() {
  if (gallery_loaded) return; else gallery_loaded = true;
  var pics_div = document.getElementById('gallery-pics');
  if (!pics_div) return; 
  var imgs = pics_div.getElementsByTagName('img');
  for(var i=0; i<imgs.length; i++) { // >
    //var src = imgs[i].src.replace(/\/gk([0-9a-f]+\.\w+)$/i,'/gn$1'); src = 'url('+src+')';
    gallery_imgs[i] = gallery_gnk_pic[i]; // a gelera_popup.inc komponensbol
    gallery_titles[i] = '<strong>' + imgs[i].alt + '</strong><br /><em>' + imgs[i].title + '</em>';
    //remove//eval("addEvent(imgs[i], 'click', function(event){gallery_setimage("+i+");event.preventDefault();event.stopPropagation();})");
  }
  //remove//addEvent(document.getElementById('gallery-prev'), 'click', function(event){document.getElementById('gallery-prev-a').blur();gallery_prev();event.preventDefault();event.stopPropagation();});
  //remove//addEvent(document.getElementById('gallery-next'), 'click', function(event){document.getElementById('gallery-next-a').blur();gallery_next();event.preventDefault();event.stopPropagation();});
}
addEvent(window, 'load', gallery_init);

function gallery_prev() {
  var i=0; while(i<gallery_imgs.length && gallery_imgs[i]!=document.getElementById('gallery-pic').style.backgroundImage) {i++;}
  if (i==gallery_imgs.length) {
    i=0;
   } else {
    i--; if (i<0) { i = gallery_imgs.length-1; }
  }
  gallery_setimage(i);
}

function gallery_next() {
  var i=0; while(i<gallery_imgs.length && gallery_imgs[i]!=document.getElementById('gallery-pic').style.backgroundImage) {i++;} 
  if (i==gallery_imgs.length) {
    i=0; 
   } else {
    i++; if (i==gallery_imgs.length) { i = 0; }
  }
  gallery_setimage(i);
}

function gallery_setimage(num) {
  document.getElementById('gallery-pic').innerHTML = ''; // remove text, show image
//  document.getElementById('gallery-pic').style.backgroundColor = '#fff';
  document.getElementById('gallery-pic').style.backgroundImage = gallery_imgs[num];
  document.getElementById('gallery-title').innerHTML = gallery_titles[num];
  var imgs = document.getElementById('gallery-pics').getElementsByTagName('img');
  setTimeout("gallery_blink("+num+")", 150);
  setTimeout("gallery_blink("+num+")", 300);
  setTimeout("gallery_blink("+num+")", 450);
  setTimeout("gallery_blink("+num+")", 600);
  setTimeout("gallery_blink("+num+")", 750);
  setTimeout("gallery_blink("+num+")", 900);
  for(var i=0; i<imgs.length; i++) { // >
    if (i==num) {
      imgs[i].className='actual';
      imgs[i].scrollIntoView();
    } else {
      imgs[i].className='';
    }
  }
}

function gallery_blink(num) {
  var imgs = document.getElementById('gallery-pics').getElementsByTagName('img');
  if ( imgs[num].className == 'actual' ) {
    imgs[num].className='blink';
  } 
  else if ( imgs[num].className == 'blink' ) {
    imgs[num].className='actual';
  }
}

function enlarge(picname,w,h) {
	x = (screen.availWidth - 12 - w) / 2;
	y = (screen.availHeight + 20 - h) / 2;

    popup = window.open('','','toolbar=no,location=no,directories=no,menubar=no,resizable=no,status=no,scrollbars=auto,left=' + x + ',top=' + y + ',width='+w+',height='+h); 
    popup.document.write('<HTML><title>Picture</title><BODY style="margin-top: 0px; margin-left: 0px; margin-bottom: 0px; margin-right: 0px;"><div style="position: absolute; left: 0px; top: 0px; right:0px; bottom:0px;"><TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0><TR VALIGN=MIDDLE><TD ALIGN=CENTER>'); 
    popup.document.write('<IMG SRC="'+picname+'" WIDTH="'+w+'" HEIGHT="'+h+'" BORDER=0 OnClick=self.close()></TR></TD></TABLE></div></BODY></HTML>'); 
    popup.document.close();
}

function enlarge_scrollable(picname,w,h) {
    x = (screen.availWidth - 12 - w) / 2 + 15;
    y = (screen.availHeight + 20 - h) / 2 + 15;

    popup = window.open('','','toolbar=no,location=no,directories=no,menubar=no,resizable=no,status=no,scrollbars=yes,left=' + x + ',top=' + y + ',width='+w+',height='+h); 
    popup.document.write('<HTML><title>Picture</title><BODY style="margin-top: 0px; margin-left: 0px; margin-bottom: 0px; margin-right: 0px;"><div style="position: absolute; left: 0px; top: 0px; right:0px; bottom:0px;"><TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0><TR VALIGN=MIDDLE><TD ALIGN=CENTER>'); 
    popup.document.write('<IMG SRC="'+picname+'" WIDTH="'+w+'" HEIGHT="'+h+'" BORDER=0 OnClick=self.close()></TR></TD></TABLE></div></BODY></HTML>'); 
    popup.document.close();
}