$(document).ready(function(){

    // Edit Profile Date Picker (DOB)
    $("#editProfileDOB").birthdaypicker({});

    // Feed
    $('#feedSlideToggle').click(function() {
      $('#update_feed').slideToggle('400', function() {
            // Animation complete.
      });
    });

    // Notifications
    $('.notifications').hide();
    getNotifications();
    $('#notifications').click(function() {
        $('.notifications').slideToggle('400', function() {
            // Animation complete.
        });
    });
    setInterval("getNotifications()", 30000); // 30000 milliseconds = 30 seconds

    // Search Page
    $(function() {
        $(".search_button, .search_spg").live('click', function() {

            var number = $(this).attr('title');
            var searchString = $("#search_box").val();
            var data = 'search='+ searchString+ '&spg='+ number;

            // if searchString is not empty
            if(data) {
                // ajax call
                $.ajax({
                    type: "POST",
                    url: "applications/cg/controllers/backend/do_search.php",
                    data: data,
                    beforeSend: function(html) { // this happens before actual call
                        $("#results").html('');
                        $("#searchresults").show();
                        $(".word").html(searchString);
                   },
                   success: function(html){ // this happens after we get results
                        $("#results").show();
                        $("#results").append(html);
                  }
                });
            }
            return false;
        });
    });

/*
    $(function() {
        $("#get_notifications").live('click', function() {
                // ajax call
                $.ajax({
                    type: "GET",
                    url: "applications/cg/controllers/backend/get_notifications.php",
                   success: function(html){ // this happens after we get results
                        $(".notifications_tooltip").append(html);
                  }
                });
            return false;
        });
    });
*/
    
});
