function menuOver(pont) {
    if(document.getElementById(pont)) {
        var oldsrc = document.getElementById(pont).src;
        document.getElementById(pont).src = oldsrc.replace(/.gif/,"_o.gif");
    }
}
function menuOut(pont) {
    if(document.getElementById(pont)) {
        var oldsrc = document.getElementById(pont).src;
        document.getElementById(pont).src = oldsrc.replace(/_o.gif/,".gif");
    }
}

function imageopen(thumbsrc, width, height, title) {
    var url = thumbsrc.replace(/_th./,".");
    imgwin = window.open('','okotarscd','left=0,top=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=' + (width) + ',height=' + (height+4));
    imgwin.document.open();
    imgwin.document.write('<html><head><title>'+title+'</title></head><body style="margin: 0; padding: 0; border: none"><a href="javascript:window.close()"><img src="'+url+'" style="border: none" alt=""></a></body></html>');
    imgwin.document.close();
}

function stripHTML(tostrip) {
    var re= /<\S[^><]*>/g
    return tostrip.replace(re, "")
}

function stripAll(id) {
    document.getElementById('szervezet_'+id).innerHTML = '<b>'+stripHTML(document.getElementById('szervezet_'+id).innerHTML)+'</b>'
    document.getElementById('projekt_'+id).innerHTML = '<b>'+stripHTML(document.getElementById('projekt_'+id).innerHTML)+'</b>'
    document.getElementById('tipus_'+id).innerHTML = stripHTML(document.getElementById('tipus_'+id).innerHTML)
    document.getElementById('tema_'+id).innerHTML = stripHTML(document.getElementById('tema_'+id).innerHTML)
    document.getElementById('megye_'+id).innerHTML = stripHTML(document.getElementById('megye_'+id).innerHTML)
    document.getElementById('varos_'+id).innerHTML = stripHTML(document.getElementById('varos_'+id).innerHTML)
    document.getElementById('descr_'+id).innerHTML = stripHTML(document.getElementById('descr_'+id).innerHTML)
}

function search_showrow(found, id) {
    if(found) {
        //kurva ie
        if(navigator.appName == 'Microsoft Internet Explorer') {
            document.getElementById('tr1_'+id).style.display = 'block';
            document.getElementById('tr2_'+id).style.display = 'block';
        } else {
            document.getElementById('tr1_'+id).style.display = 'table-row';
            document.getElementById('tr2_'+id).style.display = 'table-row';
        }
    } else {
        document.getElementById('tr1_'+id).style.display = 'none'
        document.getElementById('tr2_'+id).style.display = 'none'
    }
}

var needle = ''
var haystackId = new Array()

function search_common() {
    document.body.style.cursor = "wait";
    needleRE = new RegExp(needle, "i")
    for(i=0;i<111;i++) if(document.getElementById('tr1_'+i)) {
        found = false
        haystack = new Array

        for(j in haystackId) {
            haystack[j] = stripHTML(document.getElementById(haystackId[j]+'_'+i).innerHTML)
            foundneedle = haystack[j].match(needleRE)
            if(foundneedle != null) {
                haystack[j] = haystack[j].replace(needleRE, '<span>' + foundneedle + '</span>')
                found = true
            }
        }
        if(found) {
            stripAll(i)
            for(j in haystack) {
                document.getElementById(haystackId[j]+'_'+i).innerHTML = haystack[j]
            }
        }
        search_showrow(found, i)
    }
    document.body.style.cursor = "default";
}

var search_delay = ''

function search(_needle, _haystackId) {
    needle = _needle
    haystackId = _haystackId
    clearTimeout(search_delay)
    search_delay = window.setTimeout('search_common()', 347);
}
