$(function(){
    $(".delme").focus(function(){
        if ($(this).is('input')) {
            var orival = $(this).val();
            $(this).val("");
        }else{
            var orival = $(this).html();
            $(this).html("");
        }
        $(this).blur(function(){
            if($(this).is('input')){
                if ($(this).val() != "" && $(this).val() != orival) {
                    $(this).removeClass('delme').unbind('blur').unbind('focus');
                }else{
                    $(this).val(orival);
                }
            }else{
                if ($(this).html() != "" && $(this).html() != orival) {
                    $(this).removeClass('delme').unbind('blur').unbind('focus');
                }else if ($.browser.safari && $(this).val() != "" && $(this).val() != orival) {
                    $(this).removeClass('delme').unbind('blur').unbind('focus');
                }else{
                    $(this).html(orival);
                }
            }
        });
    });
    $(".services").addClass("closed");
    $(".name").click(function(){
        var place = $(this).parents(".services").find(".service");
        var places = $(this).parents(".services");
        if(places.hasClass("closed")){
            place.slideDown(600, function(){
                if(places.hasClass("closed")){
                    places.removeClass("closed").addClass("open");
                }
            });
        }else{
            place.slideUp(600, function(){
                if(places.hasClass("open")){
                    places.removeClass("open").addClass("closed");
                }
            });
        }
        return false;
    });
    $(".select .livsec").hide();
    $(".select .open-close, .select span").click(function(){
        $(this).siblings('.livsec').toggle().find('li').click(function(){
            var select = $(this).parents('.select');
            $('input', select).val($(this).html());
            $('.livsec', select).hide();
        });
        return false;
    });
    $("#navigations li:last").addClass("last");
    $("#footer .menu li:last").addClass("last");
    $(".entry-content table tr:first").addClass("first");
    $('.scrollbar').scrollbar();
    $('#demo2 a:first').click(function(ev){
        ev.preventDefault();
        $('#demo2').find('.scrollbar-pane').children(':first').clone().appendTo('.scrollbar-pane');
        $('#container2').scrollbar('repaint');
    });
    $('#demo2 a:last').click(function(ev){
        ev.preventDefault();
        $('#demo2').find('.scrollbar-pane').children(':first').remove();
        $('#container2').scrollbar('repaint');
    });
});


