var fullWidth;

function init() {

  if (!(isMinIE4)) { return false; }

  // Get width of window, need to account for scrollbar width in Netscape.
  fullWidth = getWindowWidth() - (isMinNS4 && getWindowHeight() < getPageHeight() ? 16 : 0);

  // use this section only if you will be positioning the menu relative to 
  // another element on the web page.
  // locate mnuMarker offset
  var yy = getOffsetTop('mnuMarker');
  var xx = getOffsetLeft('mnuMarker');
  // give the menubar a similar offset, may need to tweak
  myNavBar1.moveTo(xx+5,yy);

  // the -4 is to set the menu a little less the full width to avoid the horizontal scrollbar
  myNavBar1.resize(fullWidth-150);
  myNavBar1.create();
  myNavBar1.setzIndex(2);
}




function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {
	var j = i + alen;    
	if (document.cookie.substring(i, j) == arg)      
	return getCookieVal (j);    
	i = document.cookie.indexOf(" ", i) + 1;    
	if (i == 0) break;   
	}  
	return null;
}

function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);   
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));


function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function BrowserDetect() {
	var browser = navigator.appName
	if (browser=="Microsoft Internet Explorer") this.browser = "ie"
	else if (browser=="Netscape") this.browser = "ns"
	else this.browser = browser
	this.ie = (this.browser=="ie")
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
	this.ver = parseInt(navigator.appVersion)
	this.ns = (this.browser=="ns")
	this.ns4 = (this.browser=="ns" && this.ver==4)
	this.ns5 = (this.browser=="ns" && this.ver==5)
	if (this.ie5) this.ver = 5
	this.min = (this.ns4||this.ns5||this.ie4||this.ie5)
}
is = new BrowserDetect();



function ups(url,w,h) {
	if (window.popup_window) {
		popup_window.close();
	}
	popup_window = window.open(url,"popup","toolbar=no,location=no,directories=no,status=no,scrollbars=auto,resizable=yes,copyhistory=no,width="+w+",height="+h+" ");
	popup_window.focus();
}

function upspic(url,w,h) {
	if (window.popup_window) {
		popup_window.close();
	}
	popup_window = window.open(url,"popup","hotkeys=no;toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width="+w+",height="+h+" ");
	popup_window.focus();
}


function zoompic(url,w,h) {
	if (window.popup_window) {
		popup_window.document.write ('<html><head><meta http-equiv="expires" content="Now"><meta http-equiv="Pragma" content="no-cache"><title>&nbsp;</title></head><body topmargin="0" leftmargin="0">');
		popup_window.document.write ('<img src="'+url+'" width="'+w+'" height="'+h+'">');
		popup_window.document.write ('</body></html>');
		//popup_window.focus();
	}
}



function ToggleLayer (which) {
	if (which.style.display) {
		which.style.display="";
	} else {
		which.style.display="none";
	}
}



function ShowLayer (which) {
	if(eval('window.currTimer_'+which.id)) {
		eval('clearTimeout(currTimer_'+which.id+');');
		eval('currTimer_'+which.id+'=null;');
	}
	if (which.style.display) {
		which.style.display="";
		eval('currTimer_'+which.id+'=setTimeout("ShowLayer("+which.id+");",3000);');
	} else {
		which.style.display="none";
	}
}

function HideLayer (which) {
	if (which.style) {
		which.style.display="none";
	}
}

function ViewLayer (which) {
	if (which.style) {
		which.style.display="";
	}
}

function ShowDictionary(path,which) {
	w=400; h=400;
	url= path+'/dictionary.php?id='+which;
	dictionary = window.open(url,"dictionary","hotkeys=no;toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width="+w+",height="+h+" ");
	dictionary.focus();
}

function CloseDictionary() {
	if (window.dictionary) {
		dictionary.close();
	}
}


function ShowDictionaryOld(which) {
	if (which.style) {
		which.style.top = document.myform.downy.value;
		if (document.myform.downx.value < 400) {
			which.style.left = document.myform.downx.value;
			//which.style.width = 600-document.myform.downx.value-20;
		} else {
			which.style.left = 20;
		}
		if (which.style.display) {
			which.style.display="";
		}
	}
}

function CloseDictionaryOld(which) {
	if (which.style) {
		which.style.display="none";
	}
}


function ToggleMessage (which) {
	if (which.style.display) {
		which.style.display="";
	} else {
		which.style.display="none";
	}
	return true;
}

function CloseMessage() {
	if(currTimer!=null) {
		clearTimeout(currTimer);
		currTimer=null;
	}
	ToggleMessage(message);
}



function ModositE() {
 var acon = window.confirm("Biztos, hogy módosítani kívánja?");
 return acon;
}

function PostazE() {
 var acon = window.confirm("Biztos, hogy postázni kívánja?");
 return acon;
}

function TorolE() {
 var acon = window.confirm("Biztos, hogy törölni kívánja?");
 return acon;
}


function checkEmail (x,str1,str2) {
	valid_email = "^([0-9,a-z,A-Z]+)([.,_\-]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$";
	if (x.EMAIL.value.length == 0) {
		x.EMAIL.focus();
		x.EMAIL.select();	
		alert(str1);
		return false;					
	} else if (x.EMAIL.value.search(valid_email) == -1) {
		x.EMAIL.focus();
		x.EMAIL.select();
		alert(str2);
		return false;
	}
	return true;
}


function checkSearch (x,str1,str2) {
	newstr=x.SEARCH.value.replace(/\s/gi, "");
	if (newstr.length == 0) {
		x.SEARCH.focus();
		x.SEARCH.select();
		alert(str1);
		return false;					
	} else if (newstr.length < 2) {
		x.SEARCH.focus();
		x.SEARCH.select();
		alert(str2);
		return false;
	}
	return true;
}


function mouseTracker(e) {
	e = e || window.Event || window.event;
	document.pageX = e.pageX || e.clientX;
	document.pageY = e.pageY || e.clientY;
}

if (window.captureEvents) {
    window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
	window.onmousemove = mouseTracker;
} else {
	document.onmousemove = mouseTracker;
}

function showMenu(which,x,y) {

ContextElement=event.srcElement;
   which.style.posLeft=document.pageX+x+document.body.scrollLeft;
   which.style.posTop=document.pageY+y+document.body.scrollTop;
   which.style.display="";
}

function hideMenu(which) {
   which.style.display="none"; return true;
}
