function linkMainObj (mainObjType, otherObjType, mid, oid, the_row, ret_index) {
    kesz = false;
    $('#ext_row_'+the_row).animate({ height:"20px" }, 1000);
    timer = setTimeout("if (!kesz) {$('#ext_row_"+the_row+"').html('<img src=\""+BASEURL+"images/cms_images/loader_mini.gif\">&nbsp;Mentés folyamatban ...')};",1000);
    var p=new Array();
    p['command'] = "link_objs";
    p['linked'] = otherObjType;
    p['mid'] = mid;
    p['oid'] = oid;
    if (oid == "new") {
        p['nname'] = $("#new_tag_name").val();
        p['nszev'] = $("#new_tag_szev").val();
        p['nemail'] = $("#new_tag_email").val();
    }
    
    
    if (mainObjType) thefile = mainObjType + ".php";
        else thefile = "onlab.php";

    getAjax(thefile,p, function(ret){
                $('#ext_row_'+the_row).html(ret);
                kesz = true;
                timer = setTimeout("$('#ext_row_"+the_row+"').slideUp('slow')", 1500);
                timer1 = setTimeout('editH'+ret_index+'ListItem("'+mainObjType+'", '+the_row+', '+mid+', true)', 1950);
            });
            
            
    //editHListItem("egyenek",<?=$t?>,<?=$ta['ID']?>,true)
}

function linkOtherObj (mainObjType, otherObjType, mid, oid, the_row, ret_index) {
    kesz = false;
    $('#ext_row_'+the_row).animate({ height:"20px" }, 1000);
    timer = setTimeout("if (!kesz) {$('#ext_row_"+the_row+"').html('<img src=\""+BASEURL+"images/cms_images/loader_mini.gif\">&nbsp;Mentés folyamatban ...')};",1000);
    var p=new Array();
    p['command'] = "link_objs";
    p['linked'] = otherObjType;
    p['mid'] = mid;
    p['oid'] = oid;
    
    if (mainObjType) thefile = mainObjType + ".php";
        else thefile = "onlab.php";

    getAjax(thefile,p, function(ret){
                $('#ext_row_'+the_row).html(ret);
                kesz = true;
                timer = setTimeout("$('#ext_row_"+the_row+"').slideUp('slow')", 1500);
                timer1 = setTimeout('editH'+ret_index+'ListItem("'+otherObjType+'", '+the_row+', '+oid+', true)', 1950);
            });
            
            
    //editHListItem("egyenek",<?=$t?>,<?=$ta['ID']?>,true)
}
function delMainObjLink (mainObjType, otherObjType, mid, oid, the_row, ret_index) {
    kesz = false;
    $('#ext_row_'+the_row).animate({ height:"20px" }, 1000);
    timer = setTimeout("if (!kesz) {$('#ext_row_"+the_row+"').html('<img src=\""+BASEURL+"images/cms_images/loader_mini.gif\">&nbsp;Mentés folyamatban ...')};",1000);
    var p=new Array();
    p['command'] = "del_link";
    p['linked'] = otherObjType;
    p['mid'] = mid;
    p['oid'] = oid;
    
    if (mainObjType) thefile = mainObjType + ".php";
        else thefile = "onlab.php";

    getAjax(thefile,p, function(ret){
                $('#ext_row_'+the_row).html(ret);
                kesz = true;
                timer = setTimeout("$('#ext_row_"+the_row+"').slideUp('slow')", 1500);
                timer1 = setTimeout('editH'+ret_index+'ListItem("'+mainObjType+'", '+the_row+', '+mid+', true)', 1950);
            });
}
function delOtherObjLink (mainObjType, otherObjType, mid, oid, the_row, ret_index) {
    kesz = false;
    $('#ext_row_'+the_row).animate({ height:"20px" }, 1000);
    timer = setTimeout("if (!kesz) {$('#ext_row_"+the_row+"').html('<img src=\""+BASEURL+"images/cms_images/loader_mini.gif\">&nbsp;Mentés folyamatban ...')};",1000);
    var p=new Array();
    p['command'] = "del_link";
    p['linked'] = otherObjType;
    p['mid'] = mid;
    p['oid'] = oid;
    
    if (mainObjType) thefile = mainObjType + ".php";
        else thefile = "onlab.php";

    getAjax(thefile,p, function(ret){
                $('#ext_row_'+the_row).html(ret);
                kesz = true;
                timer = setTimeout("$('#ext_row_"+the_row+"').slideUp('slow')", 1500);
                timer1 = setTimeout('editH'+ret_index+'ListItem("'+otherObjType+'", '+the_row+', '+oid+', true)', 1950);
            });
}



