function Edit() {
  this.init = function() {
    Edit.installObservers();
  }
  
  this.installObservers = function() {
    $('#edit_selector a').click( function() {
      $('#edit_selector div a').removeClass('selected');
      $(this).addClass('selected');
      var postType = $(this).parent().attr('class');

      // switching to text-post mode
      function textSwap() {
        $('input#post_category').val('text');
        
        if ($('span.title').is(':visible') == false) { 
          // hide caption label, show title label 
          $('span.caption').fadeOut(300, function() {
            $('span.title').show();
          });

          // hide image url input, show textarea for input
          if ($('#post_url').is(':visible') == true) {
            $('#post_url').fadeOut(300, function(){
              $('#post_body').show();
              $('#url_input').val('');
            });
          }
          // hide video embed code input, show textarea for input
          if ($('#post_embed').is(':visible') == true) {
            $('#post_embed').fadeOut(300, function() {
              $('#post_body').show();
              $('#embed_input').val('');
            });
          }
        }
      } // end of switching to text-post
      
      // switching to image-post mode
      function photoSwap() {
        $('input#post_category').val('photo');
        
        if ($('#post_url').is(':visible') == false) {
          // hide title label, show caption label
          $('span.title').fadeOut(300, function() {
            $('span.caption').show();
          });

          // hide textarea input, show image url input
          if ($('#post_body').is(':visible') == true) {
            $('#post_body').fadeOut(300, function() {
              $('#post_url').show();
              $('#body_input').val('');
            });
          }
          
          // hide video embed code input, show textarea input
          if ($('#post_embed').is(':visible') == true) {
            $('#post_embed').fadeOut(300, function() {
              $('#post_url').show();
              $('#embed_input').val('');
            });
          }
        }
      } // end of switching to image-post

      function videoSwap(){
        $('input#post_category').val('video');
        
        if ($('#post_embed').is(':visible') == false) {
          // hide title label, show caption label
          $('span.title').fadeOut(300, function() {
            $('span.caption').show();
          });

          // hide textarea input, show video embed code input
          if ($('#post_body').is(':visible') == true) {
            $('#post_body').fadeOut(300, function() {
              $('#post_embed').show();
              $('#body_input').val('');
            });
          }

          // hide image url input, show video embed code input
          if ($('#post_url').is(':visible') == true) {
            $('#post_url').fadeOut(300, function() {
              $('#post_embed').show();
              $('#url_input').val('');
            });
          }
        }
      } // end of switching to video-post

      switch (postType) {
        case 'text':
           textSwap();
        break;
        case 'video':
           videoSwap();
        break;
        case 'photo':
           photoSwap();
        break;
      }
      
      return false;
    }); // end of click event definition
  } // end of installObservers function
} // end of Edit class

Edit = new Edit();
