$(document).ready( function() {

  $("a\.fancy").fancybox({
    'hideOnContentClick': false,
    'frameWidth': 600,
    'frameHeight': 450,
    'callbackOnShow': function(){$('#c_text').focus();}
  });

  $('\.tooltip').wTooltip({
    style: {
        border: "1px solid #808080",
        background: "#a9a9a9",
        color: "white",
        fontSize: "0.7em",
        padding: "5px 10px"
    }
  });


  $('#hide-int-info').click(function() {
    $.ajax({
      url: './?action=hide_iinfo',
      cache: false,
      success: function(html){
        $('#int-info').hide(750);
      }
    });
  });
  $('#lang-img').click(function() {$('#lang-select').slideToggle(500);});
  $('#chmod-help-toggle').click(function() {$('#install-list').slideToggle(750);});
  $('#p-tags-viewer').click(function() {$('#tags-in').slideToggle(750);});
  $('#p-info-viewer').click(function() {$('#info-in').slideToggle(750);});
  $('#p-settings-viewer').click(function() {$('#settings-in').slideToggle(750);});
  $('#page-key-viewer').click(function() {$('#page-key').slideToggle(750);});
  $('#post-full-story-viewer').click(function() {$('#full-story-wrap').slideToggle(750);});

  $('#post-img-add-cat').click(function() {
    $('#post-add-cat').show(500);
    $('#add_cat').focus();
  });
  $('#post-add-cat-hide').click(function() {$('#post-add-cat').hide(500);});
  
  $('#smiles-toggle-short_story').click(function() {$('#simple-format-short_story').slideToggle();});
  $('#simple-format-short_story img').click(function() {$('#simple-format-short_story').slideToggle();});
  $('#smiles-toggle-full_story').click(function() {$('#simple-format-full_story').slideToggle();});
  $('#simple-format-full_story img').click(function() {$('#simple-format-full_story').slideToggle();});
  $('#smiles-toggle-text').click(function() {$('#simple-format-text').slideToggle();});
  $('#simple-format-text img').click(function() {$('#simple-format-text').slideToggle();});
  $('#personal-info-toggle').click(function() {$('#personal-info').slideToggle(1000);$('#contact-info').slideToggle(1000);});
  $('#admin-info-toggle').click(function() {$('#admin-info').slideToggle(1000);});
  $('#view-comment-info').click(function() {$('#comment-info').slideToggle(750);});
  $('#filter-viewer').click(function() {$('\.filter').slideToggle(750);});
  $('#comments_bb1').click(function() {$('#bb-buttons-viewer').show(750);});
  $('#comments_bb2').click(function() {
    $('#bb-buttons-viewer').hide(750);
    $('#bb-buttons').hide(750);
  });
  $('#bb-buttons-viewer').click(function() {$('#bb-buttons').slideToggle(750);});
  $('#page-pass-on').click(function() {$('#page-pass').show(750);});
  $('#page-pass-off').click(function() {$('#page-pass').hide(750);});
  $('#imgupload-starter').click(function() {$('#imgupload').fileUploadStart();});
  
  $('#email').focus(function() {$('#profile-old-pass').show();});
  $('#pass1').focus(function() {
    $('#profile-old-pass').show();
    $('#tr-pass2').show();
  });
  
  $('#tmpl-title-toggle').click(function() {$('#tmpl-title').slideToggle(750);});
  $('#tmpl-links-toggle').click(function() {$('#tmpl-links').slideToggle(750);});
  $('#tmpl-author-toggle').click(function() {$('#tmpl-author').slideToggle(750);});
  $('#tmpl-cat-toggle').click(function() {$('#tmpl-cat').slideToggle(750);});
  $('#tmpl-tags-toggle').click(function() {$('#tmpl-tags').slideToggle(750);});
  $('#tmpl-date-toggle').click(function() {$('#tmpl-date').slideToggle(750);});
  $('#tmpl-time-toggle').click(function() {$('#tmpl-time').slideToggle(750);});

  $('#tmpl_group1').click(function() {$('#group_mode1').attr('checked', 'checked');});
  $('#tmpl_group2').click(function() {$('#group_mode2').attr('checked', 'checked');});
  $('#group_mode2').click(function() {$('#tmpl_group2').focus();});
  
  
  
  
  if (document.location.hash) {
    $(document.location.hash).css('background', '#ffff93');
  }
  
  
  
  
  
  /* Add category via ajax */
  $('#catajax').click(function() {
    $.ajax({
      url: './mn-categories.php?action=ajaxcall&cat_name=' + $('#add_cat').val(),
      cache: false,
      success: function(html){
        $('#cat').append(html);
        $('#post-img-add-cat').attr('src', './stuff/img/icons/tick.png');
      }
    });
    $('#add_cat').val('');
    $('#post-add-cat').hide(500);
  });

  $('#add_cat').keypress(function(e) {
    var k = e.keyCode || e.which;
    if (k == 13) {
      e.preventDefault();
    	$.ajax({
        url: './mn-categories.php?action=ajaxcall&cat_name=' + $('#add_cat').val(),
        cache: false,
        success: function(html){
          $('#cat').append(html);
          $('#post-img-add-cat').attr('src', './stuff/img/icons/tick.png');
        }
      });
      $('#add_cat').val('');
      $('#post-add-cat').hide(500);
    }
  });
  
  
  
  
  /* Add tag via ajax */
  $('#tagajax').click(function() {
    $.ajax({
      url: './mn-tags.php?action=ajaxcall&tag_name=' + $('#new_tag').val(),
      cache: false,
      success: function(html){
        $('\.tags').append(html);
      }
    });
    $('#new_tag').val('');
    $('#new_tag').focus();
  });

  $('#new_tag').keypress(function(e) {
    var k = e.keyCode || e.which;
    if (k == 13) {
      e.preventDefault();
    	$.ajax({
        url: './mn-tags.php?action=ajaxcall&tag_name=' + $('#new_tag').val(),
        cache: false,
        success: function(html){
          $('\.tags').append(html);
        }
      });
      $('#new_tag').val('');
      $('#new_tag').focus();
    }
  });



  $('#select-all').click(function(){
		var checked_status = this.checked;
		$('\.input-tag').each(function(){
			this.checked = checked_status;
		});
	});

});