;(function($) {
    $(document).ready(function() {
    	/*
    	 * DOM and Event selectors go here....just like CSS
    	 * First you select an object and/or event...
    	 * Then you specify jquery properties for that object/event...
    	 * Or a function you'd like to execute...
    	 */ 
    	 $("a[href=#network-links]").click(function() {
    	     $(this).blur();
    	     $("#network-links").toggle();
    	     return false;
    	 });
    	 $(document).click(function(e) {
             var array_location = $.inArray($("#more-network-links").get(0), $(e.target).parents());
             if (array_location < 0) {
                 $("#network-links").hide();
             }
    	 });
     
     
         // auto scroll to
         $(".scroll-to-bottom").each(function() {
             $(this).attr({ scrollTop: $(".scroll-to-bottom").attr("scrollHeight") });
             $("body").attr({ scrollTop: 0 });
         });
     
         // De-initialize input box on focus
         $("input.text.initial").focus(function() {
             $(this).val('');
             $(this).removeClass('initial');
             $(this).unbind('focus');
         });
     
         // explainer text revealer
         $("#login-explainer-reveal").click(function() {
             $("#login-explainer-text").toggle("blind", { direction: "vertical" }, 1000);
             return false;
         });
     
         $("#login-explainer-close").click(function() {
             $("#login-explainer-text").hide("blind", { direction: "vertical" }, 1000);
             return false;
         });
     
     
         // Javascript tabs
         $("#sidebar ul.js-tabs li").each(function() {
             var the_widget = $(this).parents(".widget");
             $(this).show();
             $(this).children("a").click(function() {
                 var the_id = $(this).attr("href");
                 the_widget.children(".js-tab-pane:not("+the_id+")").hide();
                 the_widget.children(".js-tab-pane"+the_id).show();
                 $(this).parents("ul.js-tabs").children("li").each(function() {
                     $(this).removeClass('selected');
                 });
                 $(this).parent("li").addClass('selected');
                 the_widget.children(".js-tab-pane"+the_id).show();
                 return false;
             });
         });
     
         // tag cloud revealer
         $("#navigation-tag-cloud-revealer").click(function() {
             $("#navigation-tag-cloud-container").toggle();
             return false;
         });
     
         $("#navigation-tag-cloud-closer").click(function() {
             $("#navigation-tag-cloud-container").hide();
             return false;
         });
         
         // initial value in search box
         $(".infield-label").each(function() {
             var initial_value = $("label[for="+$(this).attr("id")+"]").html();
             if ($(this).val() != initial_value) {
                 $(this).val(initial_value);
             }
             $(this)
                 .focus(function() {
                     $(this).parents("form").addClass("focus");
                     if ($(this).hasClass('initial')) {
                         $(this).val('');
                         $(this).removeClass("initial");
                     }
                 })
                 .blur(function() {
                     $(this).parents("form").removeClass("focus");
                     if (!$(this).val()) {
                         $(this).val(initial_value);
                         $(this).addClass("initial");
                     }
                 })
             ;
         });
         
     });
 })(jQuery);
