function galleryPopup(oid,pos) {
  open_doc('/xslt/gportal-gallery-popup.xslt?artid='+oid,700,685,'popup');
}

function open_doc(cime,szelesseg,magassag,ablak) {
	if(typeof usrwindow!='undefined' && !usrwindow.closed) usrwindow.close();
	pozx=screen.width?(screen.width-szelesseg)/2:0;
	pozy=screen.height?(screen.height-magassag)/2:0;
	usrwindow=window.open(cime,ablak,'resizable=no,scrollbars=no,hotkeys=yes,width='+szelesseg+',height='+magassag+',top='+pozy+',left='+pozx);
}

/* thumbos galeri */ 
function showGalleryThumb(o) {
	var i=0;
	while(i<o.childNodes.length && o.childNodes[i].tagName!='IMG') i++;
	document.getElementById('bigpicture').src=o.childNodes[i].src.replace('?options=width:120;height:60;quality:100;','?options=width:600;height:430;quality:100;');
	document.getElementById('bigpic_caption').innerHTML=o.getAttribute('caption');
	document.getElementById('bigpic_subcaption').innerHTML=o.getAttribute('subcaption'); 

	var old=document.getElementById('selected');
	if(old!=null) old.id='';
	o.id='selected';
	document.getElementById('leftnyil').style.visibility=(mozillaFriendlyPreviousSibling(o)== null?'hidden':'visible');
	document.getElementById('rightnyil').style.visibility=(mozillaFriendlyNextSibling(o)==null?'hidden':'visible');
}

function mozillaFriendlyPreviousSibling(n) {
	if(n==null) return n;
	do n=n.previousSibling;
	while(n!=null && n.tagName!='DIV');
	return n;
}

function mozillaFriendlyNextSibling(n) {
	if(n==null) return n;
	do n=n.nextSibling;
	while(n!=null && n.tagName!='DIV');
	return n;
}

function showGalleryLeft() {
	var s=document.getElementById('selected');
	if(s==null) return;
	var n=mozillaFriendlyPreviousSibling(s);
	if(n!=null) showGalleryThumb(n);
}

function showGalleryRight() {
	var s=document.getElementById('selected');
	if(s==null) return;
	var n=mozillaFriendlyNextSibling(s);	
	if(n!=null) showGalleryThumb(n);
}
