$(function() {
    // filtre cazare
    $('.filtru').live("click",function() {
        var ID = $(this).attr("id");
        var sectiune = $(this).attr("name");
        if (ID) {
            $("#rezultat_filtre").html('<center><img src="http://www.pensiuni-turistice.eu/images/ajax-loader2.gif" border="0" alt="Se incarca..."/></center>');
            if ($(this).is('.checkbox_no')) {
                $(this).removeClass('checkbox_no');
                $(this).addClass('checkbox_yes');
                if ($(this).is('.overlocalitati')) {
                    this_id = $(this).attr('rel');
                    $('#sublocalitati-'+this_id).toggle();
                }
            }
            else {
                child_id = ID.replace('id_judet', 'sublocalitati');
                $('#'+child_id+' > li > a').each (function() {
                    if ($(this).is('.checkbox_yes')) {
                        $(this).removeClass('checkbox_yes');
                        $(this).addClass('checkbox_no');
                    }
                })
                $(this).removeClass('checkbox_yes');
                $(this).addClass('checkbox_no');
                if ($(this).is('.overlocalitati')) {
                    this_id = $(this).attr('rel');
                    $('#sublocalitati-'+this_id).toggle();
                }
            }
            // iau indicatoarele filtrelor activate
            mydata = '';
            $('a.filtru').each (function() {
                if ($(this).is('.checkbox_yes')) {
                    myvalue = ' ' + $(this).attr('id') + '|';
                }
                else {
                    myvalue = '';
                }
                mydata += myvalue;
            })

            $.ajax({
            type: "POST",
            url: "http://www.pensiuni-turistice.eu/includes/modules/boxes/ajax_"+sectiune+"_cazare_left.php",
            data: "seo=<?=$VARS['seo'];?>&filtre="+ mydata,
            cache: false,
            success: function(html){
            $("#rezultat_filtre").html(html);
            }
            });
        }
        else {
            $("#rezultat_filtre").html('Nu s-au gasit rezultate care sa corespunda cautarii dumneavoastra');
        }
        return false;
    });

    // home_center | vezi toate zonele
    $('.more').live("click",function() {
        var ID = $(this).attr("id");
        if(ID) {
            $("#more"+ID).html('<img src="http://www.pensiuni-turistice.eu/images/ajax-loader.gif" border="0" alt="Se incarca..."/>');
            $.ajax({
                type: "POST",
                url: "includes/modules/boxes/ajax_list_zone.php",
                data: "lastmsg="+ ID,
                cache: false,
                success: function(html) {
                    $("ul#updates_"+ID).append(html);
                    if (ID == 'zone') {
                        $("#"+ID).removeClass('more');
                        $("#"+ID).attr('href', 'http://www.pensiuni-turistice.eu/zone-turistice.html');
                        $("#"+ID).text('Vezi toate zonele');
                    } // endif
                    if (ID == 'regiuni') {
                        $("#more_"+ID).remove();
                    }
                }
            });
        }
        else {
            $(".morebox").html('The End');
        }
        return false;
    });
    
    // pensiune_left_info schimbare imagine
    // incarcare imagine mare (pensiune/atractie)
    $('.more_img').live("click",function() {
        var src = $(this).attr("src");
        if(src) {
            $("#loadinfo").html('<center><img src="http://www.pensiuni-turistice.eu/images/ajax-loader.gif" border="0" alt="Se incarca..." align="center"/></center>');
            $.ajax({
                type: "POST",
                url: "http://www.pensiuni-turistice.eu/includes/modules/boxes/ajax_imagine_mare.php",
                data: "src="+ src,
                cache: false,
                success: function(html){
                    $("#main_img").attr('src', html);
                    $("#loadinfo").html('');
                }
            });
        }
        else {
            $(".morebox").html('The End');
        }
        return false;
    });
});
// end function