function openList(type, id, the_row){
    var p=new Array();
    p['command'] = "openList";
    p['eid'] = id;
    if (type) thefile = type + ".php";
        else thefile = "onlab.php";
    
    getAjax(thefile,p, function(ret){
                //$('#ext_row_'+the_row).html(ret);
                alert('#csop_tagok_'+the_row);
                $('#csop_tagok_'+the_row).html(ret);
                //kesz = true;
                $('#csop_tagok_'+the_row).slideDown('slow');
                
                //timer = setTimeout("$('#ext_row_"+the_row+"').slideUp('slow')", 1500);
                //timer1 = setTimeout('editH'+ret_index+'ListItem("'+otherObjType+'", '+the_row+', '+oid+', true)', 1950);
            });
}

function print_reszletek(url){
    var a = window.open(url,'','width=800,height=800');
    a.print();
}

function printDiv (div) {
    var a = window.open('','','width=800,height=600');
    a.document.open("text/html");
    a.document.write('<html><head><link rel="stylesheet" href="/css/base.css"></link><link rel="stylesheet" href="/css/index.css"></link><link rel="stylesheet" href="/css/print.css"></link></head><body style="padding-left:20px;background-image:none;background-color:#FFFFFF;">');
    a.document.write(document.getElementById(div).innerHTML);
    a.document.close();
    a.print();
    a.close();
} 

function sendEmail (type) {
    kesz = false;
    //<br />$('#cms_popup').animate({ height:"20px" }, 1000);
    timer = setTimeout("if (!kesz) {$('#cms_popup').html('<img src=\""+BASEURL+"images/cms_images/loader_mini.gif\">&nbsp;Mentés folyamatban ...')};",1000);
    
    //alert();
    var p=postSerializeForm(document.emailform);
    p += "&command=send";

    thefile = type + ".php";

    postAjax(thefile,p, function(ret){
                            $('#cms_popup').html(ret);
                            kesz = true;
                            timer = setTimeout("$('#cms_popup').slideUp('slow');", 1500);
                            timer1 = setTimeout('refreshTList("'+type+'")', 1750);
                        });   
}

