function showAnunturiCategs(categ,ind) {

    //first time seeing the page, no category request was made explicitly
    if(categ == '') {
        categ = -1;
    }
	//load the content
	var ldiv = $("#adds_from_categ");
	//ldiv.html("<img src='"+ _QBOX_WEB_ROOT +"/images/indicator.gif' />");

    //make a transition when changing content to 0 alpha (full transparent)
    ldiv.fadeOut('fast');

    //highlight clicked element
    if(categ > 0){
        //remove bold from the other links
        $('a[id^="categ_"]').css('font-weight','normal');

        //bold current selected categ
        $('#categ_'+categ).css('font-weight','bold');
    }

    $.post(_QBOX_WEB_ROOT + "anunt/anunt_tool_ajx.php", {anunt_categ: categ, anunt_categ_ind: ind}, function(resp_data){
            anunturiContentHandler(resp_data);
        });
    //return false;
}


function anunturiContentHandler(transport) {
	var ldiv = $("#adds_from_categ");
    var town = _ORAS_SESS_NUME;
    
    //get response in JSON format (OBJECT)
    //var resp = transport.responseText.evalJSON(true);
    if(typeof(transport) === "string"){

        var resp = eval('(' + transport + ')');

        if(typeof(resp) === 'object'){

            var sel_categ = resp.categ_id;
            var sel_categ_name = resp.categ_name;
            var jsrest = resp.body;

            ldiv.fadeIn('fast');
            ldiv.html( jsrest );

            if(sel_categ){
                //$("more_adds_from_categ").writeAttribute('href',_QBOX_WEB_ROOT+_ORAS_SESS_NUME+'/anunturi/'+sel_categ_name+'.html');
                $("#more_adds_from_categ").attr('href',_QBOX_WEB_ROOT+_ORAS_SESS_NUME+'/anunturi/'+sel_categ_name+'.html');
            }
        } //check to see if after evaluation, response is an JSON object
    }//check transport type
}


function showAnunturiCategsList(max_categs_no,categs_per_page,get_next_page){
	//ldiv.html("<img src='"+ _QBOX_WEB_ROOT +"/images/indicator.gif' />");
    //var sessid = _SESSID;
    //make a transition when changing content to 0 alpha (full transparent)
    $('#iu_anunturi_categs_list').fadeOut('fast');

    $.post(_QBOX_WEB_ROOT + "anunt/anunt_categs_list_ajx.php", {max_categs_no: max_categs_no, categs_list_no: categs_per_page, next_page: get_next_page}, function(resp_data){
            anunturiRefreshCategsList(resp_data);
    });

}

function anunturiRefreshCategsList(transport){
    var ldiv = $("#iu_anunturi_categs_list");

    //get response in JSON format (OBJECT)
    if(typeof(transport) == "string"){
        var resp = eval('(' + transport + ')');

        if(typeof(resp) == 'object'){
            //ldiv.html(resp.categs_list+'<li>'+resp.max_categs+'</li>'+'<li>'+resp.ind+'</li>'); //for debugging
            ldiv.html(resp.categs_list);

            //make a transition when showing new content to full alpha
            ldiv.fadeIn('fast');

            //refresh the anunturi content with the category of first element from the new list
            showAnunturiCategs(resp.first_new_categ_id,0);
        }
    }
}


