        $(function(){
            $('#slides').slides({
                effect: 'fade',
                fadeSpeed: 500,
                preload: true,
                preloadImage: 'images/slide/loading.gif',
                play: 5000,
                pause: 2500,
                hoverPause: true,
                generatePagination: false,
                pagination: false,
                animationStart: function(current){
                    $('.caption').animate({
                        bottom:-35
                    },100);
                    if (window.console && console.log) {
                        // example return of current slide number
                        console.log('animationStart on slide: ', current);
                    };
                },
                animationComplete: function(current){
                    $('.caption').animate({
                        bottom:0
                    },200);
                    if (window.console && console.log) {
                        // example return of current slide number
                        console.log('animationComplete on slide: ', current);
                    };
                },
                slidesLoaded: function() {
                    $('.caption').animate({
                        bottom:0
                    },200);
                }
            });
        });

        var priceSlider = null;
        $(function() {
            priceSlider = $( "#priceSlider" ).slider({
                range: "min",
                value: 0,
                min: 0,
                max: 1,
                slide: function( event, ui ) {
                    $( "#amount" ).val( ui.value + " €" );
                }
            });
            $( "#amount" ).val( priceSlider.slider( "value" ) + " €" );

            $( "#datepicker" ).datepicker({
                changeMonth: true,
                changeYear: true,
                dateFormat: 'yy-mm-dd'
            });
        });

        function loadFilterData(titlu, id, varhtml) {
            $("#" + id).find("dd ul li").remove();
            $("#" + id).find("dd ul").html(varhtml);
            $("#" + id).find("dd ul li a").click(function() {
                var text = titlu + ": " + $(this).html();
                $(this).parent().parent().parent().parent().find("dt a span").html(text); //".dropdown dt a span"
                $(this).parent().parent().hide();
                refreshFilter();
            });
        }
        
        function getSelectedValue(id) {
            return $("#" + id).find("dt a span.value").html();
        }
        
        function setSelectedValue(titlu, id) {
            var setvalue = $("#" + id).find("dd ul li a.selectat").html();
            if (setvalue != null) {
                var text = titlu + ": " + setvalue;
                $("#" + id).find("dt a span").html(text);
            }
        }

        function refreshFilter() {
            var esteFiltru = $( "#searchFilterValuesList" ).attr("value");
            if (esteFiltru) {
                var listaVal = eval( esteFiltru );
                $.ajax({
                    data: listaVal
                });
                if (listaVal.data != "") {
                    $( "#datepicker" ).attr("value", listaVal.data);
                }
                if (listaVal.text != "") {
                    $( "#cuvinte_cheie" ).find("input.box").attr("value", listaVal.text);
                }
                $( "#searchFilterValuesList" ).attr("value","");
            } else {
                $.ajax({
                    data: ({
                        tipoferta : getSelectedValue('ddtipoferta'),
                        tara : getSelectedValue('ddtara'),
                        loco : getSelectedValue('ddloco'),
                        transport : getSelectedValue('ddtransport'),
                        masa : getSelectedValue('ddmasa'),
                        categorie : getSelectedValue('ddcategorie'),
                        unitate : getSelectedValue('ddunitate'),
                        pret : priceSlider.slider( "value" ),
                        data : $( "#datepicker" ).attr("value")
                    })
                });
            }
        }

        function displayResults() {
            $.ajax({
                data: ({
                    tipoferta : getSelectedValue('ddtipoferta'),
                    tara : getSelectedValue('ddtara'),
                    loco : getSelectedValue('ddloco'),
                    transport : getSelectedValue('ddtransport'),
                    masa : getSelectedValue('ddmasa'),
                    categorie : getSelectedValue('ddcategorie'),
                    unitate : getSelectedValue('ddunitate'),
                    pret : priceSlider.slider( "value" ),
                    pretmax : priceSlider.slider( "option", "max" ),
                    data : $( "#datepicker" ).attr("value"),
                    text : $( "#cuvinte_cheie" ).find('input[name=q]').attr("value"),
                    showResults : true
                })
            });
        }

        $(document).ready(function() {
/*
            $(".dropdown dt a").click(function() {
                $(this).parent().parent().find("dd ul").toggle(); //".dropdown dd ul"
            });
*/
            // get dd values
            $.ajaxSetup({
               url: $('#ajaxSearchLink').attr('value'),
               global: false,
               type: "POST",
               dataType: "script",
               async: false // block browser while loads
            });            
            refreshFilter();

            $("#buton_cautare img").bind('click', function(e) {
                displayResults();
            });

            $(document).bind('click', function(e) {
                var $clicked = $(e.target);

                // selecturile
                $(".dropdown dd ul").not( $clicked.closest('.dropdown').find("dd ul") ).hide();
                if ( $clicked.parents().hasClass("dropdown") ) {
                    $clicked.closest('.dropdown').find("dd ul").toggle();
                }
               
                //click pe div clickDiv clickLink class
                if ($clicked.hasClass("clickDiv") || ($clicked.closest('div.clickDiv').size() == 1)) {
                    if (! $clicked.hasClass("clickDiv")) $clicked = $clicked.closest('div.clickDiv');
                    var linkul = $clicked.find("a.clickLink").attr("href");
                    var target = $clicked.find("a.clickLink").attr("target");
                    if (linkul != undefined) {
                        if (target != "_blank") {
                            document.location = linkul;
                        } else {
                            $('#content').add('<form id="newForm" target="_blank" action="' + linkul + '" method="GET"></form>').appendTo(document.body);
                            $('#newForm').submit().remove();
                        }
                    }
                }
            });

            //lightbox
            $("a[rel=photo_gallery]").fancybox({
                'transitionIn'  : 'none',
                'transitionOut' : 'none',
                'titlePosition' : 'over',
                'titleFormat'   : function(title, currentArray, currentIndex, currentOpts) {
                    return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
                }
            });
            $("a.photo_gallery").bind('click', function(e) {
                $("a[rel=photo_gallery]").first().trigger('click');
            });

            $('div.clickDiv').css("cursor", "pointer");

            //filtru left click checkbox
            $("input[type=checkbox].filtru").bind('click', function(e) {
                document.location = $(this).attr("value");
            });

            //height left
            var h1 = $("#mainContainer").height() + 10; 
            var h2 = $("#rightContainer").height();
            var h3 = $("#leftContainer").height();
            if (h3 < 600) h3 = 600; // min height
            $("#leftContainer").height( Math.max(h1, h2, h3) );
        });

var sliderHeight = "115px";

$(document).ready(function(){

    $('.slider').each(function () {
        var current = $(this);
        if (current.hasClass('sliderdisabled') == false) {
            current.attr("box_h", current.height());
            current.css("height", sliderHeight);
            current.parent().find(".slider_menu").html('<a href="#">Citeşte tot</a>');
            current.parent().find(".slider_menu a").click(function() { openSlider() })
        } else {
            current.hide();
            current.parent().find(".slider_menu").hide();
        }
        current.parent().css("height", "100%");
        current.parent().css("overflow", "visible");        
    });

});

function openSlider() {
    var open_height = $(".slider").attr("box_h") + "px";
    $(".slider").animate({"height": open_height}, {duration: "slow" });
    $(".slider_menu").html('<a href="#">Închide</a>');
    $(".slider_menu a").click(function() { closeSlider() })
}

function closeSlider() {
    $(".slider").animate({"height": sliderHeight}, {duration: "slow" });
    $(".slider_menu").html('<a href="#">Citeşte tot</a>');
    $(".slider_menu a").click(function() { openSlider() })
}