function kurzSelected(type) {
    $('#cms_popup').html('');
    $('a.modalCloseImg').click(); 
    var p=new Array();
    p['command'] = "refresh";
    p['email_kurz'] = $("#email_kurz").val();
    
    thefile = type + ".php";

    getAjax(thefile,p, function(){
                        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
                            $('#admin_fields').html(xmlHttp.responseText); 
                        }
                        });
}
function atsorolas (type, jel_id, id_id, eid) {
    $('#cms_popup').html("<img src='"+BASEURL+"images/cms_images/loader_circ.gif' class='float_left'><b>Betöltés folyamatban!</b><br />Kis türelmet ...");
    $('#cms_popup').modal(); 
    var p=new Array();
    p['command'] = "atsorol_form";
    p['jel_id'] = jel_id;
    p['id_id'] = id_id;
    p['kurz_id'] = eid;
    
    thefile = type + ".php";

    getAjax(thefile,p, function(){
                        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
                            $('a.modalCloseImg').click();                   
                            $('#cms_popup').html(xmlHttp.responseText);
                            editorInit('base','exact','megj');
                            $('#cms_popup').modal(); 
                            if (type == "meres") editorInit('base','exact','r_leir'); 
                            else editorInit('base','exact','leiras'); 
                        }
                        });
}
function atsorolas_save(type, id, mode){
    kesz = false;
    //<br />$('#cms_popup').animate({ height:"20px" }, 1000);
    timer = setTimeout("if (!kesz) {$('#cms_popup').html('<img src=\""+BASEURL+"images/cms_images/loader_mini.gif\">&nbsp;Mentés folyamatban ...')};",1000);
    
    //alert();
    var p=new Array();
    p['command'] = "atsorol_save";
    p['id'] = id;
    if (mode == 'kurzon_belul')
        p['id_id'] = $('#kurzon_belul').val();
    else {
        p['id_id'] = $('#kurzon_kivul').val();
        p['kurz_id'] = 1;
    }

    if (type) thefile = type + ".php";
        else thefile = "onlab.php";

    getAjax(thefile,p, function(ret){
                            $('#cms_popup').html(ret);
                            kesz = true;
                            timer = setTimeout("$('#cms_popup').slideUp('slow');", 1500);
                            timer1 = setTimeout('refreshTList("'+type+'")', 1750);
                        });   
}

function addJelForm (type, id_id, eid,row) {
    $('#cms_popup').html("<img src='"+BASEURL+"images/cms_images/loader_circ.gif' class='float_left'><b>Betöltés folyamatban!</b><br />Kis türelmet ...");
    $('#cms_popup').modal(); 
    var p=new Array();
    p['command'] = "addJel_form";
    p['id_id'] = id_id;
    p['kurz_id'] = eid;
    p['row'] = row;
    
    thefile = type + ".php";

    getAjax(thefile,p, function(){
                        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
                            $('a.modalCloseImg').click();                   
                            $('#cms_popup').html(xmlHttp.responseText);
                            editorInit('base','exact','megj');
                            $('#cms_popup').modal(); 
                            if (type == "meres") editorInit('base','exact','r_leir'); 
                            else editorInit('base','exact','leiras'); 
                        }
                        });
}
function saveNewJel (type, id_id, eid, row) {
    kesz = false;
    //<br />$('#cms_popup').animate({ height:"20px" }, 1000);
    timer = setTimeout("if (!kesz) {$('#cms_popup').html('<img src=\""+BASEURL+"images/cms_images/loader_mini.gif\">&nbsp;Mentés folyamatban ...')};",1000);
    
    //alert();
    var p=postSerializeForm(document.addJelForm);
    p += "&command=save_new_jel";

    if (type) thefile = type + ".php";
        else thefile = "onlab.php";

    postAjax(thefile,p, function(ret){
                            $('#cms_popup').html(ret);
                            kesz = true;
                            timer = setTimeout("$('#cms_popup').slideUp('slow');", 1500);
                            //timer1 = setTimeout('refreshTList("'+type+'")', 1750);
                            timer1 = setTimeout('viewJelList("'+type+'", "'+id_id+'", "'+eid+'", "'+row+'", true);$("#cms_popup").html("");$("a.modalCloseImg").click();', 1750);
                        });   
}
function getHint (type, field, field_id, text, target) {
    document.getElementById('hint_'+field_id).innerHTML='<img src="'+BASEURL+'images/cms_images/loader_mini.gif">';
    var p=new Array();
    p['command'] = "hint";
    p['field'] = field;
    p['target'] = target;
    p['text'] = text;
    
    thefile = type + ".php";
    var urlparam = "";
    keys = array_keys (p);
    for (k=0;k<keys.length;k++) {
        //if (urlparam == "") urlparam = "?"; else
         urlparam = urlparam+"&";
        urlparam = urlparam+keys[k]+"="+p[keys[k]];
    }

    postAjax(thefile,urlparam, function(ret){
                        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
                            document.getElementById('hint_'+field_id).innerHTML=ret;
                        }
                        });
}

function set_field(field_id, text){
    document.getElementById(field_id).value = text;
}
