

jQuery(document).ready(function($) {

  /* Accessible input values
   ---------------- */
  $("input.propagate").each(function(){
      var $this = $(this);
      var val = $('label[for=' + $this.attr('id') + ']').html();
      if($this.val() == '') $this.val(val);
      $this.focus(function(){
          if($this.val() == val) $this.val('');
      }).blur(function(){
          if($this.val() == '') $this.val(val);
      });
  });
  
  // add .open to dropdown on hover    
  
  
  
  $('#navigation li.nav-1:first, #navigation li.nav-2:first, #navigation li.nav-3:first, #navigation li.nav-4:first').hover(function() {
      $(this).addClass('open');
  }, function() {
      $(this).removeClass('open');
  });
  
  // swapping content
  function initTabs() { 
    $('.sub-nav a').bind('click',function(e) { 
      e.preventDefault(); 
      var thref = $(this).attr("href").replace(/#/, ''); 
    $('.sub-nav a').removeClass('current'); 
    $(this).addClass('current'); 
    $('.content').removeClass('active'); 
    $('#'+thref).addClass('active'); 
   }); }

   //initTabs(); 
   
   // target IE6 and below
  if ($.browser.msie && $.browser.version <= 7 ) {

    $('#navigation li').hover(function() {
        $(this).addClass('hover');
    }, function() {
        $(this).removeClass('hover');
    });
    
    
    $('.featured li').hover(function() {
        $(this).addClass('hover');
    }, function() {
        $(this).removeClass('hover');
    });
    
    
    $('.featured li').hover(function() {
        $('.featured li.hover span').css('display','none');
    }, function() {
        $('.featured li span').css('display','block');
    });
    
    
    $('#navigation li').addClass('nav-ie6');
    $('#navigation li').hover(function() { 
      $(this).removeClass('nav-ie6');
    }, function () {
      $(this).addClass('nav-ie6');
    });
    
  };
  
  
/* Added
-----------------------------------------------------------------------------------------------*/
   	var el_postnav = $('.sub-nav');
	var el_postfields = $('#content');
		
    $('a',el_postnav).click(function(){ 
    	var text = $(this).text();
		var li = $(this).parent();
    	var i = $('li',el_postnav).index(li);
    	
    	$('a',el_postnav).removeClass('current');
    	$(this).addClass('current');
    	
    	$('div.content',el_postfields).removeClass('active');
		$('div.content:eq('+i+')',el_postfields).addClass('active');
		
		$(location).attr('hash',i);
		
		return false;
    });
	
	var hash = $(location).attr('hash').replace(/\#/,'');
	if (hash) {
		$('li:eq('+hash+') a',el_postnav).trigger('click');
	}

});