function is_numeric(what){
    if ((( what/what != 1) && (what !=0)) || what=='') return false;
    return true;
}

function getElement(id){
    if (document.all){
        return document.all(id);
    }
    else if (document.getElementById){
        return document.getElementById(id);
    }
}
   
function getInnerHTML(id){
    if (document.all){
        return document.all(id).innerHTML;
    }
    else if (document.getElementById){
        return document.getElementById(id).innerHTML;
    }
}
   
function changeInnerHTML(id, code){
    if (document.all){
        document.all(id).innerHTML = code;
    }
    else if (document.getElementById){
        document.getElementById(id).innerHTML = code;
    }
}

function MM_findObj(n, d) { //v4.01
   var p,i,x; 
   if(!d) d=document; 
	if((p=n.indexOf("?"))>0 && parent.frames.length){
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
    if(!(x=d[n])&&d.all)
	x=d.all[n];
    for (i=0;!x&&i<d.forms.length;i++)
	x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++)
	x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function nclick(id){
    var what = getElement('tree_' + id);
    var kep = getElement('node_' + id);
       
    if(kep.src.indexOf('/zart.png') != -1) {
    	what.style.display='block';
	kep.src='style/images/nyitva.png';
    } else {
	what.style.display='none';
	kep.src='style/images/zart.png';
    }
}

function nclick3(id){
    var what = getElement('tree_' + id);
    var kep = getElement('node_' + id);
       
    document.getElementById('footer').innerHTML = 'Display: '+what.style.display;
    
    if (what.style.display=='none') {
    	what.style.display='block';
	kep.src='style/images/nyitva.png';
    } else {
	what.style.display='none';
	kep.src='style/images/zart.png';
    }
}


function nclick2(id){
    var what = getElement('tree_' + id);
       
    if (what.style.visibility=='hidden') {
    	what.style.visibility='visible';
    } else {
	what.style.visibility='hidden';
    }
}


function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sndReq(action,arg) {
    document.getElementById('footer').innerHTML = 'index.php?ajax=ok&menu='+action+arg;
    http.open('get', 'index.php?ajax='+action+arg);
    http.onreadystatechange = handleResponse;
    http.send(null);
  }

function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

//	    document.getElementById('footer').innerHTML = response;
        if(response.indexOf('|!|' != -1)) {
            update = response.split('|!|');
            document.getElementById(update[0]).innerHTML = update[1];
        }
    }
}
function email(){
    var obj = document.getElementsByTagName("a");
    var max_i = obj.length - 1;
    var text = "";
    
    for(i=0;i<=max_i;i++){
	link = obj[i];
	if (link.href.search("mailto:") != -1) {
	    link.href = link.href.replace("_@_","@");
	    text = link.innerHTML.replace("_@_","@");
	    if (text.search("mailto:") != -1) { // ie miatt kell, valamiért beleteszi a 'mailto:' szöveget
		text = text.replace("mailto:","");
	    }
	    link.innerHTML = text;
        }
    }
    
    obj = document.getElementsByTagName("area");
    max_i = obj.length - 1;
    
    for(i=0;i<=max_i;i++){
	link = obj[i];
	if (link.href.search("mailto:") != -1) {
	    link.href = link.href.replace("_@_","@");
        }
    }
}
