var delayHide = null;
var menuOffset = {};

function menuOver(id) {
	hideMenu();
	var subMenu = $('#mainMenu_subMenu_'+id);
	var menuPos = $('#mainMenu_'+id).offset();
	if (subMenu.length > 0) {
		subMenu.css({
				top: menuPos.top+$('#mainMenu_'+id).height()-4+'px', 
				left: menuPos.left-$('#frame').offset().left+'px'
			}).show().
			mouseout(startDelayhide).
			mouseover(clearDelayhide);
	}
}

function menuOut(id) {
    startDelayhide();
}

function startDelayhide() {
    delayhide=setTimeout(hideMenu,500);
}

function clearDelayhide() {
    if (window.delayhide) {
        clearTimeout(delayhide);
    }
}

function hideMenu() {
	clearDelayhide();
    $('.dropdown').hide();

}

function parseMails() {
    var emailElements = $('a.mailaddr');
    for (var i=0; i<emailElements.length; i++) {
        if ($('img', emailElements[i]).length > 0) {
            var email = $('img', emailElements[i]).attr('title').replace(/\s*\[DOT\]\s*/g, '.').replace(/\s*\[AT\]\s*/, '@');
            $(emailElements[i]).attr('href', 'mailto:'+email);
            $('img', emailElements[i]).attr('title', '');
        } else {
            var email = $(emailElements[i]).text().replace(/\s*\[DOT\]\s*/g, '.').replace(/\s*\[AT\]\s*/, '@');
            $(emailElements[i]).attr('href', 'mailto:'+email).text(email);
        }
    }
}

function openMap(mapUrl) {
	var mapWin;
    mapWin = window.open(mapUrl, 'mapWin','top=0,left=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=800,height=600');
}
function open_popup(pURL,name,w,h,scrollbars,resizable)
{
 if (resizable==null) resizable=1;
 if (scrollbars==null) scrollbars=1;
 var top  = ((screen.availHeight-h)/2);
 var left = ((screen.availWidth-w)/2);
 var nyit = window.open(pURL,name,'toolbar=0,location=0,directories=0,status=0,\
  menubar=0,scrollbars='+scrollbars+',resizable='+resizable+',width='+w+',height='+h+',top='+top+',left='+left);
 nyit.focus();
 return nyit;
}
function pop_kep(kep,label,w,h)
{
 var ablak=open_popup('about:blank','nagykep',w,h,0,0);
 var d=ablak.document;
 var title=(label.length>0) ? label+' - ' : '';
 d.write('<html><head><title>'+addquotes(title)+'</title>',
  '<scr'+'ipt type="text/javasc'+'ript">',
  'var NS = (navigator.appName=="Netscape")?true:false;',
  'function FitPic() {',
     'iWidth = (NS)?window.innerWidth:document.body.clientWidth;',
     'iHeight = (NS)?window.innerHeight:document.body.clientHeight;',
     'iWidth = document.images[0].width - iWidth; ',
     'if (document.images[0].height<200) {iiHeight=200} else {iiHeight=document.images[0].height}',
     'iHeight = iiHeight - iHeight;',
     'window.resizeBy(iWidth, iHeight); ',
     'self.focus(); ',
  '}; ',
  '</scr'+'ipt>',
  '</head><body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">',
  '<a name="nagykep" href="#" onclick="self.close();" onblur="self.close()">',
  '<img border="0" alt="',addquotes(label),'" src="',addquotes(kep),'" onload="FitPic();"></a></body></html>',
  '<scr'+'ipt type="text/javasc'+'ript">//FitPic();</scr'+'ipt>'
 );
 //d.anchors[0].focus();
}
$(document).ready(parseMails);