$(document).ready(function() {
    var hash = window.location.hash;
    
    (!hash) ?  
        hideAllExcept('#' + $('#toggleThis > div:first').attr('id')) 
            : hideAllExcept(window.location.hash);

    $('a.toggle').click(function() {
        var href = $(this).attr('rel');
        hideAllExcept(href);
    });
});


function hideAllExcept(el) {
    $('#toggleThis div').addClass('hideitall');
    $(el).removeClass('hideitall');

    $('a.toggle').removeClass('active');
    $('a[rel="' + el + '"]').addClass('active');
    
}

// Swap the class name to change the open / close state of episode list

 /****************************************************************
  ** Toggle ClassName
*****************************************************************/

  function swapCSS(el,elb)
{
var o = document.getElementById(el);
var ob = document.getElementById(elb);
var c1 = 'hideitall';
var c2 = 'active';
var b1 = 'off';
var b2 = 'on';

      o.className=!(RegExp('\\b'+c1+'\\b').test(o.className))?o.className.replace(c2,c1):o.className.replace(c1,c2);
      ob.className=!(RegExp('\\b'+b1+'\\b').test(ob.className))?ob.className.replace(b2,b1):ob.className.replace(b1,b2);
}



/*                                  

    http://enure.net/dev/hide-all-except-one/

*/
