jQuery(document).ready(function() {
  
  /* Add hover class to dropdown navigation : SUPPORT FOR IE6 */
  
  jQuery('#nav > li, #nav-2 > li').mouseover(function() {
    jQuery(this).addClass('hover');
  }).mouseout(function() {
    jQuery(this).removeClass('hover');
  });
  
  /* Column 2 Post List */
  
  jQuery('.col-2 .post-list li a').click(function() {
    var current_list = jQuery(this).attr('class');
    
    jQuery(this).parent().parent().find('.current').removeClass('current');
    jQuery(this).parent().addClass('current');
    
    jQuery(this).parent().parent().parent().parent().find('.post-listc ul').hide();
    jQuery(this).parent().parent().parent().parent().find('.post-listc ul.' + current_list).fadeIn();
    return false;
  })
  
  /* Remove default text from input fields on click */
  
  jQuery('input').focus(function() { // Remove the default value on focus
    var defaultValue = jQuery(this).attr('title');
    
    if(jQuery(this).val() == defaultValue) {
      jQuery(this).val('');
    };
  });
  
  jQuery('input').blur(function() { // Add the default value on blur
    var defaultValue = jQuery(this).attr('title');
    
    if(jQuery(this).val() == '') {
      jQuery(this).val(defaultValue);
    };
  });
  jQuery('input').blur();
  
  /* Featured Actions */
  
  jQuery('.featured ul li a.title').mouseover(function() {
    jQuery(this).parent().parent().find('.img, .excerpt').hide();
    
    jQuery(this).parent().find('.img, .excerpt').show();
    return false;
  });
  
  /* Videos */
  
  jQuery('.youtube ul li a').click(function() {
    var type = jQuery(this).text();
    var vids = jQuery(this).parent().parent().parent().parent().find('div');
    var vidsL = jQuery(vids).length;
    
    if(type == 'next') {
      var current = jQuery(vids).parent().find('div:visible');
      var index = jQuery('.youtube div').index(current);
      var index_length = index + 1;
      
      if(index_length != vidsL) {
        jQuery(this).parent().parent().find('.alignleft').show();
        
        var hide = jQuery('.youtube div').get(index);
        jQuery(hide).hide();
        
        var show = jQuery('.youtube div').get(index + 1);
        jQuery(show).show();
      }
      else {
        jQuery(this).hide();
        jQuery(this).parent().parent().find('.alignleft').show();
      }
    }
    else {
      var current = jQuery(vids).parent().find('div:visible');
      var index = jQuery('.youtube div').index(current);
      var index_length = index + 1;
      
      if(index_length != 1) {
        jQuery(this).parent().parent().find('.alignright').show();
        
        var hide = jQuery('.youtube div').get(index);
        jQuery(hide).hide();
        
        var show = jQuery('.youtube div').get(index - 1);
        jQuery(show).show();
      }
      else {
        jQuery(this).hide();
        jQuery(this).parent().parent().find('.alignright').show();
      }    
    }
    
    return false;
  });
});